I am writing a small message logging program, I want the bot to only log messages from a specific Guild and for that, I check for the message.guild.id. This, however, raises a problem when there is a message sent in a DM Channel. I want the bot to ignore the Dm channel completely but I did not have much luck
Tag: discord.py
Discord.py REWRITE – How to make a Guild Invite
I am trying to make my bot create an invite This gives an error ‘bot’ object has no Attribute ‘create_invite’ I am using the Discord.py Rewrite. Thanks in advance! Answer You’ll need to specify what you’re making the invite for, because the bot doesn’t currently have a target for the invite: References: TextChannel.create_invite() abc.GuildChannel – The general target that’s needed
discord.py : Sort message ID in a JSON file by user
I’m currently in the process of making a kind of ticket system. I want to do that through a reaction. When a user clicks on the reaction, a message is sent to a specific channel. This message ID is saved in a JSON file and should be assigned to the user who clicked on the reaction. But if I save
Discord.py async function does not give any output and does not do anything
here is the code: I have no clue what is happening as there is quite literally no error or output of any sort in the console. does anyone know the problem? Answer If you’re not familiar with asynchronous functions, they need to be awaited. Examples of coroutines can be seen in msg.edit(…, as edit() is a coroutine, therefore you need
Can’t open and write a file twice in a command in discord.py
I want to open a json file, to safe things in there and after a few seconds I want to delete that again. I asked already in dpy support. They said, I can’t open a file in write mode. But how can I open the file anyway? Or how can I get out of this write mode? I tried this:
discord.py emoji all servers bot in
I have a bot that sends embeds that include emojis specific to each embed and it works great on my test server where I uploaded the emojis but they don’t show up on other servers since those servers don’t have the custom emoji. using: works of course for the server it’s in but is there a way to get and
How to get a user’s avatar with their id in discord.py?
I tried using the following code but it didn’t work. Edit: For anyone that had a similar problem, while not mentioned in the docs, discord.Member can take user ids aside from @username so there isn’t any need for a complicated way. Answer I’m presuming you’re Tagging the user with @UserNameHere in discord. It’s much easier to take that input as
How to receive and send message to specific channel in Discord.py?
Yesterday I was working on something simple where a bot on command of !name Barty would print back Hello Barty However the problem I am facing at this moment is that the bot would response to any channel where I do use the !name XXXX and what I am trying to do is that I want only to react to
Which method is the best for starting the bot in discord.py? login() and connect() vs start() vs run()
So, to connect the bot to discord.py, there are several methods: discord.Client().login() + discord.Client().connect() discord.Client().start() discord.Client().run() What is the difference between them and which one is the best for running the bot? Answer I believe the official documentation is very clear: start() is shorthand coroutine for login() + connect(). run() is a blocking call which means that This function must
Discord.py (rewrite): Error Handling “Improper Token” In Function
I feel like I’m missing a simple way to solve this problem, but I can’t seem to find a way to handle the discord.errors.LoginFailure: Improper token has been passed. error. What I’m trying to do is run a function that essentially runs a bot and repeats itself if it comes across any errors (with try: and except:) and if it