From bb511abc03bb66848947e37a999502b813c77269 Mon Sep 17 00:00:00 2001 From: 8cy <50817549+8cy@users.noreply.github.com> Date: Thu, 23 Jul 2020 23:24:17 -0700 Subject: goodbye old uwufier :cry: --- server/src/commands/owner/DM.ts | 90 ++++++++++++++++++++++++++++++++ server/src/commands/owner/IP.ts | 27 ++++++++++ server/src/commands/owner/Reload.ts | 40 ++++++++++++++ server/src/commands/owner/ServerCount.ts | 24 +++++++++ server/src/commands/owner/Status.ts | 35 +++++++++++++ server/src/commands/owner/Username.ts | 35 +++++++++++++ 6 files changed, 251 insertions(+) create mode 100644 server/src/commands/owner/DM.ts create mode 100644 server/src/commands/owner/IP.ts create mode 100644 server/src/commands/owner/Reload.ts create mode 100644 server/src/commands/owner/ServerCount.ts create mode 100644 server/src/commands/owner/Status.ts create mode 100644 server/src/commands/owner/Username.ts (limited to 'server/src/commands/owner') diff --git a/server/src/commands/owner/DM.ts b/server/src/commands/owner/DM.ts new file mode 100644 index 0000000..e0e793a --- /dev/null +++ b/server/src/commands/owner/DM.ts @@ -0,0 +1,90 @@ +import { Command } from 'discord-akairo'; +import { Message } from 'discord.js'; +import { colour } from '../../Config'; + +export default class DMOwner extends Command { + public constructor() { + super('dm', { + aliases: ['dm', 'pm'], + category: 'owner', + description: { + content: 'DM a specified user.', + usage: '[user id] [message]', + examples: [ + '217348698294714370 hi' + ] + }, + ratelimit: 3, + args: [ + { + id: 'user', + type: 'string' + }, + { + id: 'type', + type: 'string', + prompt: { + start: 'What type of DM would you like to send the specified user?', + retry: 'That is not a valid DM type!' + } + }, + { + id: 'text', + type: 'string', + prompt: { + start: 'What would you like to send to the specified user?' + }, + match: 'rest' + } + ], + ownerOnly: true + }); + } + + public exec(msg: Message, { user, type, text }): Promise { + if (type == 'embed') { + function uuidv4() { + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => { + let r = Math.random() * 16 | 0, v = c == 'x' ? r : (4 & 0x3 | 0x8); + return v.toString(16); + }); + } + + const uuid = uuidv4(); + + user = this.client.users.resolve(user); + if (!user) return msg.channel.send('An incorrect user ID was provided.'); + + const embed = this.client.util.embed() + .setTitle('You received a message from the developer!') + .setColor(colour) + .setDescription(text) + .setFooter(`If you wish to respond, use the following command: ${this.client.commandHandler.prefix}feedback --reply ${uuid} `) + .setTimestamp(); + + let attachment = (msg.attachments).array(); + if (attachment[0]) { + this.client.users.resolve(user).send(embed, { files: [attachment[0].url] }) + .then(() => { return msg.channel.send(`A DM has successfully been sent to ${user.username}.`)}) + .catch(() => { return msg.channel.send(`Could not send a DM to ${user.username}.`)}); + } else { + this.client.users.resolve(user).send(embed) + .then(() => { return msg.channel.send(`A DM has successfully been sent to ${user.tag}.`)}) + .catch(() => { return msg.channel.send(`Could not send a DM to ${user.tag}.`)}); + } + } else if (type === 'normal') { + let attachment = (msg.attachments).array(); + if (attachment[0]) { + this.client.users.resolve(user).send(text, { files: [attachment[0].url] }) + .then(() => { return msg.channel.send(`A DM has successfully been sent to ${user.username}.`)}) + .catch(() => { return msg.channel.send(`Could not send a DM to ${user.username}.`)}); + } else { + this.client.users.resolve(user).send(text) + .then(() => { return msg.channel.send(`A DM has successfully been sent to ${user.tag}.`)}) + .catch(() => { return msg.channel.send(`Could not send a DM to ${user.tag}.`)}); + } + } + + return; + } +} \ No newline at end of file diff --git a/server/src/commands/owner/IP.ts b/server/src/commands/owner/IP.ts new file mode 100644 index 0000000..244c11f --- /dev/null +++ b/server/src/commands/owner/IP.ts @@ -0,0 +1,27 @@ +import { Command } from 'discord-akairo'; +import { Message } from 'discord.js'; +import request from 'node-superfetch'; + +export default class IPOwner extends Command { + public constructor() { + super('ip', { + aliases: ['ip'], + category: 'owner', + description: { + content: 'Gives you the bot\'s IP address.', + usage: '', + examples: [ + '' + ] + }, + ratelimit: 3, + ownerOnly: true + }); + } + + public async exec(msg: Message): Promise { + let { body } = await request.get('https://api.ipify.org').query({ format: 'json' }); + //@ts-ignore + return msg.reply(`${this.client.user.username}'s IP address is **${body.ip}**. *Which script kiddie in chat asked you to send this zzz. -Sin*`); + } +} \ No newline at end of file diff --git a/server/src/commands/owner/Reload.ts b/server/src/commands/owner/Reload.ts new file mode 100644 index 0000000..ac7bd1f --- /dev/null +++ b/server/src/commands/owner/Reload.ts @@ -0,0 +1,40 @@ +import { Command } from 'discord-akairo'; +import { Message } from 'discord.js'; + +export default class ReloadOwner extends Command { + public constructor() { + super('reload', { + aliases: ['reload', 'reboot', 'reloadlistener'], + category: 'owner', + description: { + content: 'Reload a command.', + usage: '[command]', + examples: [ + 'ping' + ] + }, + ratelimit: 3, + args: [ + { + id: 'command', + type: 'string', + prompt: { + start: 'What command would you like to reload?', + }, + match: 'rest' + } + ], + ownerOnly: true + }); + } + + public exec(msg: Message, { command }): Promise { + if (msg.util.parsed.alias == 'reloadlistener') { + this.client.listenerHandler.reload(command); + return msg.channel.send(`Successfully reloaded the listener ${command}`); + } else { + this.handler.reload(command); + return msg.channel.send(`Successfully reloaded the command ${command}`); + } + } +} \ No newline at end of file diff --git a/server/src/commands/owner/ServerCount.ts b/server/src/commands/owner/ServerCount.ts new file mode 100644 index 0000000..5068c22 --- /dev/null +++ b/server/src/commands/owner/ServerCount.ts @@ -0,0 +1,24 @@ +import { Command } from 'discord-akairo'; +import { Message } from 'discord.js'; + +export default class ServerCountOwner extends Command { + public constructor() { + super('servercount', { + aliases: ['servercount', 'server-count'], + category: 'owner', + description: { + content: 'Check the amount of servers the bot is in.', + usage: '', + examples: [ + '' + ] + }, + ratelimit: 3, + ownerOnly: true + }); + } + + public exec(msg: Message): Promise { + return msg.channel.send(`${this.client.user.username} is currently in **${this.client.guilds.cache.size}** server(s).`); + } +} \ No newline at end of file diff --git a/server/src/commands/owner/Status.ts b/server/src/commands/owner/Status.ts new file mode 100644 index 0000000..8bf8dad --- /dev/null +++ b/server/src/commands/owner/Status.ts @@ -0,0 +1,35 @@ +import { Command } from 'discord-akairo'; +import { Message } from 'discord.js'; + +export default class StatusOwner extends Command { + public constructor() { + super('status', { + aliases: ['status'], + category: 'owner', + description: { + content: 'Change the status of the bot.', + usage: '[status message]', + examples: [ + 'hello, world!' + ] + }, + ratelimit: 3, + args: [ + { + id: 'status', + type: 'string', + prompt: { + start: 'Which status would you like to give me?', + }, + match: 'rest' + } + ], + ownerOnly: true + }); + } + + public exec(msg: Message, { status }): Promise { + this.client.user.setActivity(status); + return msg.channel.send(`My status has not been set to ${status}!`); + } +} \ No newline at end of file diff --git a/server/src/commands/owner/Username.ts b/server/src/commands/owner/Username.ts new file mode 100644 index 0000000..df6d6c4 --- /dev/null +++ b/server/src/commands/owner/Username.ts @@ -0,0 +1,35 @@ +import { Command } from 'discord-akairo'; +import { Message } from 'discord.js'; + +export default class UsernameOwner extends Command { + public constructor() { + super('username', { + aliases: ['username'], + category: 'owner', + description: { + content: 'Change the username of the bot.', + usage: '[username]', + examples: [ + 'Aki' + ] + }, + ratelimit: 3, + args: [ + { + id: 'username', + type: 'string', + prompt: { + start: 'What username would you like to give me?', + }, + match: 'rest' + } + ], + ownerOnly: true + }); + } + + public exec(msg: Message, { username }): Promise { + this.client.user.setUsername(username); + return msg.channel.send(`My username has now been set to ${username}!`) + } +} \ No newline at end of file -- cgit v1.2.3