discord.py

Discord.py Python File not running, multiple errors

纵饮孤独 提交于 2021-02-11 15:04:23
问题 I'm pretty new to coding Discord bots on my Mac instead of a Windows, and ran into trouble trying to run my Python file. I run my Python files with Visual Studio Code and the Python extension by Microsoft. I click the green play icon in the top right corner, and VSC runs it in the terminal for me. This usually works on a Windows, but for some reason, I get a ton of errors when I try to run mine. These are the errors: mika@Mikas-Air python-test % /Library/Frameworks/Python.framework/Versions/3

How check on_message if message has emoji for discord py?

爷,独闯天下 提交于 2021-02-11 14:44:56
问题 I'm fairly new at using python and I'm trying to code a discord bot with basics functions, and I want for one of them to be that after someone uses a prefix if they post an emoji that the bot replies with the url of the emoji, but I have trouble trying to make it work. I don't know how to use on_message to check if a message contains an emoji. Could anyone help me? Thanks. #if message.content[0] == "!" and message.content[1:4] == " <:": #print(message.content[4:-1]) #emoji_name = "" #for i in

Discord.py> How to schedule a operation? i tried using schedule

泪湿孤枕 提交于 2021-02-11 14:13:03
问题 I'm trying to schedule a operation every 30 minutes. But this code isn't working. def Advice(): print("30 minutes") @client.event async def on_ready(): schedule.every(30).minutes.do(Advice) Can you please help me? 回答1: This might be what you're looking for. Here's an example for you. class Heartbeat(commands.Cog): def __init__(self, bot): self.bot = bot self.heartbeat.start() def cog_unload(self): self.heartbeat.stop() @tasks.loop(seconds=45) async def heartbeat(self): if not self.bot.debug:

Discord Python Rewrite - Account Generator

蓝咒 提交于 2021-02-11 13:36:27
问题 I Want to make a discord account generator using python and json, i can make it gen but i cant make it delete the account after genned, please help. The code: @client.command() async def gentest(ctx): genembed = discord.Embed( title="Minecraft NFA", colour=discord.Color.green() ) with open('alts.json', 'r') as f: alts = json.load(f) genembed.add_field(name="Account:", value=random.choice(alts), inline=False) with open('alts.json', 'w') as f: alts = alts.pop(alts) await ctx.author.send(embed

Discord py more than one tasks.loop at the same time?

柔情痞子 提交于 2021-02-11 13:30:49
问题 How can I have more than one loop running ate the same time using the same function but using different parameters like: @tasks.loop(seconds = 10) async def loop(name): Print(name) loop.start("Jon") loop.start("Joseph") Is this how u pass parameters to loops? 回答1: You need to create a new Loop object for each loop. You can do this by using regular function calling repeatedly instead of the decorator: async def loop(name): print(name) names = ["Jon", "Joseph"] loops = {name: tasks.loop(seconds

Discord py more than one tasks.loop at the same time?

房东的猫 提交于 2021-02-11 13:30:39
问题 How can I have more than one loop running ate the same time using the same function but using different parameters like: @tasks.loop(seconds = 10) async def loop(name): Print(name) loop.start("Jon") loop.start("Joseph") Is this how u pass parameters to loops? 回答1: You need to create a new Loop object for each loop. You can do this by using regular function calling repeatedly instead of the decorator: async def loop(name): print(name) names = ["Jon", "Joseph"] loops = {name: tasks.loop(seconds

How to convert a string to a user discord.py

可紊 提交于 2021-02-11 13:23:33
问题 I'm trying to convert a string to a user so I can dm them. Here's my current code: @bot.command(pass_context=True) async def partnerwarn(ctx): file_names = glob.glob("p*") for file in file_names: f = open(file, 'r') content = f.read() f.close() member = file[1:] await bot.send_message(member : discord.User, "You've had under 7 partners! This is a warning, please make sure you actively partner!") print("Warned!") await bot.reply("**" + file[1:] + " was warned!**") It doesn't work because

Discord.py user.block/user.send_friend_request: Error 403/Forbidden How do I give the bot permission to send friend requests and block users?

[亡魂溺海] 提交于 2021-02-11 12:50:12
问题 I'm currently trying to create a block user and send friend request command. However, I've hit a wall. It seems like the bot doesn't have permission or authorization to my account so it can't send friend requests or block users. How do I give it the permissions? Or maybe it isn't possible at all? Please let me know, I'd really appreciate it :> My current code for the commands is below: @client.command() async def unfriend(ctx, *, user: discord.User): await user.remove_friend() await ctx.send(

How to fix “discord.errors.ClientException: Command kick is already registered.” error?

不打扰是莪最后的温柔 提交于 2021-02-11 12:40:26
问题 I'm making a discord bot in discord.py that kicks any member that sends a certain string, but I get the error "discord.errors.ClientException: Command kick is already registered." bot = commands.Bot(command_prefix=',') @client.event async def on_message(message): if message.author == client.user: return if "kick me"in message.content: @bot.command(name="kick", pass_context=True) @has_permissions(kick_members=True) async def _kick(ctx, member: Member): await bot.kick(member) Instead of kicking

How to fix “discord.errors.ClientException: Command kick is already registered.” error?

为君一笑 提交于 2021-02-11 12:40:16
问题 I'm making a discord bot in discord.py that kicks any member that sends a certain string, but I get the error "discord.errors.ClientException: Command kick is already registered." bot = commands.Bot(command_prefix=',') @client.event async def on_message(message): if message.author == client.user: return if "kick me"in message.content: @bot.command(name="kick", pass_context=True) @has_permissions(kick_members=True) async def _kick(ctx, member: Member): await bot.kick(member) Instead of kicking