diff options
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | src/arguments/contentWithDuration.ts | 2 | ||||
-rw-r--r-- | src/commands/dev/superUser.ts | 5 | ||||
-rw-r--r-- | src/commands/utilities/activity.ts | 113 | ||||
-rw-r--r-- | src/commands/utilities/youtube.ts | 59 | ||||
-rw-r--r-- | src/listeners/message/automodCreate.ts | 6 |
6 files changed, 126 insertions, 61 deletions
@@ -54,3 +54,5 @@ data.db # IRONM00N's Crap src/config/options_old.ts src/config/options_pi.ts + +src/lib/badlinks-secret.json diff --git a/src/arguments/contentWithDuration.ts b/src/arguments/contentWithDuration.ts index 9753f50..99b251f 100644 --- a/src/arguments/contentWithDuration.ts +++ b/src/arguments/contentWithDuration.ts @@ -2,7 +2,7 @@ import { BushArgumentTypeCaster, BushMessage } from '@lib'; export const contentWithDurationTypeCaster: BushArgumentTypeCaster = async ( _message: BushMessage, - phrase + phrase: string ): Promise<{ duration: number; contentWithoutTime: string }> => { return client.util.parseDuration(phrase); }; diff --git a/src/commands/dev/superUser.ts b/src/commands/dev/superUser.ts index 22fa53f..5178684 100644 --- a/src/commands/dev/superUser.ts +++ b/src/commands/dev/superUser.ts @@ -44,6 +44,11 @@ export default class SuperUserCommand extends BushCommand { if (!message.author.isOwner()) return await message.util.reply(`${util.emojis.error} Only my developers can run this command.`); + if (!args.user?.id) + return await message.util.reply( + `${util.emojis.error} I fucked up here is args ${await util.inspectCleanRedactCodeblock(args, 'ts')}` + ); + const superUsers = (await Global.findByPk(client.config.environment)).superUsers; let success; if (args.action === 'add') { diff --git a/src/commands/utilities/activity.ts b/src/commands/utilities/activity.ts new file mode 100644 index 0000000..0962fff --- /dev/null +++ b/src/commands/utilities/activity.ts @@ -0,0 +1,113 @@ +import { VoiceChannel } from 'discord.js'; +import { BushCommand, BushMessage, BushSlashMessage } from '../../lib'; + +const activityMap = { + 'Poker Night': '755827207812677713', + 'Betrayal.io': '773336526917861400', + 'Fishington.io': '814288819477020702', + 'YouTube Together': '755600276941176913', + 'Chess in the Park': '832012774040141894' +}; + +function map(phase) { + if (['yt', 'youtube'].includes(phase)) return activityMap['YouTube Together']; + else if (['chess', 'park'].includes(phase)) return activityMap['Chess in the Park']; + else if (['poker'].includes(phase)) return activityMap['Poker Night']; + else if (['fish', 'fishing', 'fishington'].includes(phase)) return activityMap['Fishington.io']; + else if (['betrayal'].includes(phase)) return activityMap['Betrayal.io']; + else return undefined; +} + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +const activityTypeCaster = (_message: BushMessage, phrase: string) => { + if (!phrase) return null; + const mappedPhrase = map(phrase); + if (mappedPhrase) return mappedPhrase; + return null; +}; + +export default class YouTubeCommand extends BushCommand { + constructor() { + super('activity', { + aliases: ['activity', 'yt', 'youtube', 'chess', 'park', 'poker', 'fish', 'fishing', 'fishington', 'betrayal'], + category: 'utilities', + description: { + content: 'Allows you to play discord activities in voice channels.', + usage: [ + 'activity <channel> <`yt`|`youtube`|`chess`|`park`|`poker`|`fish`|`fishing`|`fishington`|`betrayal`>', + 'yt <channel>' // you do not need to specify the activity if you use its alias. + ], + examples: ['yt 785281831788216364', 'activity 785281831788216364 yt'] + }, + args: [ + { + id: 'channel', + type: 'voiceChannel', + prompt: { + start: 'What channel would you like to use?', + retry: '{error} Choose a valid voice channel' + } + }, + { + id: 'activity', + match: 'rest', + customType: activityTypeCaster + } + ], + slash: true, + slashOptions: [ + { + name: 'channel', + description: 'What channel would you like to use?', + type: 'CHANNEL', + required: true + }, + { + name: 'activity', + description: 'What activity would you like to play?', + type: 'STRING', + required: true, + choices: [ + { name: 'Poker Night', value: '755827207812677713' }, + { name: 'Betrayal.io', value: '773336526917861400' }, + { name: 'Fishington.io', value: '814288819477020702' }, + { name: 'YouTube Together', value: '755600276941176913' }, + { name: 'Chess in the Park', value: '832012774040141894' } + ] + } + ], + clientPermissions: ['SEND_MESSAGES'], + userPermissions: ['SEND_MESSAGES'] + }); + } + + public override async exec( + message: BushMessage | BushSlashMessage, + args: { channel: VoiceChannel; activity: string } + ): Promise<unknown> { + if (!args.channel?.id || args.channel?.type != 'GUILD_VOICE') + return await message.util.reply(`${util.emojis.error} Choose a valid voice channel`); + + let target_application_id: string; + if (message.util.isSlash) target_application_id = args.activity; + else target_application_id = target_application_id = args.activity; + + // @ts-ignore: jank typings + // prettier-ignore + const invite = await this.client.api.channels(args.channel.id) + .invites.post({ + data: { + validate: null, + max_age: 604800, + max_uses: 0, + target_type: 2, + target_application_id, + temporary: false + } + }) + .catch(() => false); + if (!invite || !invite.code) + return await message.util.reply(`${this.client.util.emojis.error} An error occurred while generating your invite.`); + else return await message.util.send(`https://discord.gg/${invite.code}`); + } +} diff --git a/src/commands/utilities/youtube.ts b/src/commands/utilities/youtube.ts deleted file mode 100644 index 0198173..0000000 --- a/src/commands/utilities/youtube.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { VoiceChannel } from 'discord.js'; -import { BushCommand, BushMessage, BushSlashMessage } from '../../lib'; - -export default class YouTubeCommand extends BushCommand { - constructor() { - super('youtube', { - aliases: ['youtube', 'yt'], - category: 'utilities', - description: { - content: "Allows the user to have access to discord's in-app YouTube experiment.", - usage: 'yt <channel>', - examples: ['yt 785281831788216364'] - }, - args: [ - { - id: 'channel', - type: 'voiceChannel', - prompt: { - start: 'What channel would you like to use?', - retry: '{error} Choose a valid voice channel' - } - } - ], - slash: true, - slashOptions: [ - { - name: 'channel', - description: 'What channel would you like to use?', - type: 'CHANNEL', - required: true - } - ], - clientPermissions: ['SEND_MESSAGES'], - userPermissions: ['SEND_MESSAGES'] - }); - } - - public override async exec(message: BushMessage | BushSlashMessage, args: { channel: VoiceChannel }): Promise<unknown> { - if (!args.channel?.id || args.channel?.type != 'GUILD_VOICE') - return await message.util.reply(`${util.emojis.error} Choose a valid voice channel`); - - // @ts-ignore: jank typings - // prettier-ignore - const invite = await this.client.api.channels(args.channel.id).invites.post({ - data: { - validate: null, - max_age: 604800, - max_uses: 0, - target_type: 2, - target_application_id: '755600276941176913', - temporary: false - } - }) - .catch(() => {}); - if (!invite || !invite.code) - return await message.util.reply(`${this.client.util.emojis.error} An error occurred while generating your invite.`); - else return await message.util.send(`https://discord.gg/${invite.code}`); - } -} diff --git a/src/listeners/message/automodCreate.ts b/src/listeners/message/automodCreate.ts index c69245a..b447ac8 100644 --- a/src/listeners/message/automodCreate.ts +++ b/src/listeners/message/automodCreate.ts @@ -1,5 +1,6 @@ import { BushListener, BushMessage } from '@lib'; import { MessageEmbed, TextChannel } from 'discord.js'; +import _badLinksSecret from '../../lib/badlinks-secret.json'; // shhhh import _badLinks from '../../lib/badlinks.json'; // Stolen from https://github.com/nacrt/SkyblockClient-REPO/blob/main/files/scamlinks.json import badWords from '../../lib/badwords.json'; import { BushClientEvents } from '../../lib/extensions/discord.js/BushClientEvents'; @@ -21,7 +22,10 @@ export default class AutomodMessageCreateListener extends BushListener { if (message.guild?.id !== client.consts.mappings.guilds.bush) return; // just temporary /* await message.guild.getSetting('autoModPhases'); */ const badLinks = {}; - _badLinks.forEach((link) => { + let temp = _badLinks; + if (_badLinksSecret) temp = temp.concat(_badLinksSecret); + + temp.forEach((link) => { badLinks[link] = 3; }); |