discord

Discord.js bot responds when mentioned

ぐ巨炮叔叔 提交于 2021-02-01 05:14:35
问题 I'm trying to make my discord.js bot send a message when it is pinged. I was unsure how to do this so I referred to this code: client.on('message', message => { if (message.content === '<@745648345216712825>') { message.channel.send('Message Here'); } }); However, this doesn't work. Also, is it possible that my bot responds when a person mentions a specific user for example if I am mentioned by the user anywhere in a message the bot responds? If yes, can you show me how to do it? 回答1: Message

Discord Python bot not sending message

倾然丶 夕夏残阳落幕 提交于 2021-01-29 21:20:50
问题 Please don't say "Already answered", cause I tried EVERYTHING, including all related posts here and obviously, reading the api doc. Complete error is: Ignoring exception in on_ready Traceback (most recent call last): File "/usr/local/lib/python3.8/dist-packages/discord/client.py", line 312, in _run_event await coro(*args, **kwargs) File "embbed_shop.py", line 26, in on_ready await channel.send_message(embed=embed) AttributeError: 'NoneType' object has no attribute 'send_message' Here is my

How to get the creator of a channel on event channelCreate in discord.js

断了今生、忘了曾经 提交于 2021-01-29 19:55:40
问题 Would it be possible to find the creator of a channel when the channelCreate event triggers? I've tried looking at the documentation of channels & channelCreate and to log the channel object to my console but there doesn't seem to be a parameter that clearly states "This ID created the channel". I know it has to be somewhere since Discord uses it in the audit logs. 回答1: You can try listening to the channelCreate event and then fetch the GuildAuditLogs with Guild.fetchAuditLogs(). Then you can

Value tallying code dysfunctions when put into discord command

偶尔善良 提交于 2021-01-29 19:08:19
问题 I just coded my bot and basically it sums every user's daily guild XP from the last seven days and prints it in a list into a google sheet. There is one problem and it is that the guild XP values in the list are wrong when manually adding up, which is the guild XP from all seven days from the API JSON. The names it prints are right, but the values are wrong, and I can't tell exactly how they are. This only happens when the code below is run in a discord command, but the code functions

Discord Python bot not sending message

a 夏天 提交于 2021-01-29 18:30:27
问题 Please don't say "Already answered", cause I tried EVERYTHING, including all related posts here and obviously, reading the api doc. Complete error is: Ignoring exception in on_ready Traceback (most recent call last): File "/usr/local/lib/python3.8/dist-packages/discord/client.py", line 312, in _run_event await coro(*args, **kwargs) File "embbed_shop.py", line 26, in on_ready await channel.send_message(embed=embed) AttributeError: 'NoneType' object has no attribute 'send_message' Here is my

Can't use Discord OAuth2 in Electron application

荒凉一梦 提交于 2021-01-29 17:58:14
问题 I'm trying to create an Electron app (using Electron.net and MVC) with user sign-ins using Discord's OAuth2. However when loading up the OAuth2 page, Discord thinks that I'm using a broken installation of Discord. I assume that this is because the Discord desktop application also uses Electron. When not using Electron, the link opens fine. So far I've attempted changing the User-Agent (both in the Electron startup code and directly on the link with Javascript) used by Electron as I believed

Discord.js currency to command handler

非 Y 不嫁゛ 提交于 2021-01-29 17:39:54
问题 I am trying to move all of my currency/shop commands/ Sequelize database into the command handler from index.js (works perfectly in index.js file) but I am running into issues transferring data from the index.js file into the individual command files. Any help on how to properly integrate the index.js commands into the command handler would be greatly appreciated. I realize this is a lot to go through but it would really mean a lot to me if anyone was able to help me out index.js: Reflect

How does Discord connect to third party APIs?

▼魔方 西西 提交于 2021-01-29 17:33:10
问题 I am trying to reproduce something similar in my app. I only see things like OAuth where you can "login" with an external API and a new user will be created/authenticated with their third party credentials. Or alternatively some authorization flow where access tokens must be refreshed every hour or so. Discord, however, connects to these APIs and does not create or login a new user, they only access the user's data from that external API and presents it on the Discord GUI. Furthermore, as a

DiscordAPIError: Unknown role

半世苍凉 提交于 2021-01-29 15:18:21
问题 I was trying to make a command in discord.js in which the bot finds the highest role it can give to a person and gives it to the person. const myrole = message.guild.me.roles.highest.rawPosition const therole = message.guild.roles.cache.find(r => r.rawPosition = myrole-1) const person = message.guild.member(client.users.cache.get("the id")) person.roles.add(therole.id); And I get the following error: (node:18926) UnhandledPromiseRejectionWarning: DiscordAPIError: Unknown Role at

Discord PY Bot, Creating a list from reactions of a specific message

别说谁变了你拦得住时间么 提交于 2021-01-29 14:29:27
问题 I'm creating a bot, and in it there is a command that adds a reaction to a message. I'm wondering how to create a list of all those who clicked on the specific reaction. I have been unsure of the variable(s) to use to retrieve the reactors. @client.command(pass_context=True) @has_permissions(administrator=True) async def reaction(ctx): msg = await ctx.send("**React '✅' to this message to sign up!**") reactions = ['✅'] for emoji in reactions: await msg.add_reaction(emoji) Here is the code of