diff --git a/server/bot/commands/utilities.ts b/server/bot/commands/utilities.ts index 5781688..4108339 100644 --- a/server/bot/commands/utilities.ts +++ b/server/bot/commands/utilities.ts @@ -1,10 +1,13 @@ // All the types! +import { Message } from 'eris' // eslint-disable-line no-unused-vars import { IveBotCommand } from '../imports/types' // All the needs! +import { getIdFromMention, getDesc } from '../imports/tools' +import * as ms from 'ms' import 'json5/lib/require' import { host, testPilots } from '../../../config.json5' -export const handleRequest: IveBotCommand = { +export const handleRequest: IveBotCommand = (client, db) => ({ name: 'request', opts: { aliases: ['req'], @@ -13,7 +16,7 @@ export const handleRequest: IveBotCommand = { fullDescription: 'Request a feature. Only available to test pilots.', usage: '/request ' }, - generator: (client) => ({ author, content, channel }, args) => { + generator: ({ author, content, channel }, args) => { client.getDMChannel(host).then((PrivateChannel) => { client.createMessage( PrivateChannel.id, @@ -25,4 +28,69 @@ and will be read shortly. You may recieve a response soon, and you can keep track here: ` } -} +}) + +export const handleSay: IveBotCommand = (client, db) => ({ + opts: { + requirements: { userIDs: [...testPilots, host], permissions: { manageMessages: true } }, + permissionMessage: 'You cannot fool me. You do not have enough permissions.', + description: 'Say something, even in another channel.', + fullDescription: 'Say something. Test pilots and admins/mods only.', + usage: '/say (channel) ', + deleteCommand: true, + errorMessage: 'There was an error processing your request.' + }, + name: 'say', + generator: (message, args) => { + // Should it be sent in another channel? + const possibleChannel = getIdFromMention(args[0]) + if (message.channelMentions[0] === possibleChannel) { + args.shift() + client.createMessage(message.channelMentions[0], args.join(' ')).then((newMessage) => { + db.say[message.channelMentions[0]] = newMessage.id + }).catch((err) => console.error(err)) + return + } + // Send the message. + client.createMessage(message.channel.id, args.join(' ')).then((newMessage) => { + db.say[message.channelMentions[0]] = newMessage.id + }).catch((err) => console.error(err)) + } +}) + +export const handleRemindme: IveBotCommand = (client) => ({ + opts: { + fullDescription: 'Remind you of something.', + description: 'Reminders.', + usage: '/remindme