Added the message content as a parameter to command.run, re-added message to ban
This commit is contained in:
parent
35cec45196
commit
fd3bd96ae6
3 changed files with 7 additions and 7 deletions
|
@ -8,9 +8,8 @@ exports.run = async (message) => {
|
||||||
try {
|
try {
|
||||||
await message.channel.guild.banMember(member.id, 0, `ban command used by @${message.author.username}#${message.author.discriminator}`);
|
await message.channel.guild.banMember(member.id, 0, `ban command used by @${message.author.username}#${message.author.discriminator}`);
|
||||||
return `Successfully banned ${member.mention}.`;
|
return `Successfully banned ${member.mention}.`;
|
||||||
} catch (error) {
|
} catch (e) {
|
||||||
throw error;
|
return `${message.author.mention}, I was unable to ban the member. Have you given me permissions?`;
|
||||||
//return `${message.author.mention}, I was unable to ban the member. Have you given me permissions?`;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return `${message.author.mention}, you need to provide a member to ban!`;
|
return `${message.author.mention}, you need to provide a member to ban!`;
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
const qrcode = require("qrcode");
|
const qrcode = require("qrcode");
|
||||||
const stream = require("stream");
|
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!`;
|
if (args.length === 0) return `${message.author.mention}, you need to provide some text to generate a QR code!`;
|
||||||
message.channel.sendTyping();
|
message.channel.sendTyping();
|
||||||
const writable = new stream.PassThrough();
|
const writable = new stream.PassThrough();
|
||||||
qrcode.toFileStream(writable, args.join(" "), { margin: 1 });
|
qrcode.toFileStream(writable, content, { margin: 1 });
|
||||||
const chunks = [];
|
const chunks = [];
|
||||||
writable.on("data", (chunk) => {
|
writable.on("data", (chunk) => {
|
||||||
chunks.push(chunk);
|
chunks.push(chunk);
|
||||||
|
|
|
@ -39,7 +39,8 @@ module.exports = async (message) => {
|
||||||
// separate commands and args
|
// separate commands and args
|
||||||
const escapedPrefix = misc.regexEscape(prefix);
|
const escapedPrefix = misc.regexEscape(prefix);
|
||||||
const prefixRegex = new RegExp(`^(${escapedPrefix})`);
|
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();
|
const command = args.shift().toLowerCase();
|
||||||
|
|
||||||
// check if command exists
|
// check if command exists
|
||||||
|
@ -49,7 +50,7 @@ module.exports = async (message) => {
|
||||||
// actually run the command
|
// actually run the command
|
||||||
logger.log("info", `${message.author.username} (${message.author.id}) ran command ${command}`);
|
logger.log("info", `${message.author.username} (${message.author.id}) ran command ${command}`);
|
||||||
try {
|
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") {
|
if (typeof result === "string") {
|
||||||
await client.createMessage(message.channel.id, result);
|
await client.createMessage(message.channel.id, result);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue