discord

Discord bot send embed message to another channel

戏子无情 提交于 2019-12-24 17:16:15
问题 I cant figure out how to send a embedded message on a bot from one channel to another although I can figure out how to send my own message to another: @bot.command(pass_context=True) async def tf1(ctx): embed=discord.Embed(title="Test", description="1", color=0x5bcdee) embed.set_footer(text="Test2") await bot.say(discord.Object(id='456277299189383168'), embed=embed) This doesn't seem to work and whenever I send it I get this <discord.object.Object object at 0x03B66BD0> and then the embedded

Select Random xx answer python bot

不羁的心 提交于 2019-12-24 08:38:21
问题 How to make python bot pick a random name. For example if I provide a list of answers. answers = ["apple", "ball", "cat", "dog", "elephant", "frog", "gun"] @bot.command() async def choose(k : int): """Chooses between multiple choices.""" if 0 <= k <= 50: await bot.say("This is your random {} pick".format(k)) embed = discord.Embed(description='\n'.join(random.choices(answers, k=k))) await bot.say(embed=embed) else: await bot.say("Invalid number") 回答1: You can use random.choices (not choice )

Send a message if Wait_For_Message timeout is reached Discord Py

不问归期 提交于 2019-12-24 08:08:39
问题 I'm trying to send a message if the timeout is reached for client.wait_for_message. In this case it's 30 seconds. I used TimeoutError but it doesn't throw any errors or work. try: msg = await client.wait_for_message(timeout= 30, author=message.author, check=check) if msg: await client.send_message(message.channel, "Nice job! {} solved the scramble! The word was {}!".format(message.author.mention, word)) except TimeoutError: await client.send_message(message.channel, "Oops! Nobody solved it.

Send message to specific channel in Discord with JDA

你说的曾经没有我的故事 提交于 2019-12-24 07:57:35
问题 How to ask the bot to send a message to another channel (specific channel) that is not the same as the bot receive command? Let's say bot receives the message !ban @xxx in channel #a and if action is completed, bot sends ban to user @xxx is given to channel #b . code Main.java : import net.dv8tion.jda.core.*; public class Main { private static String token = "NDk0MjI2Mjk2OTY5MjMyMzk0.DowgCA.j0sQHnBV3wm70rzz7Q78rX0NVPU"; public static void main(String[] args) throws Exception{ try { JDA api =

Send message to specific channel in Discord with JDA

三世轮回 提交于 2019-12-24 07:57:24
问题 How to ask the bot to send a message to another channel (specific channel) that is not the same as the bot receive command? Let's say bot receives the message !ban @xxx in channel #a and if action is completed, bot sends ban to user @xxx is given to channel #b . code Main.java : import net.dv8tion.jda.core.*; public class Main { private static String token = "NDk0MjI2Mjk2OTY5MjMyMzk0.DowgCA.j0sQHnBV3wm70rzz7Q78rX0NVPU"; public static void main(String[] args) throws Exception{ try { JDA api =

How do I check if a user is banned or not?

冷暖自知 提交于 2019-12-24 07:40:12
问题 I have managed to make the unban command to work, but now I need to make a condition to avoid errors, and need to put the unban code inside the condition if the user is in the ban list, but I have no idea how and haven't seen anything on internet. 回答1: You can use Guild.fetchBans() to retrieve a Collection of banned users. Keep in mind, this method returns a Promise. You can then use Collection.find() to search through the Collection. Example: // Async context needed for 'await' (meaning this

Schedule Asyncio task to execute every X seconds?

自闭症网瘾萝莉.ら 提交于 2019-12-24 07:26:39
问题 I'm trying to create a python discord bot that will check active members every X seconds, and award members with points for their time online. I'm using asyncio to handle the chat commands and that is all working. My issue is finding a way to schedule this checking of active members every X seconds with async I've read the asnycio documentation but this is my first time working with it and I'm having a hard time wrapping my head around tasks and loops and co routines and etc. @client.event

find the function that save an image when react to on discord

让人想犯罪 __ 提交于 2019-12-24 05:22:09
问题 I am new to building discord bots. So I created a bot, manage to make him talk etc. (I use Python 3.6) I am now trying to copy an image from a channel to send it somewhere else. I can't find the function that checks if I reacted to the image neither the one to save an image. What i want to do is : If an someone reacts to an image with the :white_check_mark: , the bot copies it. If someone already did it and can show it to me would be awesome. Thank you very much. 回答1: There are two ways an

Discord bot responds multiple times for one event

為{幸葍}努か 提交于 2019-12-24 01:58:14
问题 I want my bot to respond once to a command such as .on . However, it responds multiple times per input: The code is: client.on('message', message =>{ if(message.content === '.on'){ message.channel.sendMessage('Testing Bot is now Online, Greetings, ' + message.author.username); } If anyone could point me in the right direction to make the bot respond once that would be great. 回答1: sendMessage is deprecated. Try using send instead. client.on('message', message => { if(message.content === '.on')

How do I get the User ID of a discord user using discord.py

自作多情 提交于 2019-12-23 03:42:19
问题 Im using Discord.py and Im trying to get the Discord userid of a user when they type into a channel. The userid can be found when you go into developer mode, and right click on a username, there will be an option "copy id". The current api is not saying how to do this, or I keep missing it 回答1: The documentation says that the User class have the user's id: http://discordpy.readthedocs.io/en/latest/api.html#user And that Member is a subclass of User : http://discordpy.readthedocs.io/en/latest