'Discord.js Returning 2 Embeds Issue
if (args[0] === "off") {
let disabled = new Discord.MessageEmbed()
.setColor(ee.color)
.setAuthor('Disabled Welcomer Channel', client.user.avatarURL())
.setThumbnail('https://icons.iconarchive.com/icons/dtafalonso/android-lollipop/512/Settings-icon.png')
.addFields(
{ name: '__**Status**__', value: ':white_circle: Disabled', inline: true },
{ name: '__**Channel**__', value: `None`, inline: true },
)
db.delete(`welchannel_${message.guild.id}`)
message.channel.send(disabled)
}
let chx = db.get(`welchannel_${message.guild.id}`)
let channel = message.mentions.channels.first()
let embed = new Discord.MessageEmbed()
.setColor(ee.wrongcolor)
.setTitle('<:warning:943421375526355024> | **Please Provide A Channel**')
.setDescription('**Usage:**\n```css\n.welcomer <#channel|OFF>```')
.addFields(
{
name: '__**Current Welcomer Channel:**__',
value: chx ? `<#${chx}>` : 'None',
inline: true,
},
);
if (!channel) {
return message.channel.send(embed)
}
When using the command .welcomer off it returns the disabled embed and the embed, embed at the same time how do i make it only return the disabled embed when adding the off argument at the end of it .
Solution 1:[1]
Use return
Eg:
return message.channel.send(disabled)
if (args[0] === "off") {
let disabled = new Discord.MessageEmbed()
.setColor(ee.color)
.setAuthor('Disabled Welcomer Channel', client.user.avatarURL())
.setThumbnail('https://icons.iconarchive.com/icons/dtafalonso/android-lollipop/512/Settings-icon.png')
.addFields(
{ name: '__**Status**__', value: ':white_circle: Disabled', inline: true },
{ name: '__**Channel**__', value: `None`, inline: true },
)
db.delete(`welchannel_${message.guild.id}`)
return message.channel.send(disabled);
}
let chx = db.get(`welchannel_${message.guild.id}`)
let channel = message.mentions.channels.first()
let embed = new Discord.MessageEmbed()
.setColor(ee.wrongcolor)
.setTitle('<:warning:943421375526355024> | **Please Provide A Channel**')
.setDescription('**Usage:**\n```css\n.welcomer <#channel|OFF>```')
.addFields(
{
name: '__**Current Welcomer Channel:**__',
value: chx ? `<#${chx}>` : 'None',
inline: true,
},
);
if (!channel) {
return message.channel.send(embed)
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Azer |
