discord.js

Add channel to category by name

白昼怎懂夜的黑 提交于 2020-12-30 07:42:05
问题 var server = message.guild; for (var i = 0; i < server.channels.array().length; i++) { server.channels.array()[i].delete(); } server.createChannel("Text Channels", "category"); server.createChannel('general', "text"); I am trying to make the text channel 'general` go into the category 'Text Channels' All the solutions I have found rely on you knowing the categories id . I was wondering if there is a way I could get the category id , or else move general into "Text Channels" simply by its name

Discord.js ban/kick commands available to all users. How can I fix this?

旧街凉风 提交于 2020-12-30 03:40:26
问题 I'm making my own Discord Bot because I don't trust the bigger ones (Dyno, Hime, NosoBot, etc.) And my bot is pretty much done. The only problem is that my code allows all members to use these commands. I only want people to be able to use the functions they have permissions to. The code works, but how can I make it allow only people with permission to kick/ban? if (msg.content.startsWith("$kick ")) { if (msg.mentions.members.first()) { msg.mentions.members.first.kick().then((member) => { msg

Deleting all messages in discord.js text channel

爷,独闯天下 提交于 2020-12-29 06:39:49
问题 Ok, so I searched for a while, but I couldn't find any information on how to delete all messages in a discord channel. And by all messages I mean every single message ever written in that channel. Any clues? 回答1: Try this async () => { let fetched; do { fetched = await channel.fetchMessages({limit: 100}); message.channel.bulkDelete(fetched); } while(fetched.size >= 2); } 回答2: Discord does not allow bots to delete more than 100 messages, so you can't delete every message in a channel. You can

How to check if a specific user has a role? Discord js

大兔子大兔子 提交于 2020-12-26 08:39:46
问题 I know how to check if the message sender has a role: if(message.member.roles.has(role.id)) { console.log(`Yay, the author of the message has the role!`); } else { console.log(`Nope, noppers, nadda.`); } However, how can I check if specific user (using user id) has a specific role? var authorID = "111111111111111111" //Find role var role = message.guild.roles.find(role => role.name === "Private Splash Ping"); //Find member let member = message.guild.members.get(authorID); console.log(member

How to check if a specific user has a role? Discord js

泪湿孤枕 提交于 2020-12-26 08:39:09
问题 I know how to check if the message sender has a role: if(message.member.roles.has(role.id)) { console.log(`Yay, the author of the message has the role!`); } else { console.log(`Nope, noppers, nadda.`); } However, how can I check if specific user (using user id) has a specific role? var authorID = "111111111111111111" //Find role var role = message.guild.roles.find(role => role.name === "Private Splash Ping"); //Find member let member = message.guild.members.get(authorID); console.log(member

Member count but without bots (Discord.js Javascript)

牧云@^-^@ 提交于 2020-12-15 06:47:07
问题 I'm trying to make my Discord bot update a locked voice channel with the server's member count, but I can't figure out how to make it filter out bots. I've looked online and tried different things but none seem to work for me. Could anyone help? This is my code: let myGuild = client.guilds.cache.get("703315963583528991"); let memberCount = myGuild.members.filter(member => !member.user.bot).size; let memberCountChannel = myGuild.channels.cache.get("704843759078211604"); memberCountChannel

DiscordAPIError: Invalid Form Body when trying to send embeds

流过昼夜 提交于 2020-12-15 05:15:30
问题 This is one of the first commands I wrote whilst I've been learning, and recently it stopped working. I fiddled with it a little, but can't see where the problem comes from. When I run ~userinfo the following error comes up in the console: Unhandled Rejection at: DiscordAPIError: Invalid Form Body embed.footer.icon_url: Not a well formed URL. This is the code for userinfo: if (command === 'userinfo') { var embed = new Discord.RichEmbed() .setTitle('User Info') .addField('Username', message

DiscordAPIError: Invalid Form Body when trying to send embeds

放肆的年华 提交于 2020-12-15 05:15:00
问题 This is one of the first commands I wrote whilst I've been learning, and recently it stopped working. I fiddled with it a little, but can't see where the problem comes from. When I run ~userinfo the following error comes up in the console: Unhandled Rejection at: DiscordAPIError: Invalid Form Body embed.footer.icon_url: Not a well formed URL. This is the code for userinfo: if (command === 'userinfo') { var embed = new Discord.RichEmbed() .setTitle('User Info') .addField('Username', message

Finding who deleted the message

不问归期 提交于 2020-12-15 05:01:44
问题 My discord.js bot is programmed to log deleted messages. I have the code setup, but I was wondering if there was a way to see who deleted it? Thanks. Heres the code: bot.on("messageDelete", (messageDelete) => { let DeleteEmbed = new Discord.RichEmbed() .setTitle("**DELETED MESSAGE**") .setColor("#fc3c3c") .addField("Author", messageDelete.author.tag, true) .addField("Channel", messageDelete.channel, true) .addField("Message", messageDelete.content) .setFooter(`Message ID: ${messageDelete.id}

How can I embed messages using a Discord bot?

佐手、 提交于 2020-12-15 05:01:20
问题 I want to code a bot that will embed a user's sent message in a specific channel. If you know anything about GTA RP servers, it's like a Twitter or Instagram bot. Here's an example: I think it's something about the console.log and the author's name, but I'm not sure so that's why I'm here. How can I embed users' messages like this? 回答1: You can use a MessageEmbed, like programmerRaj said, or use the embed property in MessageOptions: const {MessageEmbed} = require('discord.js') const embed =