Browse Source

Use default prefix for DMs

master
Abheek Dhawan 4 years ago
parent
commit
fafb02da61
  1. 64
      bot.js

64
bot.js

@ -52,11 +52,12 @@ client.on("ready", () => {
}); });
client.on("message", async message => { client.on("message", async message => {
let prefix;
if (message.guild) {
collection.findOne({ guild_id: message.guild.id }, (error, result) => { collection.findOne({ guild_id: message.guild.id }, (error, result) => {
if (error) { if (error) {
console.error; console.error;
} }
let prefix;
if (!result) { if (!result) {
console.log(`Guild ${message.guild.id} not in database`); console.log(`Guild ${message.guild.id} not in database`);
return; return;
@ -125,6 +126,67 @@ client.on("message", async message => {
customPrefix(message); customPrefix(message);
} }
}); });
} else {
prefix = defaultPrefix;
if (message.content === `<@!${client.user.id}>`) {
message.reply(`\nPrefix: \`${prefix}\`\nHelp: \`${prefix}help\`\nChange Prefix: \`${prefix}prefix [new prefix]\``);
}
if (!message.content.startsWith(prefix) || message.author.bot) {
return;
}
switch (message.content.toLowerCase()) {
case `${prefix}aboutserver`:
aboutServer(message);
break;
case `${prefix}help`:
helpMessage(message, prefix);
break;
case `${prefix}startlogs`:
startLogs(message);
break;
case `${prefix}kulboard`:
kulboardCreate(message)
break;
case `${prefix}ping`:
ping(message);
break;
case `${prefix}iss`:
locateISS(message);
break;
case `${prefix}membercountchannel`:
memberCountChannelCreate(message);
break;
}
if (message.content.toLowerCase().startsWith(`${prefix}bulkdelete`)) {
bulkDelete(message);
} else if (message.content.toLowerCase().startsWith(`${prefix}rolerequest`)) {
roleRequest(message);
} else if (message.content.toLowerCase().startsWith(`${prefix}userswith`)) {
usersWith(message);
} else if (message.content.toLowerCase().startsWith(`${prefix}ban`)) {
ban(message);
} else if (message.content.toLowerCase().startsWith(`${prefix}kick`)) {
kick(message);
} else if (message.content.toLowerCase().startsWith(`${prefix}addrole`)) {
addRole(message);
} else if (message.content.toLowerCase().startsWith(`${prefix}userinfo`)) {
userInfo(message);
} else if (message.content.toLowerCase().startsWith(`${prefix}aboutbot`)) {
aboutBot(message);
} else if (message.content.toLowerCase().startsWith(`${prefix}roleinfo`)) {
roleInfo(message);
} else if (message.content.toLowerCase().startsWith(`${prefix}addemoji`)) {
addEmoji(message);
} else if (message.content.toLowerCase().startsWith(`${prefix}reactionrole`)) {
reactionRole(message);
} else if (message.content.toLowerCase().startsWith(`${prefix}prefix`)) {
customPrefix(message);
}
}
}); });
async function customPrefix(message) { async function customPrefix(message) {

Loading…
Cancel
Save