aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--package.json3
-rw-r--r--src/commands/moderation/modlog.ts30
-rw-r--r--src/lib/extensions/discord-akairo/BushClientUtil.ts6
-rw-r--r--src/lib/extensions/discord.js/BushGuildMember.ts25
-rw-r--r--src/lib/models/ActivePunishment.ts6
-rw-r--r--src/lib/models/ModLog.ts4
-rw-r--r--src/listeners/custom/bushPurge.ts1
-rw-r--r--yarn.lock21
8 files changed, 52 insertions, 44 deletions
diff --git a/package.json b/package.json
index 7424bea..07c4066 100644
--- a/package.json
+++ b/package.json
@@ -41,7 +41,6 @@
"@types/node-os-utils": "^1",
"@types/numeral": "^2",
"@types/tinycolor2": "^1",
- "@types/uuid": "^8.3.0",
"@types/validator": "^13.6.3",
"@typescript-eslint/eslint-plugin": "^4.14.1",
"@typescript-eslint/parser": "^4.14.1"
@@ -69,6 +68,7 @@
"mathjs": "^9.4.4",
"module-alias": "^2.2.2",
"moment": "^2.29.1",
+ "nanoid": "^3.1.25",
"node-fetch": "^2.6.1",
"node-os-utils": "^1.3.5",
"numeral": "^2.0.6",
@@ -82,7 +82,6 @@
"source-map-support": "^0.5.19",
"tinycolor2": "^1.4.2",
"typescript": "^4.4.2",
- "uuid": "^8.3.2",
"wolfram-alpha-api": "https://products.wolframalpha.com/api/libraries/javascript/wolfram-alpha-api-1.0.0-rc.1.tgz"
},
"eslintConfig": {
diff --git a/src/commands/moderation/modlog.ts b/src/commands/moderation/modlog.ts
index 0be6971..459e53c 100644
--- a/src/commands/moderation/modlog.ts
+++ b/src/commands/moderation/modlog.ts
@@ -1,5 +1,5 @@
import { BushCommand, BushMessage, BushSlashMessage, BushUser, ModLog } from '@lib';
-import { User } from 'discord.js';
+import { MessageEmbed, User } from 'discord.js';
export default class ModlogCommand extends BushCommand {
public constructor() {
@@ -23,7 +23,7 @@ export default class ModlogCommand extends BushCommand {
{
id: 'hidden',
match: 'flag',
- flags: ['--hidden', '-h'],
+ flag: ['--hidden', '-h'],
default: false
}
],
@@ -51,8 +51,8 @@ export default class ModlogCommand extends BushCommand {
const modLog = [
`**Case ID**: ${log.id}`,
`**Type**: ${log.type.toLowerCase()}`,
- `**User**: <@!${log.user}> (${log.user})`,
- `**Moderator**: <@!${log.moderator}> (${log.moderator})`
+ `**User**: <@!${log.user}>`,
+ `**Moderator**: <@!${log.moderator}>`
];
if (log.duration) modLog.push(`**Duration**: ${util.humanizeDuration(log.duration)}`);
modLog.push(`**Reason**: ${trim(log.reason ?? 'No Reason Specified.')}`);
@@ -73,14 +73,20 @@ export default class ModlogCommand extends BushCommand {
},
order: [['createdAt', 'ASC']]
});
- if (!logs.length) return message.util.reply(`${util.emojis.error} **${foundUser.tag}** does not have any modlogs.`);
- const niceLogs = logs.filter((log) => !log.pseudo && !log.hidden && !hidden).map((log) => this.#generateModlogInfo(log));
- const chunked: string[][] = util.chunk(niceLogs, 3);
- const embedPages = chunked.map((chunk) => ({
- title: `${foundUser.tag}'s Mod Logs`,
- description: chunk.join('\n━━━━━━━━━━━━━━━\n'),
- color: util.colors.default
- }));
+ const niceLogs = logs
+ .filter((log) => !log.pseudo || (!log.hidden && !hidden))
+ .map((log) => this.#generateModlogInfo(log));
+ if (!logs.length || !niceLogs.length)
+ return message.util.reply(`${util.emojis.error} **${foundUser.tag}** does not have any modlogs.`);
+ const chunked: string[][] = util.chunk(niceLogs, 4);
+ const embedPages = chunked.map(
+ (chunk) =>
+ new MessageEmbed({
+ title: `${foundUser.tag}'s Mod Logs`,
+ description: chunk.join('\n━━━━━━━━━━━━━━━\n'),
+ color: util.colors.default
+ })
+ );
return await util.buttonPaginate(message, embedPages, undefined, true);
} else if (search) {
const entry = await ModLog.findByPk(search as string);
diff --git a/src/lib/extensions/discord-akairo/BushClientUtil.ts b/src/lib/extensions/discord-akairo/BushClientUtil.ts
index fec0174..91d5eb6 100644
--- a/src/lib/extensions/discord-akairo/BushClientUtil.ts
+++ b/src/lib/extensions/discord-akairo/BushClientUtil.ts
@@ -1133,6 +1133,7 @@ export class BushClientUtil extends ClientUtil {
reason: string | undefined | null;
duration?: number;
guild: BushGuildResolvable;
+ pseudo?: boolean;
},
getCaseNumber = false
): Promise<{ log: ModLog | null; caseNum: number | null }> {
@@ -1158,7 +1159,8 @@ export class BushClientUtil extends ClientUtil {
moderator,
reason: options.reason,
duration: duration,
- guild
+ guild,
+ pseudo: options.pseudo ?? false
});
const saveResult: ModLog | null = await modLogEntry.save().catch(async (e) => {
await util.handleError('createModLogEntry', e);
@@ -1176,7 +1178,7 @@ export class BushClientUtil extends ClientUtil {
user: BushGuildMemberResolvable;
duration: number | undefined;
guild: BushGuildResolvable;
- modlog?: string;
+ modlog: string;
extraInfo?: Snowflake;
}): Promise<ActivePunishment | null> {
const expires = options.duration ? new Date(new Date().getTime() + options.duration ?? 0) : undefined;
diff --git a/src/lib/extensions/discord.js/BushGuildMember.ts b/src/lib/extensions/discord.js/BushGuildMember.ts
index 4dd1a5d..5575303 100644
--- a/src/lib/extensions/discord.js/BushGuildMember.ts
+++ b/src/lib/extensions/discord.js/BushGuildMember.ts
@@ -145,25 +145,24 @@ export class BushGuildMember extends GuildMember {
const ret = await (async () => {
if (options.addToModlog || options.duration) {
- const { log: modlog } = options.addToModlog
- ? await util.createModLogEntry({
- type: options.duration ? ModLogType.TEMP_PUNISHMENT_ROLE : ModLogType.PERM_PUNISHMENT_ROLE,
- guild: this.guild,
- moderator: moderator.id,
- user: this,
- reason: 'N/A'
- })
- : { log: null };
- caseID = modlog?.id;
-
- if (!modlog && options.addToModlog) return 'error creating modlog entry';
+ const { log: modlog } = await util.createModLogEntry({
+ type: options.duration ? ModLogType.TEMP_PUNISHMENT_ROLE : ModLogType.PERM_PUNISHMENT_ROLE,
+ guild: this.guild,
+ moderator: moderator.id,
+ user: this,
+ reason: 'N/A',
+ pseudo: !options.addToModlog
+ });
+
+ if (!modlog) return 'error creating modlog entry';
+ caseID = modlog.id;
if (options.addToModlog || options.duration) {
const punishmentEntrySuccess = await util.createPunishmentEntry({
type: 'role',
user: this,
guild: this.guild,
- modlog: modlog?.id ?? undefined,
+ modlog: modlog.id,
duration: options.duration,
extraInfo: options.role.id
});
diff --git a/src/lib/models/ActivePunishment.ts b/src/lib/models/ActivePunishment.ts
index 794560f..f453426 100644
--- a/src/lib/models/ActivePunishment.ts
+++ b/src/lib/models/ActivePunishment.ts
@@ -1,6 +1,6 @@
import { Snowflake } from 'discord.js';
+import { nanoid } from 'nanoid';
import { DataTypes, Sequelize } from 'sequelize';
-import { v4 as uuidv4 } from 'uuid';
import { BaseModel } from './BaseModel';
export enum ActivePunishmentType {
@@ -26,7 +26,7 @@ export interface ActivePunishmentModelCreationAttributes {
guild: Snowflake;
extraInfo?: Snowflake;
expires?: Date;
- modlog?: string;
+ modlog: string;
}
const NEVER_USED = 'This should never be executed';
@@ -112,7 +112,7 @@ export class ActivePunishment
type: DataTypes.STRING,
primaryKey: true,
allowNull: false,
- defaultValue: uuidv4
+ defaultValue: nanoid
},
type: {
type: DataTypes.STRING,
diff --git a/src/lib/models/ModLog.ts b/src/lib/models/ModLog.ts
index 5c87331..a70913d 100644
--- a/src/lib/models/ModLog.ts
+++ b/src/lib/models/ModLog.ts
@@ -1,6 +1,6 @@
import { Snowflake } from 'discord.js';
+import { nanoid } from 'nanoid';
import { DataTypes, Sequelize } from 'sequelize';
-import { v4 as uuidv4 } from 'uuid';
import { BaseModel } from './BaseModel';
import { jsonParseGet, jsonParseSet, NEVER_USED } from './__helpers';
@@ -155,7 +155,7 @@ export class ModLog extends BaseModel<ModLogModel, ModLogModelCreationAttributes
type: DataTypes.STRING,
primaryKey: true,
allowNull: false,
- defaultValue: uuidv4
+ defaultValue: nanoid
},
type: {
type: DataTypes.STRING, //# This is not an enum because of a sequelize issue: https://github.com/sequelize/sequelize/issues/2554
diff --git a/src/listeners/custom/bushPurge.ts b/src/listeners/custom/bushPurge.ts
index 240af96..22de99c 100644
--- a/src/listeners/custom/bushPurge.ts
+++ b/src/listeners/custom/bushPurge.ts
@@ -28,6 +28,7 @@ export default class BushPurgeListener extends BushListener {
.setColor(util.colors.discord.DARK_PURPLE)
.setTimestamp()
.setFooter(`${messages.size.toLocaleString()} Messages`)
+ .setAuthor(moderator.tag, moderator.avatarURL({ dynamic: true, format: 'png', size: 4096 }) ?? undefined)
.addField('**Action**', `${'Purge'}`)
.addField('**Moderator**', `${moderator} (${moderator.tag})`)
.addField('**Channel**', `<#${channel.id}> (${channel.name})`)
diff --git a/yarn.lock b/yarn.lock
index 9e6833c..a7cea8e 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -426,13 +426,6 @@ __metadata:
languageName: node
linkType: hard
-"@types/uuid@npm:^8.3.0":
- version: 8.3.1
- resolution: "@types/uuid@npm:8.3.1"
- checksum: b41bdc5e86c6f0f1899306be10455636da0f2168c9489b869edd6837ddeb7c0e501b1ff7d857402462986bada2a379125743dd895fa801d03437cd632116a373
- languageName: node
- linkType: hard
-
"@types/validator@npm:^13.6.3":
version: 13.6.3
resolution: "@types/validator@npm:13.6.3"
@@ -783,7 +776,6 @@ __metadata:
"@types/node-os-utils": ^1
"@types/numeral": ^2
"@types/tinycolor2": ^1
- "@types/uuid": ^8.3.0
"@types/validator": ^13.6.3
"@typescript-eslint/eslint-plugin": ^4.14.1
"@typescript-eslint/parser": ^4.14.1
@@ -807,6 +799,7 @@ __metadata:
mathjs: ^9.4.4
module-alias: ^2.2.2
moment: ^2.29.1
+ nanoid: ^3.1.25
node-fetch: ^2.6.1
node-os-utils: ^1.3.5
numeral: ^2.0.6
@@ -820,7 +813,6 @@ __metadata:
source-map-support: ^0.5.19
tinycolor2: ^1.4.2
typescript: ^4.4.2
- uuid: ^8.3.2
wolfram-alpha-api: "https://products.wolframalpha.com/api/libraries/javascript/wolfram-alpha-api-1.0.0-rc.1.tgz"
dependenciesMeta:
discord-akairo@8.2.2:
@@ -2288,6 +2280,15 @@ discord.js@NotEnoughUpdates/discord.js:
languageName: node
linkType: hard
+"nanoid@npm:^3.1.25":
+ version: 3.1.25
+ resolution: "nanoid@npm:3.1.25"
+ bin:
+ nanoid: bin/nanoid.cjs
+ checksum: e2353828c7d8fde65265e9c981380102e2021f292038a93fd27288bad390339833286e8cbc7531abe1cb2c6b317e55f38b895dcb775151637bb487388558e0ff
+ languageName: node
+ linkType: hard
+
"natural-compare@npm:^1.4.0":
version: 1.4.0
resolution: "natural-compare@npm:1.4.0"
@@ -3336,7 +3337,7 @@ typescript@^4.4.2:
languageName: node
linkType: hard
-"uuid@npm:^8.1.0, uuid@npm:^8.3.2":
+"uuid@npm:^8.1.0":
version: 8.3.2
resolution: "uuid@npm:8.3.2"
bin: