discord.js

How to list all members from a specific server?

邮差的信 提交于 2021-02-10 09:36:11
问题 My code is const list = client.guilds.find("id", "335507048017952771") for (user of list.users){ console.log(user[1].username); } This does literally nothing. There is no error or anything. I just want the bot to find a server and then log all members from said server. Displaying all connected users Discord.js The answers in this question didn't really help me at all. I did try using message.guild.users but that also did nothing. Can't seem to find anything on the Discord.js site to help me

Bot mention as a prefix in Discord.js

混江龙づ霸主 提交于 2021-02-10 07:06:51
问题 My prefix only works if I do not add spaces to the entire command, example: { "token": "", "prefix": "<@453463055741747200>" } const Discord = require("discord.js"); module.exports.run = async (bot, message, args) => { let something = args.join(" "); message.delete().catch(); message.channel.send(something); } module.exports.help = { name: "say" } Let's say my bot name is MyBot , the above code would only work with @MyBot say this, how can I make it work when the command is @MyBot say this?

Bot mention as a prefix in Discord.js

最后都变了- 提交于 2021-02-10 07:06:12
问题 My prefix only works if I do not add spaces to the entire command, example: { "token": "", "prefix": "<@453463055741747200>" } const Discord = require("discord.js"); module.exports.run = async (bot, message, args) => { let something = args.join(" "); message.delete().catch(); message.channel.send(something); } module.exports.help = { name: "say" } Let's say my bot name is MyBot , the above code would only work with @MyBot say this, how can I make it work when the command is @MyBot say this?

discord.js v12: How do I await for messages in a DM channel?

江枫思渺然 提交于 2021-02-09 09:13:14
问题 This is the code that I've tried: message.author.dmChannel.awaitMessages(msg => { console.log(msg.content) }); But it returns this error message: TypeError: Cannot read property 'awaitMessages' of null Updated Code: message.author.send("What is your name?") const filter = m => m.author.id === message.author.id message.author.dmChannel.awaitMessages(filter) .then((collected) => console.log(collected.first().content)) 回答1: You're not using awaitMessages() properly, you need to pass a filter

User connected to voice channel?

本小妞迷上赌 提交于 2021-02-08 11:19:31
问题 I want to know is it possible to know if any member is connected to a specific voice channel in discord.js v12.2.0. I've been sticking in this question in recent days. Please tell me if you have any clues on it. 回答1: I am not sure if you want to know if the member is connected to a VoiceChannel or listen to the voiceStateUpdate event so I'll cover both cases. Checking if the member is connected to a VoiceChannel const Guild = client.guilds.cache.get("GuildID"); // Getting the guild. const

discord.js trying to create a random outcome command with 2 arrays

佐手、 提交于 2021-02-08 09:55:46
问题 I've been working on my discord bot for a while now and it has a mine command feature but only has one outcome gives the user 20 silver and a simple message but I want multiple answers the bot can give and different amounts of silver. I've tried to use the 'dl.AddXp' and the message in one array but it just gives off a error. if (command === "mine") { var rando_choice = [ dl.AddXp(message.author.id, -20), dl.AddXp(message.author.id, 50), dl.AddXp(message.author.id, -10) ] var rando_choice2 =

discord.js trying to create a random outcome command with 2 arrays

試著忘記壹切 提交于 2021-02-08 09:55:13
问题 I've been working on my discord bot for a while now and it has a mine command feature but only has one outcome gives the user 20 silver and a simple message but I want multiple answers the bot can give and different amounts of silver. I've tried to use the 'dl.AddXp' and the message in one array but it just gives off a error. if (command === "mine") { var rando_choice = [ dl.AddXp(message.author.id, -20), dl.AddXp(message.author.id, 50), dl.AddXp(message.author.id, -10) ] var rando_choice2 =

Returning promise value from function [duplicate]

对着背影说爱祢 提交于 2021-02-08 05:49:26
问题 This question already has answers here : How do I return the response from an asynchronous call? (42 answers) Closed 9 months ago . I am trying to make this recursive function return a promise value, I don't know how to go about doing it, I have tried writing it in different ways but they all ended up with search being undefined public search(message: Message) { let search: string; const filter = (msg: Message) => msg.author.id === message.author.id; message.channel.send('Enter search term')

Discord.js message.react fails when adding specific unicode emotes

和自甴很熟 提交于 2021-02-08 05:10:19
问题 Yesterday I started coding a bot using the guide from discord.js. The core is just with what you finish the Command Handler part with. I was working on a voting command, where the bot would react with Unicode symbols like :one: :two: :three:. This is where I encounter my problem. Using: module.exports = { name: 'testing', description: 'creates a reaction', aliases: ['test'], cooldown: 1, execute(message, args) { if (!args.length) { message.react(':one:'); } } }; Gives me a DiscordAPIError:

Discord.js message.react fails when adding specific unicode emotes

我只是一个虾纸丫 提交于 2021-02-08 05:09:40
问题 Yesterday I started coding a bot using the guide from discord.js. The core is just with what you finish the Command Handler part with. I was working on a voting command, where the bot would react with Unicode symbols like :one: :two: :three:. This is where I encounter my problem. Using: module.exports = { name: 'testing', description: 'creates a reaction', aliases: ['test'], cooldown: 1, execute(message, args) { if (!args.length) { message.react(':one:'); } } }; Gives me a DiscordAPIError: