diff --git a/commands/portal/fix-portal-channels.js b/commands/portal/fix-portal-channels.js new file mode 100644 index 00000000..d809cd36 --- /dev/null +++ b/commands/portal/fix-portal-channels.js @@ -0,0 +1,24 @@ +const { Command } = require('discord.js-commando'); + +module.exports = class FixPortalChannelsCommand extends Command { + constructor(client) { + super(client, { + name: 'fix-portal-channels', + group: 'portal', + memberName: 'fix-portal-channels', + description: 'Removes no longer existent channels from the portal list.', + ownerOnly: true + }); + } + + run(msg) { + const channels = this.client.provider.get('global', 'portals', []); + let count = 0; + for (const channel of channels) { + if (this.client.channels.has(channel)) continue; + channels.splice(channels.indexOf(channel), 1); + count++; + } + return msg.say(`Cleared **${count}** channels from the portal list.`); + } +}; diff --git a/commands/portal/portal-send.js b/commands/portal/portal-send.js index fea90504..af315ba8 100644 --- a/commands/portal/portal-send.js +++ b/commands/portal/portal-send.js @@ -21,7 +21,7 @@ module.exports = class PortalSendCommand extends Command { async run(msg, { message }) { if (/discord(\.gg|app\.com\/invite|\.me)\//gi.test(message)) return msg.reply('Please do not send invites.'); - let channels = this.client.provider.get('global', 'portals', []); + let channels = this.client.provider.get('global', 'portals', []).filter(c => this.client.channels.has(c)); if (msg.channel.type === 'text') channels = channels.filter(channel => !msg.guild.channels.has(channel)); if (!channels.length) return msg.reply('No channels have an open portal...'); const channel = this.client.channels.get(channels[Math.floor(Math.random() * channels.length)]); diff --git a/commands/text-edit/base64.js b/commands/text-edit/base64.js new file mode 100644 index 00000000..c47eac37 --- /dev/null +++ b/commands/text-edit/base64.js @@ -0,0 +1,28 @@ +const { Command } = require('discord.js-commando'); + +module.exports = class Base64Command extends Command { + constructor(client) { + super(client, { + name: 'base64', + aliases: ['base-64'], + group: 'text-edit', + memberName: 'base64', + description: 'Converts text to Base64.', + args: [ + { + key: 'text', + prompt: 'What text would you like to convert to Base64?', + type: 'string', + validate: text => { + if (Buffer.from(text).toString('base64').length < 2000) return true; + return 'Invalid text, your text is too long.'; + } + } + ] + }); + } + + run(msg, { text }) { + return msg.say(Buffer.from(text).toString('base64')); + } +}; diff --git a/commands/text-edit/hex.js b/commands/text-edit/hex.js new file mode 100644 index 00000000..03bd3297 --- /dev/null +++ b/commands/text-edit/hex.js @@ -0,0 +1,28 @@ +const { Command } = require('discord.js-commando'); + +module.exports = class HexCommand extends Command { + constructor(client) { + super(client, { + name: 'hex', + aliases: ['hexidecimal'], + group: 'text-edit', + memberName: 'hex', + description: 'Converts text to hex.', + args: [ + { + key: 'text', + prompt: 'What text would you like to convert to hex?', + type: 'string', + validate: text => { + if (Buffer.from(text).toString('hex').length < 2000) return true; + return 'Invalid text, your text is too long.'; + } + } + ] + }); + } + + run(msg, { text }) { + return msg.say(Buffer.from(text).toString('hex')); + } +}; diff --git a/commands/text-edit/url-encode.js b/commands/text-edit/url-encode.js new file mode 100644 index 00000000..a76e28d1 --- /dev/null +++ b/commands/text-edit/url-encode.js @@ -0,0 +1,28 @@ +const { Command } = require('discord.js-commando'); + +module.exports = class URLEncodeCommand extends Command { + constructor(client) { + super(client, { + name: 'url-encode', + aliases: ['encode-url', 'encode-uri', 'uri-encode', 'encode-uri-component'], + group: 'text-edit', + memberName: 'url-encode', + description: 'Encodes text to URL-friendly characters.', + args: [ + { + key: 'text', + prompt: 'What text would you like to encode?', + type: 'string', + validate: text => { + if (encodeURIComponent(text).length < 2000) return true; + return 'Invalid text, your text is too long.'; + } + } + ] + }); + } + + run(msg, { text }) { + return msg.say(encodeURIComponent(text)); + } +}; diff --git a/package.json b/package.json index ef12d262..9c7062e9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "65.0.1", + "version": "65.1.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {