mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 15:07:42 +02:00
Change in the way choice commands work
This commit is contained in:
+20
-14
@@ -10,9 +10,9 @@ module.exports = class MemeCommand extends Command {
|
||||
],
|
||||
group: 'imageedit',
|
||||
memberName: 'meme',
|
||||
description: 'Sends a Meme with text of your choice, and a background of your choice. Split first and second lines with a | (;meme facepalm I can\'t even | comprehend this)',
|
||||
description: 'Sends a Meme with text of your choice, and a background of your choice. (;meme facepalm "I can\'t even" "comprehend this")',
|
||||
details: '**Codes:** tenguy, afraid, older, aag, tried, biw, blb, kermit, bd, ch, cbg, wonka, cb, keanu, dsm, live, ants, doge, alwaysonbeat, ermg, facepalm, fwp, fa, fbf, fry, hipster, icanhas, crazypills, mw, noidea, regret, boat, hagrid, sohappy, captain, inigo, iw, ackbar, happening, joker, ive, ll, morpheus, mb, badchoice, mmm, jetpack, red, mordor, oprah, oag, remembers, philosoraptor, jw, patrick, rollsafe, sad-obama, sad-clinton, sadfrog, sad-bush, sad-biden, sad-boehner, saltbae, sarcasticbear, dwight, sb, ss, sf, dodgson, money, sohot, nice, awesome-awkward, awesome, awkward-awesome, awkward, fetch, success, scc, ski, officespace, interesting, toohigh, bs, center, both, winter, xy, buzz, yodawg, uno, yallgot, bad, elf, chosen',
|
||||
examples: [';meme facepalm I can\'t even | comprehend this'],
|
||||
examples: [';meme facepalm "I can\'t even" "comprehend this"'],
|
||||
args: [{
|
||||
key: 'type',
|
||||
prompt: 'What meme type do you want to use?',
|
||||
@@ -24,14 +24,24 @@ module.exports = class MemeCommand extends Command {
|
||||
return 'Please enter a valid meme type. Use `;help meme` to view a list of types.';
|
||||
}
|
||||
}, {
|
||||
key: 'content',
|
||||
prompt: 'What should the meme content be? Split the bottom and top text of the meme with " | ".',
|
||||
key: 'toprow',
|
||||
prompt: 'What should the top row of the meme to be? Surround in "" for multiple words.',
|
||||
type: 'string',
|
||||
validate: content => {
|
||||
if (content.includes(' | ') && content.match(/^[a-zA-Z0-9|.,!?'-\s]+$/)) {
|
||||
validate: toprow => {
|
||||
if (toprow.match(/^[a-zA-Z0-9|.,!?'-\s]+$/) && toprow.length < 101) {
|
||||
return true;
|
||||
}
|
||||
return 'Please split your choices with ' | ' and do not use special characters.';
|
||||
return 'Please do not use special characters and keep the rows under 100 characters each.';
|
||||
}
|
||||
}, {
|
||||
key: 'bottomrow',
|
||||
prompt: 'What should the bottom row of the meme to be? Surround in "" for multiple words.',
|
||||
type: 'string',
|
||||
validate: bottomrow => {
|
||||
if (bottomrow.match(/^[a-zA-Z0-9|.,!?'-\s]+$/) && bottomrow.length < 101) {
|
||||
return true;
|
||||
}
|
||||
return 'Please do not use special characters and keep the rows under 100 characters each.';
|
||||
}
|
||||
}]
|
||||
});
|
||||
@@ -43,13 +53,9 @@ module.exports = class MemeCommand extends Command {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission('ATTACH_FILES')) return message.say(':x: Error! I don\'t have the Attach Files Permission!');
|
||||
}
|
||||
const type = args.type.toLowerCase();
|
||||
const content = args.content;
|
||||
const memeQuery = content.split(' ').join('-').split('-|-');
|
||||
const toprow = memeQuery[0].split('?').join('~q');
|
||||
const bottomrow = memeQuery[1].split('?').join('~q');
|
||||
const toprow = args.toprow.split(' ').join('-').split('?').join('~q');
|
||||
const bottomrow = args.bottomrow.split(' ').join('-').split('?').join('~q');
|
||||
const link = `https://memegen.link/${type}/${toprow}/${bottomrow}.jpg`;
|
||||
if (bottomrow.length > 100) return message.say(':x: Error! Bottom text is over 100 characters!');
|
||||
if (toprow.length > 100) return message.say(':x: Error! Top text is over 100 characters!');
|
||||
return message.channel.sendFile(link).catch(err => message.say(':x: Error! Something went wrong!'));
|
||||
return message.channel.sendFile(link).catch(() => message.say(':x: Error! Something went wrong!'));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -11,8 +11,8 @@ module.exports = class StrawpollCommand extends Command {
|
||||
],
|
||||
group: 'random',
|
||||
memberName: 'strawpoll',
|
||||
description: 'Creates a Strawpoll with your options. (;strawpoll "Who likes chips?" Me | Not Me)',
|
||||
examples: [';strawpoll "Who likes chips?" Me | Not Me'],
|
||||
description: 'Creates a Strawpoll with your options. (;strawpoll "Who likes chips?" "Me" "Not Me")',
|
||||
examples: [';strawpoll "Who likes chips?" "Me" "Not Me"'],
|
||||
args: [{
|
||||
key: 'title',
|
||||
prompt: 'What would you like the title of the Strawpoll to be? Surround in "" for multiple words.',
|
||||
@@ -25,17 +25,9 @@ module.exports = class StrawpollCommand extends Command {
|
||||
}
|
||||
}, {
|
||||
key: 'choices',
|
||||
prompt: 'What choices do you want me pick from? Split them with " | ".',
|
||||
prompt: 'What choices do you want me pick from? Surround each choice in "".',
|
||||
type: 'string',
|
||||
validate: content => {
|
||||
if (content.includes(' | ')) {
|
||||
return true;
|
||||
}
|
||||
if (content.length > 160) {
|
||||
return 'Please limit your options to 160 characters.';
|
||||
}
|
||||
return 'Please split your choices with ' | '.';
|
||||
}
|
||||
infinite: true
|
||||
}]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -9,18 +9,13 @@ module.exports = class ChooseCommand extends Command {
|
||||
],
|
||||
group: 'response',
|
||||
memberName: 'choose',
|
||||
description: 'Chooses between things. (;choose Cow | Sheep)',
|
||||
examples: [';choose Cow | Sheep', ';choose Bark | Woof | Meow | Moo'],
|
||||
description: 'Chooses between things. (;choose "Cow" "Sheep")',
|
||||
examples: [';choose "Cow" "Sheep"', ';choose "Bark" "Woof" "Meow" "Moo"'],
|
||||
args: [{
|
||||
key: 'choices',
|
||||
prompt: 'What choices do you want me pick from? Split them with " | ".',
|
||||
prompt: 'What choices do you want me pick from? Surround each choice in "".',
|
||||
type: 'string',
|
||||
validate: content => {
|
||||
if (content.includes(' | ')) {
|
||||
return true;
|
||||
}
|
||||
return 'Please split your choices with ' | '.';
|
||||
}
|
||||
infinite: true
|
||||
}]
|
||||
});
|
||||
}
|
||||
@@ -30,7 +25,6 @@ module.exports = class ChooseCommand extends Command {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
}
|
||||
let choices = args.choices;
|
||||
choices = choices.split(' | ');
|
||||
choices = choices[Math.floor(Math.random() * choices.length)];
|
||||
return message.say(`I choose ${choices}!`);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,8 @@ client.registry
|
||||
])
|
||||
.registerDefaultGroups()
|
||||
.registerDefaultCommands({
|
||||
prefix: false
|
||||
prefix: false,
|
||||
commandState: false
|
||||
})
|
||||
.registerCommandsIn(path.join(__dirname, 'commands'));
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiaobot",
|
||||
"version": "22.1.0",
|
||||
"version": "22.2.0",
|
||||
"description": "A Discord Bot",
|
||||
"main": "shardingmanager.js",
|
||||
"repository": {
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
const { ArgumentType } = require('discord.js-commando');
|
||||
const emojiRanges = [
|
||||
'[\u0023-\u0039]\u20E3',
|
||||
'[\u2002-\u21AA]',
|
||||
'[\u231A-\u27bf]',
|
||||
'[\u2934-\u2b55]',
|
||||
'\u3030', '\u303D',
|
||||
'\u3297', '\u3299',
|
||||
'\uD83C[\udc04-\uDFFF]',
|
||||
'\uD83D[\uDC00-\uDE4F]'
|
||||
];
|
||||
const emojiRegex = new RegExp(emojiRanges.join('|'), 'g');
|
||||
const regex = /<:([a-zA-Z0-9_]+):(\d+)>/;
|
||||
|
||||
class EmojiArgumentType extends ArgumentType {
|
||||
constructor(client) {
|
||||
super(client, 'emoji');
|
||||
}
|
||||
|
||||
validate(value, msg) {
|
||||
if (value.match(regex)) {
|
||||
const emoji = msg.client.emojis.get(value.match(regex)[2]);
|
||||
if (emoji) return true;
|
||||
} else if (value.match(emojiRegex)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
parse(value, msg) { // eslint-disable-line consistent-return
|
||||
if (value.match(regex)) {
|
||||
const emoji = msg.client.emojis.get(value.match(regex)[2]);
|
||||
if (emoji) return emoji;
|
||||
} else if (value.match(emojiRegex)) {
|
||||
return value.match(emojiRegex)[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = EmojiArgumentType;
|
||||
Reference in New Issue
Block a user