discord.js

Guild is not defined

爱⌒轻易说出口 提交于 2019-12-10 00:45:52
问题 I am currently making a discord.js bot for discord, but i'm getting the same issue all time : ReferenceError: guild is not defined at Client.client.on.message (C:\Users\Valentin\Documents\JsBot_dev\bot.js:27:30) at emitOne (events.js:101:20) at Client.emit (events.js:188:7) at MessageCreateHandler.handle (C:\Users\Valentin\node_modules\discord.js\src\client\websocket\packets\handlers\MessageCreate.js:9:34) at WebSocketPacketManager.handle (C:\Users\Valentin\node_modules\discord.js\src\client

Why messageReactionAdd do nothing discord.js

我与影子孤独终老i 提交于 2019-12-10 00:19:49
问题 I want to say that I am French, and I apologize for the mistakes. I try to code a discord bot with node.js, but i have a problem with messageReactionAdd i don't now why he do nothing when i react with an emoji. My code : bot.on('messageReactionRemove', (reaction, user) => { console.log("that work 1"); if(reaction.emoji.name === "white_check_mark") { console.log("that work 2"); }}) However i see on this forum it will work for others thanks for read ! 回答1: Events messageReactionAdd and

How do I use JSDoc type inference in WebStorm on a module with a dot in it's name? (Discord.js)

旧时模样 提交于 2019-12-08 10:56:31
问题 I'm trying to find a way to work with Discord.js TypeScript annotations using WebStorm's JSDoc type inference in a non-conflicting pattern. Here's what "works"... import Discord from 'discord.js'; /** * @param {Client} client * @param {Collection.<Snowflake, Message>} msgs */ function handleRemoveMessages(client, msgs) {} The problem is with Client, multiple definitions exist. While this works, I'd like to be able to namespace the imported types from the discord.js module into something like

How to show roles of user discord.js / userinfo command

本秂侑毒 提交于 2019-12-08 04:29:53
问题 I'm trying to make a 'userinfo' command, and I'm currently stuck on showing roles of the user. Here's my code: const Discord = module.require('discord.js'); const moment = require('moment'); module.exports.run = async (bot, message, args) => { let user = message.mentions.users.first() || message.author; const joinDiscord = moment(user.createdAt).format('llll'); const joinServer = moment(user.joinedAt).format('llll'); let embed = new Discord.RichEmbed() .setAuthor(user.username + '#' + user

discord.js send scheduled message

ぐ巨炮叔叔 提交于 2019-12-07 22:08:58
问题 Hi I've just started on Javascript and Node.js, so I don't really know what to do. Please be patient with me.Thanks! So I've hosted a node.js on my physical server. I wanted to create a Discord Bot that sends a daily message on specific timings on my server, for example, I want to send a message to a channel saying "Good Morning" everyday at 8am. How do I do it? Currently, I only have this code to ping the bot(and the server) /* A ping pong bot, whenever you send "ping", it replies "pong". */

Displaying all connected users Discord.js

浪尽此生 提交于 2019-12-07 14:37:28
问题 I'm trying to create a timer that polls all connected users with discord.js. My current code is... Bot.on('ready', () => { setInterval (function (){ var u = Bot.users(); console.log(u); }, 10000); }); However, it doesn't work with a error "TypeError: Bot.users is not a function". I'm just not sure how this works. I've also tried... Bot.server.users(); Bot.guilds.users(); 回答1: Looking at https://discord.js.org/#/docs/main/master/class/Client?scrollTo=users, users is an associative array, not a

Discord.js Delete Single Message

牧云@^-^@ 提交于 2019-12-07 13:25:55
问题 I am currently working on creating a Discord bot using Discord.js, and I want to have a command that you can tell it ||say Hello or something and it will delete your comment, then say what you told it to. My current code is client.on('message', message => { if (message.content.startsWith("||say ")) { message.delete(1000); //Supposed to delete message message.channel.send(message.content.slice(5, message.content.length)); } }); But this is not working. 回答1: It turns out that I had the correct

Loop through Snowflake array

时光怂恿深爱的人放手 提交于 2019-12-07 07:41:11
问题 I'm looking for a way to get data from this Collection. The data looks like: '0000000' => GuildMember { guild: Guild { members: [Object], id: '000000', name: 'Zombie', _rawVoiceStates: [Object] }, user: User { id: '0000000', username: 'Orc', _roles: [ '0000' ], nickname: 'Orc', joinedTimestamp: 00000, lastMessageID: null }, '0000000' => GuildMember { guild: Guild { members: [Object], id: '000000', name: 'Zombie', _rawVoiceStates: [Object] }, user: User { id: '0000001', username: 'Orc1',

discord.js send scheduled message

為{幸葍}努か 提交于 2019-12-06 16:05:28
Hi I've just started on Javascript and Node.js, so I don't really know what to do. Please be patient with me.Thanks! So I've hosted a node.js on my physical server. I wanted to create a Discord Bot that sends a daily message on specific timings on my server, for example, I want to send a message to a channel saying "Good Morning" everyday at 8am. How do I do it? Currently, I only have this code to ping the bot(and the server) /* A ping pong bot, whenever you send "ping", it replies "pong". */ // Import the discord.js module const Discord = require('discord.js'); // Create an instance of a

How do I list all Members with a Role In Discord.Js

心不动则不痛 提交于 2019-12-06 15:20:09
问题 How I can list members in a role using Discord.js . My code: client.on("message", message => { var guild = message.guild; let args = message.content.split(" ").slice(1); if (!message.content.startsWith(prefix)) return; if (message.author.bot) return; if(message.content.startsWith(prefix + 'go4-add')) { guild.member(message.mentions.users.first()).addRole('415665311828803584'); } }); How would I go about listing all the members that have the go4 role in an embed. When the message .go4-list is