discord.py Dictionary of all roles

Advertisements I’d like to create a dictionary with all roles of a guild for easier use in development: roles_dictionary = {‘role1′: discord.utils.get(guild.roles, name=’role1′) } etc. I’d like to always be able to access any role using: roles_dictionary[‘role1′] I already tried putting it into the on_ready() function, however it seems as if you shouldn’t do stuff… Read More discord.py Dictionary of all roles

Discord.py recognizing on_message client event, but IF statements not responding

Advertisements I am working on a Discord bot and in this case want the bot to roll a 6 sided die when any user gives the "roll" command. See code below. Oddly enough this was working just fine, but now the print(worked) triggers and the if p_message statements do nothing. I get no errors, it… Read More Discord.py recognizing on_message client event, but IF statements not responding

Discord.py 2.0.0 voice chat disconnection problem

Advertisements @commands.command(name="disconnect") async def _disconnect(self, ctx): voice_state = ctx.author.voice if voice_state is None: return for voice_client in ctx.bot.voice_clients: if voice_client.channel == ctx.author.voice.channel: await voice_client.disconnect() print("disconnected") The code executes fine but the bot is still in voice chat I tried changing ctx.bot.voice_clients: to self.bot.voice_clients: but it had no effect. I changed vesrion of discord.py multiple times… Read More Discord.py 2.0.0 voice chat disconnection problem

AttributeError: 'coroutine' object has no attribute 'edit' with discord.py

Advertisements So I was working on a discord bot, that should edit its own message on a command, and I tried many things, but I kept getting the AttributeError: ‘coroutine’ object has no attribute ‘edit’ Error, my code is this: embed = discord.Embed(title="title") embed.set_author(name="name", icon_url="image") embed.add_field(name="name", value="some text", inline=True) channel = Client.get_channel(channel-id) msg = channel.fetch_message(message-id)… Read More AttributeError: 'coroutine' object has no attribute 'edit' with discord.py

Discord.py missing permissions when bot role is above all and has admin privileges

Advertisements raise CommandInvokeError(self, e) from e discord.app_commands.errors.CommandInvokeError: Command ‘test’ raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions Constantly getting this error, even though my bot has administrator permissions, also the role is located at the top of the tree. Evem with all of this, I continuously get the error of missing permissions.… Read More Discord.py missing permissions when bot role is above all and has admin privileges

My Discord bot is not responding to messages/not even outputting to terminal?

Advertisements Trying to make a sorta complicated bot, but before i get started on writing the other code I wanted to just make sure that the bot worked in Discord, and was up and running and responding to a basic command – Send the message "Hello" when someone used the command "!hello". import discord from… Read More My Discord bot is not responding to messages/not even outputting to terminal?

Discord.py not responding to @client.event commands

Advertisements I am not getting a "ping" response with this code. It was working before, but I am not sure what changed. There are no errors on my end, just no response. Any feedback is appreciated. import os import random import discord from dotenv import load_dotenv from discord.ext import commands load_dotenv() PREFIX = os.getenv("PREFIX") TOKEN… Read More Discord.py not responding to @client.event commands

I'm making a Discord bot that is supposed to read from a text file and send called for line

Advertisements I’m new to this coding space, and what I’m trying to do is have the discord bot respond to slash command with it’s specified line. I have it where it works, but it responds to the command with the line below what is being called for. Here’s what I have so far @slash.slash(name="f2pquest", description="Lists… Read More I'm making a Discord bot that is supposed to read from a text file and send called for line

Cannot assign to global variable in on_ready()

Advertisements I am trying to code a discord bot that simultaneously prints new messages and sends user input from console to a selected channel. Here is what I have so far: import discord from threading import Thread from asyncio import run intents = discord.Intents.all() intents.members = True client = discord.Client(intents=intents,chunk_guilds_at_startup=False) main_channel = int(input(‘Enter channel ID… Read More Cannot assign to global variable in on_ready()