discord.py-rewrite

How to define objects in discord.py rewrite

强颜欢笑 提交于 2020-06-17 00:49:08
问题 As stated in the title, how? I'm really struggling with understanding the documentation as there are no examples of anything. How do I define something like a VoiceState, Member, VoiceChannel, etc... Running on tutorials is fine until you have to start consulting the documentation for something specific, at which point it becomes really frustrating when you have no idea how to define objects or use certain commands... 回答1: A lot of this will come from experience, so don't be discouraged if it

discord.py - Getting all available roles of a guild

为君一笑 提交于 2020-06-01 07:07:14
问题 I notice there is a method for the Guild object for fetching all roles of a guild. My problem is that I cannot install discord.py==1.3.0 using pip. Is there another way to get all the guild's roles in discord.py==1.2.3 ? 回答1: Returns a list of the guild’s roles in hierarchy order. The first element of this list will be the lowest role in the hierarchy. Once you have list of roles you can iterate through it and get its name, id etc. Documentation 回答2: Download it here: https://pypi.org/project

Give and remove roles with a bot, Discord.py

元气小坏坏 提交于 2020-06-01 05:53:10
问题 How do I make a bot in Discord.py that will assign roles present in a role.json file, while using the same command to both remove and add the same role. For example, ?role <rolename> will both add and remove a role, depending on if the user has the role assigned. I'm a bit confused on how to achieve this. My current bot uses ?roleadd <rolename> ?roleremove <rolename> . 回答1: I'm not sure where your role.json file comes into play, but here's how I would implement such a command @bot.command

How a discord bot can join a voice channel in discord rewrite?

匆匆过客 提交于 2020-05-30 07:52:19
问题 I want to make my discord bot to connect to the voice channel I am when I type !join . i have tried to do it with the following code but i got this error: bot: BotInstance of 'Bot' has no 'voice_client_int' memberpylint(no-member) i found that my code is not compatible with the rewrite discord version. @bot.command(pass_context = True) async def join(ctx): channel = ctx.message.author.voice.voice_channel await bot.join_voice_channel(channel) @bot.command(pass_context = True) async def leave

Error decode byte when send image in discord

拜拜、爱过 提交于 2020-04-17 21:41:26
问题 I have some problems with sending images in discord. I decide to use Pillow library for creating images and I want to send image which is created by this library without save . I found out what I can convert Image object to binary data and put in fp argument. But it raised encoding error. Code: image = Image.open("test.png") image_binary = BytesIO() image.save(image_binary, "PNG") image_binary = image_binary.getvalue() await ctx.send(file=discord.File(fp=image_binary)) Error: Traceback (most

Discord.py how to get the snowflake of a user that isn't a member of the server?

烂漫一生 提交于 2020-03-26 04:05:51
问题 username="Testing" BADuser = await bot.fetch_user(username) await ctx.guild.ban(BADuser, reason="Testing", delete_message_days=0) This is the code I'm using. I get this error: command raised an exception: HTTPException: 400 BAD REQUEST (error code: 50035): Invalid Form Body In user_id: Value "Testing" is not snowflake. I don't know how to get the snowflake using only the name and the unique number for each user. Cause the users aren't on the server. Thank you for any help. 回答1: The bot cannot

Discord.py how to get the snowflake of a user that isn't a member of the server?

喜夏-厌秋 提交于 2020-03-26 04:04:19
问题 username="Testing" BADuser = await bot.fetch_user(username) await ctx.guild.ban(BADuser, reason="Testing", delete_message_days=0) This is the code I'm using. I get this error: command raised an exception: HTTPException: 400 BAD REQUEST (error code: 50035): Invalid Form Body In user_id: Value "Testing" is not snowflake. I don't know how to get the snowflake using only the name and the unique number for each user. Cause the users aren't on the server. Thank you for any help. 回答1: The bot cannot

Discord.py: How to pin a post made by a webhook?

|▌冷眼眸甩不掉的悲伤 提交于 2020-03-25 12:59:53
问题 Message= await webhook.send("Test message to pin") await Message.pin() But I get a str in return from webhook.send. How can I get a message type so I'm able to pin it? Thank you in advance. 回答1: If you read the documentation. You will see that you need to add the following parameter: wait=True (when sending through a webhook). This will return the message. If you dont do this it will return None as explained in the doc. Thus what you need to do: Message = await webhook.send("Test message to

Can I safely ignore these errors?

≡放荡痞女 提交于 2020-03-23 08:18:56
问题 @client.event async def on_message_edit(before, after): channel = client.get_channel (649024513614282764) embed=discord.Embed(title="Edited Message", description=f"Message sent by {before.author.mention} ({before.author}) in {before.channel.mention}", color=0xffff00, timestamp=datetime.datetime.now()) embed.add_field(name=f"{before.content}", value=f"{after.content}", inline=False) if channel is None: print("Channel not found") else: await channel.send(embed=embed) When I run the above, it's

Can I safely ignore these errors?

匆匆过客 提交于 2020-03-23 08:17:11
问题 @client.event async def on_message_edit(before, after): channel = client.get_channel (649024513614282764) embed=discord.Embed(title="Edited Message", description=f"Message sent by {before.author.mention} ({before.author}) in {before.channel.mention}", color=0xffff00, timestamp=datetime.datetime.now()) embed.add_field(name=f"{before.content}", value=f"{after.content}", inline=False) if channel is None: print("Channel not found") else: await channel.send(embed=embed) When I run the above, it's