discord

How to get the ID of a mentioned User in Python discord bot?

谁说胖子不能爱 提交于 2019-12-11 14:43:53
问题 So I was programming a discord bot in python. But there is a problem. I know how to mention the user who sent the message. But how do I get the ID of a user that is mentioned by the author in the message? I couldn't get the answer. 回答1: You can get the user(s) that were mentioned in a message using message.mentions (async rewrite) From there, you can either get the ID from the Member object, or get a formatted mention from those objects message.mentions[0].id message.mentions[0].mention 回答2:

Send a pm from discord.py rewrite

假如想象 提交于 2019-12-11 10:48:05
问题 I'm trying to figure out how to send a pm from a discord.py rewrite bot. I can't do ctx.author.send("context") because it messaging someone other than the author of the message. here's the code that I have so far when I'm searching for a user it always comes with the value of NONE @bot.command() async def spam(ctx, author, message, amount): print(author) print(ctx.author) victim = bot.get_user(author) print(victim) if not (victim == None): for i in range(int(amount)): await victim.send

I'm trying to send data from a cell range to a discord chat channel

我怕爱的太早我们不能终老 提交于 2019-12-11 10:24:51
问题 I'm trying to send data from a range of cells to a discord text channel. I have the webhook working. However, I can't seem to convert the cell data in the "message = messager" part of the code. function postMessageToDiscord(message) { var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheetByName("Loot"); var range = sheet.getRange("A12:N12"); message = message || "range" ; var discordUrl = 'https://discordapp.com/api/webhooks/565294544682221617/l_mER5nwxITlaW

When running bot sample code, I get this error

♀尐吖头ヾ 提交于 2019-12-11 09:48:05
问题 My code is exactly This (With my token of course) When I run it, my bot starts up as normal, but when a new person is added to the server, i get this. ------ Ignoring exception in on_member_join Traceback (most recent call last): File "C:\Users\USRNAME\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\client.py", line 307, in _run_event yield from getattr(self, event)(*args, **kwargs) File "test.py", line 9, in on_member_join await client.send_message(server, fmt.format(member,

Discord.py get message from DM

吃可爱长大的小学妹 提交于 2019-12-11 08:46:10
问题 I try to make my bot to get message from DM using this syntax: for wolf in wolf_list_id: poll_message = await self.client.get_message(wolf, react_message.id) The wolf contains the id of user, but the get_message syntax can't take the id from wolf. Any ideas? 回答1: like said the doc, the client.get_message methods must take as parameter an channel object and an id. In case of DM channel, you can pass an user or member object. For get an user by id, you can use client.get_user_info methods: user

How to send a message with discord.py without a command

六眼飞鱼酱① 提交于 2019-12-11 08:38:44
问题 import discord import asyncio client = discord.Client() @client.event async def on_ready(): print("I'm ready.") async def send(message): await client.send_message(client.get_channel("412678093006831617"), message) client.run("token") loop = asyncio.get_event_loop() loop.run_until_complete(send("hello")) Hi, i want to make a GUI. When someone put in his name and press "OK" my discord bot should send a message. Basically i thought i call the async by it's name, didn't work. Then i made a event

Command Case Insensitve

不问归期 提交于 2019-12-11 08:04:22
问题 How to make below command to work if members use below command in lower or upper or mixing. If members use ping it works. but if members use Ping it not works. @bot.event async def on_message(message): message.content = message.content.lower() await bot.process_commands(message) @bot.command(pass_context=True) async def ping(ctx): msg = 'Pong {0.author.mention}'.format(ctx.message) await bot.say(msg) Update: above on_message is working correctly in single file but i splitted main file to

How would I make my Python 3.6.1 Discord bot create a new text channel in a server?

陌路散爱 提交于 2019-12-11 06:26:37
问题 I have been reading the documentation. The documentation shows this example: channel = await guild.create_text_channel('cool-channel') I need to figure out what to do with guild so that there is no NameError regarding guild . (Do I have to import guild ? etc.) Documentations: http://discordpy.readthedocs.io/en/rewrite/api.html#discord.Guild.create_text_channel http://discordpy.readthedocs.io/en/rewrite/api.html#guild 回答1: If you are using the rewrite branch, to create a text channel you would

How to use commands only when a current command is triggered?

六眼飞鱼酱① 提交于 2019-12-11 05:59:31
问题 This question might be complicated and my brain can't really explain it well so please bare with this crappy explanation, My question, When you trigger a command for example .start it will start let's say a text based game, of course you would have the commands to be able to actually play the game however my concern is people can still trigger the ingame commands without needing to start the game for example . if message.content.startswith("/play"): #Here is the play command where you execute

Sending a message the first channel with discord.js

耗尽温柔 提交于 2019-12-11 05:19:32
问题 I've seen a lot of bots that have a greeting message when they join. Its usually sent to the first channel of the server. For example: bot joins the guild Bot: Hey! Thanks for inviting me! The code i have right now is really simple: client.on("guildCreate", guild => { the code goes here }); I dont know how to send a message to a random (first) channel though. If anyone could please tell me how the other bots do it I would be really greatful. 回答1: I'm using Discord.js version 11.4.2, and I was