Skip to content


Triggering method from within a loop with Python and Pycord

I’m playing around with Pycord and trying to send a message to a channel X for each element in an array. The following class will throw a TypeError: MyClient.on_ready() missing 1 required positional argument: ‘message’ indicating that MyClient.on_ready() needs 2 arguments, one for self, one for message, but every example on how to pass arguments to class methods were only

Why I can’t send messages in a @tasks.loop in

I have a problem: I can’t send message in a @tasks.loop() function. When I try to get the channel object with self.client.get_channel(channlid), it return me a Nonetype variable. My code : my error: Can you help me ? Answer Problem You’re calling client.get_channel before the client is ready. So, the client cannot find the channel you’re looking for, and channel

mention user from string(name#discriminator)

I have an user in str format, for example: I want to convert it into a member to be able to do: I tried: and: both make member NoneType, the name and discriminator are fine. Answer If you have both the username and discriminator, the best way to get that member would be like this: ALSO: Make sure you have – Get channel permissions of user

I am trying to create a command that lists the permissions that the user has in the current channel. I have tried using a function that adds permissions to a list and calling it in the command. Unfortunately, this command sends all of the permissions that a member could possibly have, rather than the permissions that the member has currently.

In, is it possible to wait for a variable to change from a different part of the code than the variable changes?

I tried using time.sleep(), but instead of waiting for the variable it paused the whole code, not allowing the variable to change. This is my code: I can’t figure out what to replace time.sleep(1.0) with. Answer You can use await asyncio.sleep(1) instead. Asyncio.sleep works like time.sleep, but it doesn’t block the entire code execution. It stops only one event. Meanwhile, ctx commands not recognised

im fairly new to coding in general and recently started trying to code my own bot. Almost all of the tutorials i have seen use the ctx command however, whenever i use it i get this error: Here is part of my code that uses the ctx command. The aim is to get it to delete the last 3 messages Sending attachments for ‘say’ command

I have a ‘say’ command for my bot where it repeats what the user writes in the command message: I want it to also include the attachments if the user included any, but i can’t seem to get it to work. I keep getting the error: What am i doing wrong? In the docs it says that the ctx.message.attachments