diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/common/ButtonPaginator.ts | 3 | ||||
-rw-r--r-- | src/lib/extensions/discord-akairo/BushClientUtil.ts | 18 | ||||
-rw-r--r-- | src/lib/extensions/discord.js/BushGuild.ts | 2 | ||||
-rw-r--r-- | src/lib/utils/BushConstants.ts | 84 |
4 files changed, 75 insertions, 32 deletions
diff --git a/src/lib/common/ButtonPaginator.ts b/src/lib/common/ButtonPaginator.ts index 0c18119..0399e74 100644 --- a/src/lib/common/ButtonPaginator.ts +++ b/src/lib/common/ButtonPaginator.ts @@ -53,8 +53,7 @@ export class ButtonPaginator { ) { this.message = message; this.embeds = embeds; - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - this.text = text || null; + this.text = text ? text : null; this.deleteOnExit = deleteOnExit; this.curPage = startOn - 1; diff --git a/src/lib/extensions/discord-akairo/BushClientUtil.ts b/src/lib/extensions/discord-akairo/BushClientUtil.ts index 968a805..e3c0803 100644 --- a/src/lib/extensions/discord-akairo/BushClientUtil.ts +++ b/src/lib/extensions/discord-akairo/BushClientUtil.ts @@ -793,8 +793,9 @@ export class BushClientUtil extends ClientUtil { public clientSendAndPermCheck(message: BushMessage | BushSlashMessage, permissions: bigint[] = [], checkChannel = false) { const missing = []; const sendPerm = message.channel!.isThread() ? Permissions.FLAGS.SEND_MESSAGES : Permissions.FLAGS.SEND_MESSAGES_IN_THREADS; + if (!message.inGuild()) return null; - if (!message.guild!.me!.permissionsIn(message.channel!.id!).has(sendPerm)) missing.push(sendPerm); + if (!message.guild.me!.permissionsIn(message.channel.id).has(sendPerm)) missing.push(sendPerm); missing.push( ...(checkChannel @@ -867,15 +868,14 @@ export class BushClientUtil extends ClientUtil { return deepLock; } - public get time(): Record<keyof typeof client.constants.timeUnits, number> { - const values = Object.entries(client.constants.timeUnits).map(([key, value]) => [key, value.value]); - return Object.fromEntries(values); - } - + /** + * The link to invite the bot with all permissions. + */ public get invite() { - return `https://discord.com/api/oauth2/authorize?client_id=${client.user!.id}&permissions=${ - Permissions.ALL - }&scope=bot%20applications.commands`; + return `https://discord.com/api/oauth2/authorize?client_id=${Buffer.from( + client.token!.split('.')[0], + 'base64' + ).toString()}&permissions=${Permissions.ALL}&scope=bot%20applications.commands`; } /** diff --git a/src/lib/extensions/discord.js/BushGuild.ts b/src/lib/extensions/discord.js/BushGuild.ts index bbef953..b546dab 100644 --- a/src/lib/extensions/discord.js/BushGuild.ts +++ b/src/lib/extensions/discord.js/BushGuild.ts @@ -370,7 +370,7 @@ export class BushGuild extends Guild { author: { name: moderator.user.tag, icon_url: moderator.displayAvatarURL() }, title: `This channel has been ${options.unlock ? 'un' : ''}locked`, description: options.reason ?? 'No reason provided', - color: options.unlock ? util.colors.discord.GREEN : util.colors.discord.RED, + color: options.unlock ? util.colors.GREEN : util.colors.RED, timestamp: new Date().toISOString() } ] diff --git a/src/lib/utils/BushConstants.ts b/src/lib/utils/BushConstants.ts index 4e73672..e7b69ae 100644 --- a/src/lib/utils/BushConstants.ts +++ b/src/lib/utils/BushConstants.ts @@ -2,8 +2,51 @@ import { Constants } from 'discord.js'; import { BushClientUtil } from '../extensions/discord-akairo/BushClientUtil.js'; const rawCapeUrl = 'https://raw.githubusercontent.com/NotEnoughUpdates/capes/master/'; + +export const enum Time { + /** + * One millisecond (1 ms). + */ + Millisecond = 1, + + /** + * One second (1,000 ms). + */ + Second = Millisecond * 1000, + + /** + * One minute (60,000 ms). + */ + Minute = Second * 60, + + /** + * One hour (3,600,000 ms). + */ + Hour = Minute * 60, + + /** + * One day (86,400,000 ms). + */ + Day = Hour * 24, + + /** + * One week (604,800,000 ms). + */ + Week = Day * 7, + + /** + * One month (2,629,800,000 ms). + */ + Month = Day * 30.4375, // average of days in a month (including leap years) + + /** + * One year (31,557,600,000 ms). + */ + Year = Day * 365.25 // average with leap years +} + export class BushConstants { - public static emojis = BushClientUtil.deepFreeze({ + public static emojis = Object.freeze({ success: '<:success:837109864101707807>', warn: '<:warn:848726900876247050>', error: '<:error:837123021016924261>', @@ -22,7 +65,7 @@ export class BushConstants { check: '<:check:878320135297961995>' } as const); - public static colors = BushClientUtil.deepFreeze({ + public static colors = Object.freeze({ default: 0x1fd8f1, error: 0xef4947, warn: 0xfeba12, @@ -45,42 +88,42 @@ export class BushConstants { darkGray: 0x7a7a7a, black: 0x000000, orange: 0xe86100, - discord: Object.assign({}, Constants.Colors) + ...Constants.Colors } as const); // Somewhat stolen from @Mzato0001 public static timeUnits = BushClientUtil.deepFreeze({ milliseconds: { match: / (?:(?<milliseconds>-?(?:\d+)?\.?\d+) *(?:milliseconds?|msecs?|ms))/im, - value: 1 + value: Time.Millisecond }, seconds: { match: / (?:(?<seconds>-?(?:\d+)?\.?\d+) *(?:seconds?|secs?|s))/im, - value: 1000 + value: Time.Second }, minutes: { - match: / (?:(?<minutes>-?(?:\d+)?\.?\d+) *(?:minutes?|mins?))/im, - value: 1000 * 60 + match: / (?:(?<minutes>-?(?:\d+)?\.?\d+) *(?:minutes?|mins?|m))/im, + value: Time.Minute }, hours: { match: / (?:(?<hours>-?(?:\d+)?\.?\d+) *(?:hours?|hrs?|h))/im, - value: 1000 * 60 * 60 + value: Time.Hour }, days: { match: / (?:(?<days>-?(?:\d+)?\.?\d+) *(?:days?|d))/im, - value: 1000 * 60 * 60 * 24 + value: Time.Day }, weeks: { match: / (?:(?<weeks>-?(?:\d+)?\.?\d+) *(?:weeks?|w))/im, - value: 1000 * 60 * 60 * 24 * 7 + value: Time.Week }, months: { - match: / (?:(?<months>-?(?:\d+)?\.?\d+) *(?:months?|mon|mo?))/im, - value: 1000 * 60 * 60 * 24 * 30.4375 // average of days in months including leap years + match: / (?:(?<months>-?(?:\d+)?\.?\d+) *(?:months?|mon|mo))/im, + value: Time.Month }, years: { match: / (?:(?<years>-?(?:\d+)?\.?\d+) *(?:years?|y))/im, - value: 1000 * 60 * 60 * 24 * 365.25 //leap years + value: Time.Year } } as const); @@ -93,7 +136,7 @@ export class BushConstants { /(?:ptb\.|canary\.|staging\.|lc\.)?(?:discord(?:app)?|inv)\.(?:com|wtf)?\/channels\/(?<guild_id>\d{15,21}|@me)\/(?<channel_id>\d{15,21})\/(?<message_id>\d{15,21})/im } as const); - public static pronounMapping = BushClientUtil.deepFreeze({ + public static pronounMapping = Object.freeze({ unspecified: 'Unspecified', hh: 'He/Him', hi: 'He/It', @@ -318,6 +361,7 @@ export class BushConstants { { name: 'secondpfirsisch' }, { name: 'stormy_lh' } ].map((value, index) => ({ ...value, index })), + roleMap: [ { name: '*', id: '792453550768390194' }, { name: 'Admin Perms', id: '746541309853958186' }, @@ -343,9 +387,9 @@ export class BushConstants { { name: 'No Bots', id: '786804858765312030' }, { name: 'No VC', id: '788850482554208267' }, { name: 'No Giveaways', id: '808265422334984203' }, - { name: 'No Support', id: '790247359824396319' }, - { name: 'DJ', id: '782619038403919902' } + { name: 'No Support', id: '790247359824396319' } ], + roleWhitelist: { 'Partner': ['*', 'Admin Perms', 'Sr. Moderator', 'Moderator'], 'Suggester': ['*', 'Admin Perms', 'Sr. Moderator', 'Moderator', 'Helper', 'Trial Helper', 'Contributor'], @@ -368,7 +412,7 @@ export class BushConstants { } } as const); - public static ArgumentMatches = BushClientUtil.deepFreeze({ + public static ArgumentMatches = Object.freeze({ PHRASE: 'phrase', FLAG: 'flag', OPTION: 'option', @@ -380,7 +424,7 @@ export class BushConstants { NONE: 'none' } as const); - public static ArgumentTypes = BushClientUtil.deepFreeze({ + public static ArgumentTypes = Object.freeze({ STRING: 'string', LOWERCASE: 'lowercase', UPPERCASE: 'uppercase', @@ -445,7 +489,7 @@ export class BushConstants { GLOBAL_USER: 'globalUser' } as const); - public static BlockedReasons = BushClientUtil.deepFreeze({ + public static BlockedReasons = Object.freeze({ CLIENT: 'client', BOT: 'bot', OWNER: 'owner', @@ -465,7 +509,7 @@ export class BushConstants { RESTRICTED_CHANNEL: 'restrictedChannel' } as const); - public static CommandHandlerEvents = BushClientUtil.deepFreeze({ + public static CommandHandlerEvents = Object.freeze({ COMMAND_BLOCKED: 'commandBlocked', COMMAND_BREAKOUT: 'commandBreakout', COMMAND_CANCELLED: 'commandCancelled', |