aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-09-05 21:45:29 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-09-05 21:45:29 -0400
commite3c116e0f4b741032fe777936fdf5d80f0b011e6 (patch)
tree024bd9884f1456983faae2b62b59485a879ac934 /src/lib
parentc8a5bfe694ee6e784a0c5cbe1a7076b1c055249a (diff)
downloadtanzanite-e3c116e0f4b741032fe777936fdf5d80f0b011e6.tar.gz
tanzanite-e3c116e0f4b741032fe777936fdf5d80f0b011e6.tar.bz2
tanzanite-e3c116e0f4b741032fe777936fdf5d80f0b011e6.zip
modlogid uuid -> nanoid
Diffstat (limited to 'src/lib')
-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
4 files changed, 21 insertions, 20 deletions
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