fix database calls
This commit is contained in:
2 files changed
+17
-6
No files matched your search
@@ -34,7 +34,18 @@ module.exports = {
|
||||
}
|
||||
|
||||
let channelType = args[0].value;
|
||||
let query = "server.actionChannel" ? channelType == "action" : "server.tweetChannel";
|
||||
let query;
|
||||
if (channelType == "action") {
|
||||
query = {
|
||||
$set: {
|
||||
"server.actionChannel": null
|
||||
}
|
||||
}
|
||||
} else query = {
|
||||
$set: {
|
||||
"server.tweetChannel": null
|
||||
}
|
||||
}
|
||||
|
||||
let message = new MessageEmbed()
|
||||
.setTitle(`Are you sure you want to stop using this channel for ${channelType}s?`)
|
||||
@@ -59,7 +70,7 @@ module.exports = {
|
||||
let action = ''
|
||||
if (queryString=='yes') {
|
||||
action = 'removed';
|
||||
client.dbo.collection("guilds").updateOne({"server.serverID":ButtonInteraction.guild.id},{$set:{query:null}},function(err, res) {
|
||||
client.dbo.collection("guilds").updateOne({"server.serverID":ButtonInteraction.guild.id},query,function(err, res) {
|
||||
if (err) {
|
||||
client.log(err);
|
||||
let embed = new MessageEmbed()
|
||||
|
||||
@@ -52,14 +52,14 @@ module.exports = {
|
||||
let channelSetting, query;
|
||||
if (channelType == "action") {
|
||||
channelSetting = guild.server.actionChannel;
|
||||
query = "server.actionChannel"
|
||||
query = { $set: { "server.actionChannel": channelid } }
|
||||
} else if (channelType == "tweet") {
|
||||
channelSetting = guild.server.tweetChannel;
|
||||
query = "server.tweetChannel"
|
||||
query = { $set: { "server.tweetChannel": channelid } }
|
||||
}
|
||||
|
||||
if (channelSetting == channelid) return interaction.send(`The channel <#${args[1].value}> has already been set for ${channelType}s.`);
|
||||
client.dbo.collection("guilds").updateOne({"server.serverID":interaction.guild.id},{$set:{query: channelid}},function(err, res) {
|
||||
client.dbo.collection("guilds").updateOne({"server.serverID":interaction.guild.id},query,function(err, res) {
|
||||
if (err) {
|
||||
client.log(err);
|
||||
let embed = new MessageEmbed()
|
||||
@@ -72,7 +72,7 @@ module.exports = {
|
||||
let successEmbed = new MessageEmbed()
|
||||
.setColor("GREEN")
|
||||
.setTitle("Success")
|
||||
.setDescription(`Successfully set <#${args[0].value}> for ${channelType}.`);
|
||||
.setDescription(`Successfully set <#${channelid}> for ${channelType}s.`);
|
||||
|
||||
return interaction.send({ embeds: [successEmbed] });
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user