Finding out who dmed the bot. | Discord.js - discord.js

I've tried this code:
footer: {
text: `${message.author.user}`
},
It's in embed by the way. How can you figure out who dmed the bot?

Related

My bot sends an embed that is invisible to all users and shows no message sent

I've been working on using JS to create a simple Discord Bot for my server. I have been trying to have it send a message with the rules of the server embedded into it. When the /rules command is run, I receive a notification to state a message was sent, but there is no message to be seen on any device. I am able to view message history so I do not understand why there is no visible embed or message.
My code was made using Autocode's Discord Embed Builder, and has worked for other embeds within the same Bot. A link to view the full embed code in the Builder and see how it is supposed to look is here.
It would be much easier to learn to make these yourself than using a generator and trying to reverse engineer how their coding works:
a simple example would be this:
const {
MessageEmbed
} = require('discord.js')
module.exports = {
name: "rules",
description: "Post rules",
run: async (client, interaction) => {
// build the message
const embed = new MessageEmbed()
.setColor('#00ff00') //change the color if you want
.setTitle('Some Title')
.setDescription(`Some description`)
.addFields({
name: 'Rule Name/Number',
value: 'Rule text',
inline: true
}, {
name: 'Rule Name/Number',
value: `Rule text`,
inline: true
}, {
name: 'Rule Name/Number',
value: 'Rule text',
inline: true
})
// add more if needed
// send the message
interaction.channel.send({
embeds: [embed]
})
// confirm they are sent and complete the interaction only visible to you
return interaction.reply({
content: 'Done',
ephemeral: true
})
}
}

Discord bot not dming, while having all of the intents on

I have a discord bot that is supposed to DM the user anytime they have a moderator action against them. (Getting muted, etc.)
DiscordAPIError: Missing Permissions
I have all of the intents on for the bot and it is only in 2 servers.
Picture Here
This is the code I use to DM, it is in typescript but I basicly use discord.JS documentation and that while writing it due to its simularities.
try {
await user.createDM()
await user.send(`You have been muted for ${reason!}! It will last ${time!} minutes!`)
} catch (error) {
await interaction.reply({
content: `The player was not DMed!`,
ephemeral: true,
});
}
I just relised that I forgot to remove part of the script not shown from the orginial script it was copied from.

Mentioning roles in slash command reply discors.js BOT

I am making a Discord bot using discord js v13.2.0, and I want to reply to an interaction with a mention to an role, but when the interaction is "sent", it not ping the role.
I am just a beginner in code so maybe I do something wrong, I tried looking on the internet but I found nothing.
async execute(interaction, client) {
interaction.reply({
"content": "This is the role mention : <#&roleid>"
})
},
What I have
To allow mentions in interaction you can use allowedMentions:
interaction.reply({
allowedMentions: {roles: ['YOUR_ROLE_ID']},
content: "This is the role mention: <#&roleid>"
})

how can i make my discord.js bot reply to one specific user?

I'm trying to make a discord.js bot that will reply to one user when they type anything into the chat but I'm having trouble defining that user. Here is the code:
bot.on("message", message => {
if (message.content.includes(" ")) {
//the user im trying to target
if (!message.author.user(fuze_fatal1ty.user)) {
message.reply('No');
}
}
});
This is worded poorly, but I think i get it, you would need to check to their id.
bot.on("message", message => {
if(msg.author.id === "THE_USER_ID") {
msg.reply("No");
}
});
Not sure what fuze_fatal1ty.user is supposed to be

Discord js creating discord category

I'm trying to make a category on discord server using Discord Bot but I couldn't find the method or something on internet. Also I looked the "discord.js.org". Then I thought that isn't there any possibility to do that. So is there any way to make a category on discord servers?
discordjs v13 needs GUILD_CATEGORY instead of just "category"
message.guild.channels.create("Name", { type: "GUILD_CATEGORY" });
You need to use the .createChannel method and then enter „category“ as type of the channel
<guild>.createChannel("NAME OF THE CHANNEL", "category")
I would advice the usage of a promise as it adds a lot of functionality and safety to your code
guild.createChannel('new-category', {
type: 'category',
permissionsOverwrites: [{
id: guild.id,
deny: ['MANAGE_MESSAGES'],
allow: ['SEND_MESSAGES']
}]
})
.then(console.log)
.catch(console.error);
This allows you to create the channel with permissions and actually handle any errors like the channel already existing or your bot not being able to create said channel cause of its permissions assigned.
This is the proper way to do this.
Example to create channel
guild.createChannel('new-general', { type: 'text' })
.then(console.log)
.catch(console.error);
v12:
message.guild.channels.create('Category', { type: 'category' });
I have made a command code for you to use. Modify it and use it.
if(message.content === `${prefix}create-channel`) {
message.guild.createChannel('name', {
//Channel type (text || voice || category)
type: 'text',
permissionsOverwrites: [{
id: guild.id,
deny: [],
allow: ['SEND_MESSAGES']
}]
})
.catch(console.error);
}
discordjs v14 needs ChannelType.GuildCategory and the name in the options
message.guild.channels.create({ name: "Name", type: ChannelType.GuildCategory });

Resources