discord.py Dictionary of all roles

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 like… Read More discord.py Dictionary of all roles

Discord.py 2.0.0 voice chat disconnection problem

@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 but… Read More Discord.py 2.0.0 voice chat disconnection problem

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

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) await… 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

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. My… 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?

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 discord.ext… Read More My Discord bot is not responding to messages/not even outputting to terminal?

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

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 all… 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()

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 you… Read More Cannot assign to global variable in on_ready()