0

I'm trying to make a discord bot using the discord.py module. I have structured my code in so called Cogs and now want to make one for creating text channels. The Bot has the permissions it requires but is not doing anything when I call the command. I also don't get any error message, it just does nothing. Thanks for helping already!


from discord.ext import commands
import discord


class createchannel(commands.Cog):

    def __init__(self, client):
        self.client = client


    @commands.command()
    async def create(self, ctx, channel_name):
        guild = ctx.message.guild
        await guild.create_text_channel(channel_name)

def setup(client):
    client.add_cog(createchannel(client))
2
  • Can you see the command when you use the help command? Commented Jan 14, 2021 at 15:42
  • @Nurqm Yes I can. I'm pretty sure the Cog is loaded correctly and it's not the things that's causing the problem. Commented Jan 14, 2021 at 16:09

2 Answers 2

1

I found what was causing it not to work. The bot actually didn't have the permissions to edit the channel (which is weird because I authorized it with Amdin Rights) and I didn't get an error in the console because my cog that handles erros blocked it.

Sign up to request clarification or add additional context in comments.

Comments

0

Ran into the same problem with disnake, and it took me reading through the api and testing things to figure it out. Since disnake is supposed to be forked off of discord.py try this

@commands.command(name="obvious", description="given")
async def command(ctx: Context):
    await ctx.message.guild.create_text_channel("channel_name")

This solved my issue, and now I just need to add the parameters to properly sort channel creation.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.