I have these lines of codes so far. However, I am not entirely sure how to make an embed that if the command executor reacts to an emoji it will proceed to the next embed message; and if it's someone else, it'll return.
const embed = new MessageEmbed()
.setDescription("Thank you for using Norieko, please react below to see the command list")
message.channel.send(embed)
const modEmbed = new MessageEmbed()
.setDescription("Moderation Commands: `kick`, `ban`, `purge`")
message.channel.send(modEmbed)
const miscEmbed = new MessageEmbed()
.setDescription("Misc Commands: `meme`, `server`, `user`, `help`")
message.channel.send(miscEmbed)
Using Fields
It seems you wanted to react and sends the message, this could be better and less complicate!
client.on('messageReactionAdd', async (reaction, message) => {
const embed1 = new MessageEmbed()
.setDescription('Thank you for using Norieko, please react below to see the command list')
message.channel.send(embed1).then(function(message) {
message.react('✅');
});
if (reaction.emoji === '✅') {
const embed2 = new MessageEmbed()
.setTitle('Commands')
.addField('Moderation', '`kick`, `ban`, `purge`')
.addField('Misc', '`meme`, `server`, `user`, `help`')
message.channel.send(embed2);
};
});
Related
im trying to do an embed, but every time i try using it, it says "DiscordAPIError: Cannot send an empty message"
Here is the embed and everything related to it:
client.on('message',(message) => {
if(message.author.bot) return;
let botMessageLog = new Discord.MessageEmbed()
.setAuthor(`Logs`, client.user.avatarURL())
.setDescription(`**${message.author.toString()}** said: **${message.content}** in channel **${message.channel.toString()}**`)
.setFooter(`Log system`, client.user.avatarURL())
.setTimestamp()
.setColor("FF0000");
bot.channels.cache.get("1018767166218182668").send(botMessageLog)
});
You are doing many things wrong if you are using discord js v 14
hare is a quick fix
const {Client, EmbedBuilder} = require("discord.js")
//define a new client
client.on('messageCreate',(message) => {
if(message.author.bot) return;
let botMessageLog = new EmbedBuilder()
.setAuthor({name:`Logs`,iconURL: client.user.displayAvatarURL()})
.setDescription(`**${message.author.username}** said: **${message.content}** in channel **${message.channel.name}**`)
.setFooter({text:`Log system`, iconURL: client.user.displayAvatarURL() })
.setTimestamp()
.setColor("FF0000");
bot.channels.cache.get("1018767166218182668").send({embeds:[botMessageLog]})
//you must define bot as client
})
it always better if you use the latest Version of discord js
I'm trying to make a snipe command for the dc bot but I can't get the embed to reset. Tried putting embed = {} in different locations, then it tries sending an empty message the next time and errors out. Also it's let embed now since I was testing, tried const first. Edit: works now when checking messages elsewhere, should have done that to start with. Code:
bot.on('messageDelete', message => {
let embed = new Discord.MessageEmbed()
.setAuthor(`${message.author.username} (${message.author.id})`, message.author.avatarURL())
.setDescription(message.content || "None")
bot.on('message', message => {
const args = message.content.slice(PREFIX.length).split(/ +/);
const cmd = args.shift().toLowerCase();
if (cmd === 'msg'){
message.channel.send(embed)
}
})
})
You don't need a embed = {}, instead use client.snipes = new Map() as collector. So if someone delete message when the bot online, the bot can detect it.
client.snipes = new Map()
client.on('messageDelete', function(message, channel) {
client.snipes.set(message.channel.id, {
content: message.content,
author: message.author,
image: message.attachments.first() ? message.attachments.first().proxyURL : null
})
}) //This will be your collector on your index file.
Then create a command file.
const msg = client.snipes.get(message.channel.id)
if(!msg) return message.channel.send("Didn't find any deleted messages.")
const embed = new MessageEmbed()
.setDescription(`Your_Message`)
.setTimestamp()
if(msg.image) embed.setImage(msg.image) //If image deleted, it will go here.
message.channel.send({ embeds: [embed] })
Every time a message is deleted you are resubscribing to the message event.
I would suggest taking some of that logic to the outside of that scope.
let embed = null;
bot.on('messageDelete', message => {
embed = new Discord.MessageEmbed()
.setAuthor(`${message.author.username} (${message.author.id})`, message.author.avatarURL())
.setDescription(message.content || "None")
})
bot.on('message', message => {
const args = message.content.slice(PREFIX.length).split(/ +/);
const cmd = args.shift().toLowerCase();
if (cmd === 'msg' && embed){
message.channel.send(embed)
}
})
Hello I made a mail command which would take message from modal and send it to a mentioned user but it gives this error in modal window and does not log anything in console
const { Permissions } = require('discord.js');
const { Modal, TextInputComponent, showModal } = require('discord-modals')
const { Formatters } = require('discord.js');
module.exports.run = async (Client, message, args, prefix) => {
let member = message.mentions.members.first();
if(!message.content.includes(member)) {
embed = new MessageEmbed()
.setColor('RED')
.setTitle('Whome shd I send this mail to bruh')
.setDescription('Please mention the user whome you want to deliver the message')
await message.reply({embeds:[embed]})
}
else {
msg = new MessageEmbed()
.setColor('GREEN')
.setTitle('its time to type your message to your friend')
.setDescription('Please type your subject and message as you do while composing a normal mail using gmail just click the button and fill the subject and the message in their respective fields')
const row = new MessageActionRow().addComponents(
new MessageButton()
.setCustomId('compose')
.setLabel('Fill up info and compose')
.setEmoji('📧')
.setStyle('SECONDARY')
);
const msg = await message.reply({embeds:[msg],components: [row]});
//defining intput text fields
let textinput = new TextInputComponent()
.setCustomId('textinput-customid')
.setLabel('Subject')
.setStyle('SHORT')
.setMinLength('1')
.setMaxLength('200')
.setPlaceholder('type your Subject here it can be anything in less than 200 words')
.setRequired(true)
let textinputl = new TextInputComponent()
.setCustomId('textinput-customidl')
.setLabel('Message')
.setStyle('LONG')
.setMinLength('1')
.setMaxLength('4000')
.setPlaceholder('type your message here it can be anything in less than 4000 words')
.setRequired(true)
//main modal
const modal = new Modal() // We create a Modal
.setCustomId('modal-customid')
.setTitle('Compose a mail')
.addComponents([ textinput, textinputl ])
Client.on('interactionCreate', (interaction) => {
if(interaction.isButton) {
if(interaction.customId === 'compose'){
showModal(modal, {
client: Client,
interaction: interaction
})
}
}
})
Client.on('modalSubmit', async (modal) => {
if(modal.customId === 'modal-customid'){
const subjectresponse = modal.getTextInputValue('textinput-customid')
const messageresponse = modal.getTextInputValue('textinput-customidl')
modal.followUp({ content: 'Done message delivered.' + Formatters.codeBlock('markdown', firstResponse), ephemeral: true })
const embed = new MessageEmbed()
.setTitle('You have a new mail')
.setDescription(`${message.author.username} has sent you an email`)
.addField('Subject:', `${subjectresponse}`, false)
.addField('Message:', `${messageresponse}`, false)
await message.reply({embeds:[embed]});
}
})
}
}
module.exports.help = {
name: 'mail',
aliases: []
}
this is the code please check it out and tell what is the error
on the git error page of this people were asking about it but I dint understand that
Have to make a lot of code changes, here is what the final result was below, basically the issue was that there were a lot of variances in the code and how the code was handled. Needed to add checks to the code to help it move along. Added the member id to the embed to help the bot get that id when it needed it later.
command.js file
const mentionedMember = message.mentions.members.first();
if (!mentionedMember || mentionedMember.user.bot) {
const embed = new MessageEmbed()
.setColor('RED')
.setTitle('Whom should I send this mail to bruh')
.setDescription('Please mention the user whom you want to deliver the message, no bots');
message.reply({
embeds: [embed],
});
setTimeout(() => {
message.delete();
}, 100);
} else {
const rickrollmsg = new MessageEmbed()
.setColor('GREEN')
.setTitle('its time to type your message to your friend')
.setDescription('Please type your subject and message as you do while composing a normal mail using gmail just click the button and fill the subject and the message in their respective fields')
.setFooter({
text: mentionedMember.id,
});
const row = new MessageActionRow().addComponents(
new MessageButton()
.setCustomId('compose')
.setLabel('Fill up info and compose')
.setEmoji('📧')
.setStyle('SECONDARY'),
);
message.reply({
embeds: [rickrollmsg],
components: [row],
});
setTimeout(() => {
message.delete();
}, 100);
}
interactionCreate button code
const textinput = new TextInputComponent()
.setCustomId('rickmail-subject')
.setLabel('Subject')
.setStyle('SHORT')
.setMinLength('1')
.setMaxLength('200')
.setPlaceholder('type your Subject here it can be anything in less than 200 words')
.setRequired(true);
const textinputl = new TextInputComponent()
.setCustomId('rickmail-message')
.setLabel('Message')
.setStyle('LONG')
.setMinLength('1')
.setMaxLength('4000')
.setPlaceholder('type your message here it can be anything in less than 4000 words')
.setRequired(true);
const modal = new Modal()
.setCustomId('rickmail')
.setTitle('Compose a rickmail')
.addComponents([textinput, textinputl]);
showModal(modal, {
client: client,
interaction: inter,
});
modalSubmit listener
const member = modal.guild.members.cache.get(modal.message.embeds[0].footer.text);
const subject = modal.getTextInputValue('rickmail-subject');
const message = modal.getTextInputValue('rickmail-message');
const embed = new MessageEmbed()
.setColor('RANDOM')
.setTitle(`${subject}`)
.setDescription(`${message}`)
.setImage('https://www.icegif.com/wp-content/uploads/rick-roll-icegif-5.gif')
.setFooter({
text: `Message Received ${new Date().toLocaleString()}`,
});
modal.message.delete();
member.send({
embeds: [embed],
});
return modal.followUp({
content: 'Rickmail sent',
ephemeral: true,
});
I recently made a discord word filter bot and I was wondering how I could make it configurable per server? I want to be able to make a command that adds words to be filtered to the code and I want people to be able to add a custom prefix per server. I also want people to be able to set their log channel per server. Can someone help me with this please? I spent a lot of time on this bot and I dont want to just keep making more of the same bot for different servers. I'm using discord.js 12.5.3. I'll attach my code below.
const Discord = require('discord.js');
const client = new Discord.Client();
client.once('ready', async () => {
console.log('yay, the bot is online')
client.user.setActivity('im real', {type: 'PLAYING'})
})
client.on('message', async message => {
if(message.channel.type === 'dm' || message.author.bot) return;
const logChannel = client.channels.cache.find(channel => channel.id === '921730444498726924')
let words = [“bad”, “words”, “here”]
let foundInText = false;
for (var i in words) {
if (message.content.toLowerCase().includes(words[i].toLowerCase())) foundInText = true;
}
if (foundInText) {
let logEmbed = new Discord.MessageEmbed()
.setDescription(<#${message.author.id}> Said a bad word)
.addField('The Message', message.content)
.setColor('RANDOM')
.setTimestamp()
logChannel.send(logEmbed)
let embed = new Discord.MessageEmbed()
.setDescription('That word is not allowed here')
.setColor('RANDOM')
.setTimestamp()
let msg = await message.channel.send(embed);
message.delete()
msg.delete({timeout: '3500'})
}
})
I've tried following a tutorial but it didn't help because I need one specifically for my case. If anyone could help, that would be great.
The code won't work perfectly, i find couple of issues:
When I'm connected to a VC and trying to attempt the command the bot leaves the VC but triggers two functions at a time i.e., General leave funtion and author not in the same channel.
When i give command being outside the VC(bot connected to the VC) the bot responds with function we are not in a same channel funtion., rather i want it to respond with you're not connected to VC
When i give command while being outside VC and bot not connected to VC, it responds nothing and at console i get error:
(node:37) UnhandledPromiseRejectionWarning: TypeError: cannot read property "id" of undefined
Code:
client.on('message', async (message) => {
const args = message.content.slice(prefix.length).trim().split(/ +/);
const command = args.shift().toLowerCase();
if (command === 'leave') {
let authorVoice = message.member.voice;
const embed1 = new discord.MessageEmbed()
.setTitle('🚫`You are not in a Voice Channel!`')
.setColor('RED')
.setTimestamp();
if (!authorVoice.channel) return message.channel.send(embed1);
const embed2 = new discord.MessageEmbed()
.setTitle('⛔`We are not in a same Voice Channel`')
.setColor('YELLOW')
.setTimestamp();
if (authorVoice.channel.id !== client.voice.channel.id)
return message.channel.send(embed2);
const embed = new discord.MessageEmbed()
.setTitle('`Successfully left the Voice Channel`✔')
.setColor('RED')
.setTimestamp();
authorVoice.channel.leave()
message.channel.send(embed);
}
});
Can someone help me fix it?
client.voice doesn't have a channel property. It means that client.voice.channel is undefined. When you try to read the id of it, you receive the error that you "cannot read property "id" of undefined".
You probably want the connections that is a collection of VoiceConnections. A connection does have a channel property but as client.voice.connections is a collection, you need to find the one you need first.
As you only want to check if a channel with the same ID exists, you can use the .some() method. In its callback function you check if any of the connections has the same channel ID as the message author's channel ID. So, instead of if(authorVoice.channel.id !== client.voice.channel.id) you could create a variable that returns a boolean. It returns true if the bot is in the same channel and false otherwise:
const botIsInSameChannel = client.voice.connections.some(
(c) => c.channel.id === authorVoice.channel.id,
);
// bot is not in the same channel
if (!botIsInSameChannel)
return message.channel.send(embed2);
Here is the updated code if anyone watching for:
client.on('message', async message => {
const args = message.content.slice(prefix.length).trim().split(/ +/);
const command = args.shift().toLowerCase();
if (command === 'leave') {
let authorVoice = message.member.voice;
const botIsInSameChannel = client.voice.connections.some(
(c) => c.channel.id === authorVoice.channel.id,
);
const embed1 = new discord.MessageEmbed()
.setTitle(':no_entry_sign: You are not in a Voice Channel!')
.setColor('RED')
.setTimestamp();
if(!authorVoice.channel) return message.channel.send(embed1);
const embed2 = new discord.MessageEmbed()
.setTitle(':no_entry: We are not in a same Voice Channel')
.setColor('YELLOW')
.setTimestamp();
if (!botIsInSameChannel) return message.channel.send(embed2)
const embed = new discord.MessageEmbed()
.setTitle('Successfully left the Voice Channel✔')
.setColor('RED')
.setTimestamp();
authorVoice.channel.leave();
message.channel.send(embed);
}
});