Added the message content as a parameter to command.run, re-added message to ban

This commit is contained in:
TheEssem 2020-01-13 10:31:01 -06:00
parent 35cec45196
commit fd3bd96ae6
3 changed files with 7 additions and 7 deletions

View file

@ -8,9 +8,8 @@ exports.run = async (message) => {
try {
await message.channel.guild.banMember(member.id, 0, `ban command used by @${message.author.username}#${message.author.discriminator}`);
return `Successfully banned ${member.mention}.`;
} catch (error) {
throw error;
//return `${message.author.mention}, I was unable to ban the member. Have you given me permissions?`;
} catch (e) {
return `${message.author.mention}, I was unable to ban the member. Have you given me permissions?`;
}
} else {
return `${message.author.mention}, you need to provide a member to ban!`;

View file

@ -1,11 +1,11 @@
const qrcode = require("qrcode");
const stream = require("stream");
exports.run = async (message, args) => {
exports.run = async (message, args, content) => {
if (args.length === 0) return `${message.author.mention}, you need to provide some text to generate a QR code!`;
message.channel.sendTyping();
const writable = new stream.PassThrough();
qrcode.toFileStream(writable, args.join(" "), { margin: 1 });
qrcode.toFileStream(writable, content, { margin: 1 });
const chunks = [];
writable.on("data", (chunk) => {
chunks.push(chunk);

View file

@ -39,7 +39,8 @@ module.exports = async (message) => {
// separate commands and args
const escapedPrefix = misc.regexEscape(prefix);
const prefixRegex = new RegExp(`^(${escapedPrefix})`);
const args = message.content.replace(prefixRegex, "").trim().split(/ +/g);
const content = message.content.replace(prefixRegex, "").trim();
const args = content.split(/ +/g);
const command = args.shift().toLowerCase();
// check if command exists
@ -49,7 +50,7 @@ module.exports = async (message) => {
// actually run the command
logger.log("info", `${message.author.username} (${message.author.id}) ran command ${command}`);
try {
const result = await cmd(message, args);
const result = await cmd(message, args, content.replace(command, "").trim()); // we also provide the message content as a parameter for cases where we need more accuracy
if (typeof result === "string") {
await client.createMessage(message.channel.id, result);
}