discord.js

Send message to specific channel with typescript

試著忘記壹切 提交于 2019-12-06 11:19:00
I want to send a greeting message to an "welcome" text channel, whenever a new user joins the server (guild). The problem I'm facing is that, when I find the wanted channel, I will receive the channel with the type GuildChannel . Since GuildChannel has no send() function, I'm not able to send the message. But I can't find a way to find the TextChannel , so I'm stuck here. How can I get to the TextChannel so that I'm able to use the send() message? Below the code I'm using by now: // Get the log channel (change to your liking) const logChannel = guild.channels.find(123456); if (!logChannel)

Collecting users who reacted to a message using discord.js

人走茶凉 提交于 2019-12-06 08:09:19
I'm trying to collect all users that have reacted to certain message. My code client.on('messageReactionAdd', (reaction, user) => { if(reaction.emoji.name === "✅") { console.log(reaction.emoji.users); } But it returns undefined. If I use "reaction.emoji" it returns ReactionEmoji { reaction: MessageReaction { message: Message { channel: [Object], id: '371695165498458115', type: 'DEFAULT', content: 'bb', author: [Object], member: [Object], pinned: false, tts: false, nonce: '371695172469129216', system: false, embeds: [], attachments: Collection {}, createdTimestamp: 1508689433217,

How to edit message according to reaction in Discord.js (create a list and switch page)

一个人想着一个人 提交于 2019-12-06 06:34:53
问题 I want my Discord bot to sent a message and then edit it when people react (for example creating a list, and clicking on the right or left arrow will edit the messages and show the next/previous part of the list). Example: before reaction: after reaction: 回答1: How to handle a message reaction? There is 3 ways to react to a message reaction: Using the function awaitReactions (promise based) Using a ReactionCollector Using the messageReactionAdd event The Difference: messageReactionAdd is an

Embed message doesn't update

久未见 提交于 2019-12-06 02:08:40
I want to make a vote with an embed message. When someone adds a reaction, I want to add a like and to show the number of likes in the embed. Here an example: Whenever someone clicks on like, all my code lines work and I finally change the Field value linked to like just like that : messageReaction.message.embeds[0].fields[0] = "Some much like"; But the embed message doesn't update. I've tried to update the message with this: function doAfakeEdit(message){ message.edit(message.content); } It still keeps the old value of the field. What should I do? Blundering Philosopher I wonder if your

Displaying all connected users Discord.js

流过昼夜 提交于 2019-12-06 00:49:12
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(); Looking at https://discord.js.org/#/docs/main/master/class/Client?scrollTo=users , users is an associative array, not a function. Try: Bot.on('ready', () => { setInterval (function (){ var u, user; for(u in Bot.users){ user =

DeprecationWarning: Collection#find: pass a function instead

最后都变了- 提交于 2019-12-05 20:22:52
问题 I'm quite a newbie to node.js and I'm currently using discord.js to make a Discord bot. As soon as any bot command gets used the console prints a DeprecationWarning. for example: (node:15656) DeprecationWarning: Collection#find: pass a function instead (node:15656) sometimes is another number, nearly always changing. This is what my code looks like (only one command, I've got multiple, I get this error with all of them though): const botconfig = require("./botconfig.json") const Discord =

Loop through Snowflake array

允我心安 提交于 2019-12-05 16:32:20
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', _roles: [ '0000' ], nickname: 'Orc', joinedTimestamp: 00000, lastMessageID: null }, _array: null, _keyArray:

How do I get a bot to mention a channel?

妖精的绣舞 提交于 2019-12-05 14:41:35
I am making a welcome message but I can’t seem to make it say the rule channel. I want the bot to say #rules and make it so you can click it to go to the rules channel. I know you can do this with a normal user, but I want to do it with my bot. Every time I try, it can’t be clicked like a normal player. I’ve tried doing #rules, <#channelID>, and other stuff. None of them are clickable. You need to send a GuildChannel for the channel name to be clickable. You can achieve this by finding the channel in guild.channels This returns a Collection, which you can filter. If you have an ID (easier):

Discord.js - Deleting all channels in a server

巧了我就是萌 提交于 2019-12-05 08:52:39
问题 I'm making a bot that auto-sets up a server, and I was wondering how to delete all channels and categories in a server. Thanks, Codingpro 回答1: The code is very simple: message.guild.channels.forEach(channel => channel.delete()) That should do it. Remember to use this in response of a message, or message will be undefined 回答2: You can run a loop for every single channel in the server (Categories are considered as channels too) //This goes in Client.on('ready', ...); var server = Client.guilds

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

╄→гoц情女王★ 提交于 2019-12-04 21:41:36
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 entered in a channel I would like the bot to respond with the embed. <Role>.members returns a