Skip to content
Snippets Groups Projects
Commit ff97e6e7 authored by Reviath's avatar Reviath
Browse files

Fixed welcome-channel command (getting channel by Promise.

parent 5430d035
Branches
No related tags found
No related merge requests found
......@@ -13,17 +13,20 @@ exports.run = async (client, message , args, connection) => {
});
return;
};
let channel;
await connection.query(`SELECT channel FROM welcome_channel WHERE guild ='${message.guild.id}'`, function (err, result) {
if (err) {
throw err;
};
if (result.length > 0) {
channel = result[0].channel;
} else {
const channeldb = await new Promise((resolve, reject) => {
connection.query(`SELECT channel FROM welcome_channel WHERE guild ='${message.guild.id}'`, function (err, result) {
if (err)
reject(err);
resolve(result);
});
});
if (channeldb.length < 1) {
channel = "none";
} else {
channel = channeldb[0].channel;
};
});
if (args[0] == "reset") {
if (channel == "none"){
message.channel.send(errors.not_existing_on_db).catch(() => {
......@@ -51,6 +54,10 @@ exports.run = async (client, message , args, connection) => {
throw err;
};
});
message.channel.send(`Successful!`).catch(() => {
return;
});
return;
} else {
const prefixdb = await new Promise((resolve, reject) => {
connection.query(`SELECT prefix FROM prefixes WHERE guild ='${message.guild.id}'`, function (err, result) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment