mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-05 22:01:54 +02:00
hex, base64, fix portal channels
This commit is contained in:
@@ -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.`);
|
||||
}
|
||||
};
|
||||
@@ -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)]);
|
||||
|
||||
@@ -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'));
|
||||
}
|
||||
};
|
||||
@@ -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'));
|
||||
}
|
||||
};
|
||||
@@ -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));
|
||||
}
|
||||
};
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "65.0.1",
|
||||
"version": "65.1.0",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user