discord.py

How to retrieve a specific message by ID (tried fetch_message(id))

痴心易碎 提交于 2020-08-20 11:32:10
问题 @client.command() async def edit(ctx, message_id, *, new_message) : channel, chan, guild = None, list_channels("saved_channels.csv"), ctx.guild.id message = await fetch_message(message_id) await message.edit(new_message) embed=discord.Embed(color=0x00ca1f) embed.add_field(name="Success :white_check_mark:", value=f"Le message a bien été édité dans {message.channel.mention}", inline=False) await ctx.send(embed = embed) I'm trying to edit a specific message my bot sent in another channel by

Discord.py-rewrite wait_for() how do i use?

青春壹個敷衍的年華 提交于 2020-08-19 12:59:52
问题 I can not really use wait_if () the way I want it, can anyone explain how to use wait_for ('message') and wait_for ('reaction') , only by the user of the command? (message translated by Google Translate, forgive me for any error...) 回答1: wait_for takes a check argument that is a function that takes the arguments of the event you're waiting for and determines whether or not that is the event you're waiting for. For example, the on_message event takes a message argument, so if we wanted to

Discord Music bot VoiceClient' object has no attribute 'create_ytdl_player'

梦想的初衷 提交于 2020-08-19 10:44:11
问题 I wanted to programm my own discord bot, which plays some songs from youtube but it wont create the ydl player this is the error Command raised an exception: AttributeError: 'VoiceClient' object has no attribute 'create_ytdl_player' and this is my code. Thanks in advance. @client.command(pass_context=True) async def s(ctx): user=ctx.message.author voicech = ctx.author.voice.channel voice = await voicech.connect() player = await voice.create_ytdl_player("some url") player = await vc.create

I have a error in discord.py (purge command)

我们两清 提交于 2020-08-10 23:10:56
问题 I have this Python code for discord.py rewrite: @bot.command(pass_context=True) async def clean(ctx): if ctx.author.guild_permissions.administrator: llimit = ctx.message.content[10:].strip() await ctx.channel.purge(limit=llimit) await ctx.send('Cleared by <@{.author.id}>'.format(ctx)) await ctx.message.delete() else: await ctx.send("You cant do that!") But every time i get this error: discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: '<=' not supported

How to store server and user ids in json file with discord.py

十年热恋 提交于 2020-08-10 20:31:02
问题 Yo, so I'm trying to give the bot I'm building more useful configuration per server. But I use channel name right now because I don't know how to automatically get all server and channel ids and store them in a json. My question is, how would i use json to implement a guild config and make the bot automatically fill out the ids of each guild and channel it is in so as to code my bot to use that to set up the channels the bot uses? My bot is built using discord.py rewrite if it helps. --EDIT--

How to store server and user ids in json file with discord.py

主宰稳场 提交于 2020-08-10 20:28:16
问题 Yo, so I'm trying to give the bot I'm building more useful configuration per server. But I use channel name right now because I don't know how to automatically get all server and channel ids and store them in a json. My question is, how would i use json to implement a guild config and make the bot automatically fill out the ids of each guild and channel it is in so as to code my bot to use that to set up the channels the bot uses? My bot is built using discord.py rewrite if it helps. --EDIT--

How to make the embed change when a user reacts on the message in discord.py rewrite?

£可爱£侵袭症+ 提交于 2020-08-10 20:23:26
问题 How do I make the embed description change when a user reacts with ▶ or ◀ ? This is the code I currently am using, - @client.command(aliases=['commands', 'info', 'cmds']) async def help(ctx): embed1 = discord.Embed(title=f"Everyone/Fun Commands-",description=f"```!vx userinfo [Member]```\n" f"**- Shows the info of the user mentioned.**\n\n" f"```!vx ping```\n" f"**- Shows the ping of the bot.**\n\n" f"```!vx help```\n" f"**- Shows a list of all commands.**\n\n" f"```!vx avatar [Member]```\n"

How to loop a function using Discord.py

不打扰是莪最后的温柔 提交于 2020-08-10 20:13:24
问题 My goal is to "toggle" a loop when a function is called inside of a cog. I want the function to take the argument of a filename. The function will print the line it has read from a txt file. I want this to loop until I call another function that cancels it. Discord py uses async, I just do not know how to operate a loop within a function. Example: class Looptest: def __init__(self, client): self.client = client #This is responsible for playing the loop. async def play_loop(self, filename):

discord bot waiting for message

不羁岁月 提交于 2020-08-10 19:08:07
问题 So as the title suggests I'm trying to make my bot respond to a certain message. So after a user sends an image, it'll respond with a compliment, then if the user RESPONDS TO THAT MESSAGE with a message such as "thanks" the bot will then go on to respond with a different message, but I'm trying to make it respond to multiple versions of "thanks" using if statements. This is the code so far: if '.png' in message.content or '.jpg' in message.content or '.jpeg' in message.content: await bot.send

How to use command name with spaces?

老子叫甜甜 提交于 2020-08-10 04:58:29
问题 How to make bot works when there is a space between commands in python bot. I know we can do that using sub-command or on_message but is there any another option to do that for only selected commands not for all commands. The following code will not work. @bot.command(pass_context=True) async def mobile phones(ctx): msg = "Pong. {0.author.mention}".format(ctx.message) await bot.say(msg) So I tried using alias but still it won't working. @bot.command(pass_context=True, aliases=['mobile phones'