discord.py

Catching CommandOnCooldown Error

不羁岁月 提交于 2021-02-04 19:47:45
问题 I am making a discord bot that has a cooldown and I am attempting to make an event that when the CommandOnCooldown Error occurs, the bot will DM them how much longer they have to wait. Here is my code and it all looks okay, but it doesn't know what retry_after means: @bot.event async def on_CommandOnCooldown(): await bot.send_message(ctx.message.channel, 'You are on cooldown. Try again in {:.2f}s'.format(retry_after)) @bot.command(pass_context = True) @commands.cooldown(1, 30, commands

Mass DM bot was working fine and now it wont send messages

丶灬走出姿态 提交于 2021-02-04 08:29:07
问题 i coded a MassDM bot with a guy called Diggy (from this community) few months ago, for a guild that I and some friends run on BlackDesert Online. It was working just fine till October 28th when stopped sending the DMs. At the begining it just sent the DM to some members that had the specified role (3 out of 105) and now that I updated dicord.py, it sends the message to no one (and sometimes to just one of them, or two... is kinda random)... There are 105 users in that discord server with the

on_member_join and remove dont work. How to make it work?

六眼飞鱼酱① 提交于 2021-02-02 03:47:06
问题 I don't know why but those 2 commands don't work for me. @client.event async def on_member_join(member): ver_Channel = client.get_channel(799666119787020289) await ver_Channel.send(member+ " have joined the server!") @client.event async def on_member_remove(member): ver_Channel = client.get_channel(799666119787020289) await ver_Channel.send(member + " have been left :(") btw please write in basic coding explanation I'm a beginner 回答1: I'm pretty sure this is an intents issue, you should

on_member_join and remove dont work. How to make it work?

£可爱£侵袭症+ 提交于 2021-02-02 03:46:28
问题 I don't know why but those 2 commands don't work for me. @client.event async def on_member_join(member): ver_Channel = client.get_channel(799666119787020289) await ver_Channel.send(member+ " have joined the server!") @client.event async def on_member_remove(member): ver_Channel = client.get_channel(799666119787020289) await ver_Channel.send(member + " have been left :(") btw please write in basic coding explanation I'm a beginner 回答1: I'm pretty sure this is an intents issue, you should

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

how to play gtts mp3 file in discord voice channel the user is in (discord.py)

可紊 提交于 2021-01-29 16:52:33
问题 Like the title I need to play a gtts file into a voice channel what is the easiest way to do this? I am using python 3.7. Here is my code so far: @client.command(name="repeat") async def repeat(context): import gtts, ffmpeg from discord.ext import commands # grab the user who sent the command user = context.message.author voice_channel = user.voice.voice_channel channel = None # only play music if user is in a voice channel if voice_channel != None: await ctx.send(f"What do you want to say,

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

Error on music discord bot in python 'NoneType' object has no attribute 'create_ytdl_player'

孤者浪人 提交于 2021-01-29 14:21:46
问题 When ever i run this code: @client.command(pass_context=True) async def ranjaplay(ctx, url): server = ctx.message.server voice_client = client.voice_client_in(server) player = await voice_client.create_ytdl_player(url) players[server.id] = player player.start() it returns with this error: Traceback (most recent call last): File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site- packages\discord\ext\commands\bot.py", line 846, in process_commands yield from command.invoke(ctx)

Discord.py - passing an argument role functions

纵饮孤独 提交于 2021-01-29 13:51:56
问题 I wanted to create a command, like !iknow @user . A normal verification bot I think. Here's my code, I only pasted the important parts: import discord from discord.ext import commands @client.command(pass_context=True) async def iknow(ctx, arg): await ctx.send(arg) unknownrole = discord.utils.get(ctx.guild.roles, name = "Unknown") await client.remove_roles(arg, unknownrole) knownrole = discord.utils.get(ctx.guild.roles, name = "Verified") await client.add_roles(arg, knownrole) (The Unknown

Value tallying code dysfunctions when put into discord command

删除回忆录丶 提交于 2021-01-29 13:51:01
问题 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