mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-05 13:53:12 +02:00
stripIndents
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { RichEmbed } = require('discord.js');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const math = require('mathjs');
|
||||
const operations = ['+', '-', '*'];
|
||||
|
||||
@@ -63,16 +64,16 @@ module.exports = class MathGameCommand extends Command {
|
||||
errors: ['time']
|
||||
});
|
||||
if (collected.first().content !== solved)
|
||||
return msg.say(
|
||||
`Aw... Too bad, try again next time!
|
||||
The correct answer is: ${solved}`
|
||||
);
|
||||
return msg.say(stripIndents`
|
||||
Aw... Too bad, try again next time!
|
||||
The correct answer is: ${solved}
|
||||
`);
|
||||
return msg.say(`Good Job! You won! ${solved} is the correct answer!`);
|
||||
} catch (err) {
|
||||
return msg.say(
|
||||
`Aw... Too bad, try again next time!
|
||||
The correct answer is: ${solved}`
|
||||
);
|
||||
return msg.say(stripIndents`
|
||||
Aw... Too bad, try again next time!
|
||||
The correct answer is: ${solved}
|
||||
`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { RichEmbed } = require('discord.js');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const request = require('superagent');
|
||||
|
||||
module.exports = class QuizCommand extends Command {
|
||||
@@ -25,10 +26,10 @@ module.exports = class QuizCommand extends Command {
|
||||
const answer = body[0].answer.toLowerCase().replace(/(<i>|<\/i>)/g, '');
|
||||
const embed = new RichEmbed()
|
||||
.setTitle('You have **15** seconds to answer this question:')
|
||||
.setDescription(
|
||||
`**Category: ${body[0].category.title}**
|
||||
${body[0].question}`
|
||||
);
|
||||
.setDescription(stripIndents`
|
||||
**Category: ${body[0].category.title}**
|
||||
${body[0].question}
|
||||
`);
|
||||
await msg.embed(embed);
|
||||
try {
|
||||
const collected = await msg.channel.awaitMessages(res => res.author.id === msg.author.id, {
|
||||
@@ -40,10 +41,10 @@ module.exports = class QuizCommand extends Command {
|
||||
return msg.say(`The correct answer is: ${answer}`);
|
||||
return msg.say(`Perfect! The correct answer is: ${answer}`);
|
||||
} catch (err) {
|
||||
return msg.say(
|
||||
`Aw... Too bad, try again next time!
|
||||
The Correct Answer was: ${answer}`
|
||||
);
|
||||
return msg.say(stripIndents`
|
||||
Aw... Too bad, try again next time!
|
||||
The Correct Answer was: ${answer}
|
||||
`);
|
||||
}
|
||||
} catch (err) {
|
||||
return msg.say('An Unknown Error Occurred.');
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const slotThing = [':grapes:', ':tangerine:', ':pear:', ':cherries:'];
|
||||
|
||||
module.exports = class SlotsCommand extends Command {
|
||||
@@ -16,13 +17,13 @@ module.exports = class SlotsCommand extends Command {
|
||||
const slotTwo = slotThing[Math.floor(Math.random() * slotThing.length)];
|
||||
const slotThree = slotThing[Math.floor(Math.random() * slotThing.length)];
|
||||
if (slotOne === slotTwo && slotOne === slotThree)
|
||||
return msg.say(
|
||||
`${slotOne}|${slotTwo}|${slotThree}
|
||||
Wow! You won! Great job... er... luck!`
|
||||
);
|
||||
return msg.say(
|
||||
`${slotOne}|${slotTwo}|${slotThree}
|
||||
Aww... You lost... Guess it's just bad luck, huh?`
|
||||
);
|
||||
return msg.say(stripIndents`
|
||||
${slotOne}|${slotTwo}|${slotThree}
|
||||
Wow! You won! Great job... er... luck!
|
||||
`);
|
||||
return msg.say(stripIndents`
|
||||
${slotOne}|${slotTwo}|${slotThree}
|
||||
Aww... You lost... Guess it's just bad luck, huh?
|
||||
`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { RichEmbed } = require('discord.js');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const moment = require('moment');
|
||||
require('moment-duration-format');
|
||||
|
||||
@@ -30,8 +31,10 @@ module.exports = class GuildInfoCommand extends Command {
|
||||
.addField('**ID:**',
|
||||
msg.guild.id, true)
|
||||
.addField('**Created On:**',
|
||||
`${msg.guild.createdAt}
|
||||
${moment.duration(Date.now() - msg.guild.createdTimestamp).format('y[ years], M[ months], w[ weeks, and ]d[ days]')} ago.`, true)
|
||||
stripIndents`
|
||||
${msg.guild.createdAt}
|
||||
${moment.duration(Date.now() - msg.guild.createdTimestamp).format('y[ years], M[ months], w[ weeks, and ]d[ days]')} ago.
|
||||
`, true)
|
||||
.addField('**Default Channel:**',
|
||||
msg.guild.defaultChannel, true)
|
||||
.addField('**Region:**',
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { RichEmbed } = require('discord.js');
|
||||
const { stripIndents } = require('common-tags');
|
||||
|
||||
module.exports = class BanCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -50,10 +51,10 @@ module.exports = class BanCommand extends Command {
|
||||
return msg.say('This member is not bannable. Perhaps they have a higher role than me?');
|
||||
try {
|
||||
try {
|
||||
await member.send(
|
||||
`You were banned from ${msg.guild.name}!
|
||||
Reason: ${reason}.`
|
||||
);
|
||||
await member.send(stripIndents`
|
||||
You were banned from ${msg.guild.name}!
|
||||
Reason: ${reason}.
|
||||
`);
|
||||
} catch (err) {
|
||||
await msg.say('Failed to send DM to user.');
|
||||
}
|
||||
@@ -66,11 +67,11 @@ module.exports = class BanCommand extends Command {
|
||||
.setAuthor(msg.author.tag, msg.author.displayAvatarURL)
|
||||
.setColor(0xFF0000)
|
||||
.setTimestamp()
|
||||
.setDescription(
|
||||
`**Member:** ${member.user.tag} (${member.id})
|
||||
.setDescription(stripIndents`
|
||||
**Member:** ${member.user.tag} (${member.id})
|
||||
**Action:** Ban
|
||||
**Reason:** ${reason}`
|
||||
);
|
||||
**Reason:** ${reason}
|
||||
`);
|
||||
return modlogs.send({embed});
|
||||
} catch (err) {
|
||||
return msg.say('An Unknown Error Occurred.');
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { RichEmbed } = require('discord.js');
|
||||
const { stripIndents } = require('common-tags');
|
||||
|
||||
module.exports = class KickCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -47,10 +48,10 @@ module.exports = class KickCommand extends Command {
|
||||
return msg.say('This member is not kickable. Perhaps they have a higher role than me?');
|
||||
try {
|
||||
try {
|
||||
await member.send(
|
||||
`You were kicked from ${msg.guild.name}!
|
||||
Reason: ${reason}.`
|
||||
);
|
||||
await member.send(stripIndents`
|
||||
You were kicked from ${msg.guild.name}!
|
||||
Reason: ${reason}.
|
||||
`);
|
||||
} catch (err) {
|
||||
await msg.say('Failed to send DM.');
|
||||
}
|
||||
@@ -62,11 +63,11 @@ module.exports = class KickCommand extends Command {
|
||||
.setAuthor(msg.author.tag, msg.author.displayAvatarURL)
|
||||
.setColor(0xFFA500)
|
||||
.setTimestamp()
|
||||
.setDescription(
|
||||
`**Member:** ${member.user.tag} (${member.id})
|
||||
.setDescription(stripIndents`
|
||||
**Member:** ${member.user.tag} (${member.id})
|
||||
**Action:** Kick
|
||||
**Reason:** ${reason}`
|
||||
);
|
||||
**Reason:** ${reason}
|
||||
`);
|
||||
return modlogs.send({embed});
|
||||
} catch (err) {
|
||||
return msg.say('An Unknown Error Occurred.');
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { RichEmbed } = require('discord.js');
|
||||
const { stripIndents } = require('common-tags');
|
||||
|
||||
module.exports = class SoftbanCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -49,10 +50,10 @@ module.exports = class SoftbanCommand extends Command {
|
||||
return msg.say('This member is not bannable. Perhaps they have a higher role than me?');
|
||||
try {
|
||||
try {
|
||||
await member.send(
|
||||
`You were softbanned from ${msg.guild.name}!
|
||||
Reason: ${reason}.`
|
||||
);
|
||||
await member.send(stripIndents`
|
||||
You were softbanned from ${msg.guild.name}!
|
||||
Reason: ${reason}.
|
||||
`);
|
||||
} catch (err) {
|
||||
await msg.say('Failed to send DM to user.');
|
||||
}
|
||||
@@ -66,11 +67,11 @@ module.exports = class SoftbanCommand extends Command {
|
||||
.setAuthor(msg.author.tag, msg.author.displayAvatarURL)
|
||||
.setColor(0xFF4500)
|
||||
.setTimestamp()
|
||||
.setDescription(
|
||||
`**Member:** ${member.user.tag} (${member.id})
|
||||
.setDescription(stripIndents`
|
||||
**Member:** ${member.user.tag} (${member.id})
|
||||
**Action:** Softban
|
||||
**Reason:** ${reason}`
|
||||
);
|
||||
**Reason:** ${reason}
|
||||
`);
|
||||
return modlogs.send({embed});
|
||||
} catch (err) {
|
||||
return msg.say('An Unknown Error Occurred.');
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { RichEmbed } = require('discord.js');
|
||||
const { stripIndents } = require('common-tags');
|
||||
|
||||
module.exports = class UnbanCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -61,11 +62,11 @@ module.exports = class UnbanCommand extends Command {
|
||||
.setAuthor(msg.author.tag, msg.author.displayAvatarURL)
|
||||
.setColor(0x00AE86)
|
||||
.setTimestamp()
|
||||
.setDescription(
|
||||
`**Member:** ${member.tag} (${member.id})
|
||||
.setDescription(stripIndents`
|
||||
**Member:** ${member.tag} (${member.id})
|
||||
**Action:** Unban
|
||||
**Reason:** ${reason}`
|
||||
);
|
||||
**Reason:** ${reason}
|
||||
`);
|
||||
return modlogs.send({embed});
|
||||
} catch (err) {
|
||||
return msg.say('An Unknown Error Occurred.');
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { RichEmbed } = require('discord.js');
|
||||
const { stripIndents } = require('common-tags');
|
||||
|
||||
module.exports = class WarnCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -46,11 +47,11 @@ module.exports = class WarnCommand extends Command {
|
||||
.setAuthor(msg.author.tag, msg.author.displayAvatarURL)
|
||||
.setColor(0xFFFF00)
|
||||
.setTimestamp()
|
||||
.setDescription(
|
||||
`**Member:** ${member.user.tag} (${member.id})
|
||||
.setDescription(stripIndents`
|
||||
**Member:** ${member.user.tag} (${member.id})
|
||||
**Action:** Warn
|
||||
**Reason:** ${reason}`
|
||||
);
|
||||
**Reason:** ${reason}
|
||||
`);
|
||||
return modlogs.send({embed});
|
||||
} catch (err) {
|
||||
return msg.say('An Unknown Error Occurred.');
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const request = require('superagent');
|
||||
|
||||
module.exports = class StrawpollCommand extends Command {
|
||||
@@ -47,10 +48,10 @@ module.exports = class StrawpollCommand extends Command {
|
||||
title,
|
||||
options
|
||||
});
|
||||
return msg.say(
|
||||
`${body.title}
|
||||
http://strawpoll.me/${body.id}`
|
||||
);
|
||||
return msg.say(stripIndents`
|
||||
${body.title}
|
||||
http://strawpoll.me/${body.id}
|
||||
`);
|
||||
} catch (err) {
|
||||
return msg.say('An Unknown Error Occurred.');
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const answers = require('./8ballanswers');
|
||||
|
||||
module.exports = class MagicBallCommand extends Command {
|
||||
@@ -21,9 +22,9 @@ module.exports = class MagicBallCommand extends Command {
|
||||
run(msg, args) {
|
||||
const { question } = args;
|
||||
const answer = answers[Math.floor(Math.random() * answers.length)];
|
||||
return msg.say(
|
||||
`Question: ${question}
|
||||
:8ball: ${answer} :8ball:`
|
||||
);
|
||||
return msg.say(stripIndents`
|
||||
Question: ${question}
|
||||
:8ball: ${answer} :8ball:
|
||||
`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { stripIndents } = require('common-tags');
|
||||
|
||||
module.exports = class CowsayCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -24,13 +25,15 @@ module.exports = class CowsayCommand extends Command {
|
||||
|
||||
run(msg, args) {
|
||||
const { text } = args;
|
||||
return msg.code(null,
|
||||
`< ${text} >
|
||||
return msg.code(null,
|
||||
stripIndents`
|
||||
< ${text} >
|
||||
\\ ^__^
|
||||
\\ (oO)\\_______
|
||||
(__)\\ )\\/\\
|
||||
U ||----w |
|
||||
|| ||`
|
||||
|| ||
|
||||
`
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { RichEmbed } = require('discord.js');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const moment = require('moment');
|
||||
require('moment-duration-format');
|
||||
|
||||
@@ -60,8 +61,10 @@ module.exports = class UserInfoCommand extends Command {
|
||||
.addField('**ID:**',
|
||||
user.id, true)
|
||||
.addField('**Joined Discord On:**',
|
||||
`${user.createdAt}
|
||||
${moment.duration(Date.now() - user.createdTimestamp).format('y[ years], M[ months], w[ weeks, and ]d[ days]')} ago.`, true)
|
||||
stripIndents`
|
||||
${user.createdAt}
|
||||
${moment.duration(Date.now() - user.createdTimestamp).format('y[ years], M[ months], w[ weeks, and ]d[ days]')} ago.
|
||||
`, true)
|
||||
.addField('**Joined Server On:**',
|
||||
`${member.joinedAt}
|
||||
${moment.duration(Date.now() - member.joinedTimestamp).format('y[ years], M[ months], w[ weeks, and ]d[ days]')} ago.`, true)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { RichEmbed } = require('discord.js');
|
||||
const { stripIndents } = require('common-tags');
|
||||
|
||||
module.exports = class HelpCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -29,14 +30,14 @@ module.exports = class HelpCommand extends Command {
|
||||
const showAll = command && command.toLowerCase() === 'all';
|
||||
if (command && !showAll) {
|
||||
if (commands.length === 1) {
|
||||
return msg.say(
|
||||
`__Command **${commands[0].name}**:__ *${commands[0].description}*
|
||||
return msg.say(stripIndents`
|
||||
__Command **${commands[0].name}**:__ *${commands[0].description}*
|
||||
${commands[0].guildOnly ? 'Usable Only in Servers' : 'Usable in Server and DM'}
|
||||
**Format:** ${msg.anyUsage(`${commands[0].name}${commands[0].format ? ` ${commands[0].format}` : ''}`)}
|
||||
**Aliases:** ${commands[0].aliases.join(', ') || 'None'}
|
||||
**Group:** ${commands[0].group.name}
|
||||
${commands[0].details || ''}`
|
||||
);
|
||||
${commands[0].details || ''}
|
||||
`);
|
||||
} else if (commands.length > 1) {
|
||||
return msg.say('Multiple Commands Found. Please be more specific.');
|
||||
} else {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { stripIndents } = require('common-tags');
|
||||
|
||||
module.exports = class InviteCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -12,11 +13,11 @@ module.exports = class InviteCommand extends Command {
|
||||
|
||||
async run(msg) {
|
||||
const invite = await this.client.generateInvite('1345846343');
|
||||
return msg.say(
|
||||
`Add me to your server with this link:
|
||||
return msg.say(stripIndents`
|
||||
Add me to your server with this link:
|
||||
${invite}
|
||||
Or, come to my server with this link:
|
||||
${this.client.options.invite}`
|
||||
);
|
||||
${this.client.options.invite}
|
||||
`);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user