#Using Bridge Group Commands in a Cog (not loading)

1 messages · Page 1 of 1 (latest)

hidden ingot
#

Could someone send me an example of using bridge group command in a cog? I've tried everything and my cog isn't being loaded into my bot at all.

This is how I've implemented a portion of my relevant command. In this example, I'm trying to make a slash command "/create" with a subcommand "group"

class AdminOnlyCommands(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @bridge.bridge_group()
    @bridge.map_to("group")
    async def create (self, ctx: bridge.BridgeContext):

@create.bridge_command()
async def group(self, ctx: bridge.BridgeContext)
... 

At the end of my cog file, I have this function.

def setup(bot):
   bot.add_cog(AdminOnlyCommands(bot))```
and my main() file starts the bot as such:
```py
async def main():
    bot.load_extension("cogs.create_command")
    await bot.start(BOT_TOKEN)
asyncio.run(main())```
I get this error: ```discord.errors.ExtensionFailed: Extension 'cogs.create_command' raised an error: AttributeError: 'BridgeCommandGroup' object has no attribute 'bridge_command` ```
burnt temple
#

bridge.Bot and not commands.Bot

hidden ingot
#

I'm pretty sure I'm calling it incorrectly, looking at the docs rn

#

What's weird is when I change it from "@create.bridge_command()" to "@bridge.bridge_command()" the error goes away, but it still doesn't load my /create command so shrug

burnt temple
#

Can you move the load_extension outside of the main() one?

burnt temple
#

Above it?

hidden ingot
#


async def main():
    await bot.start(BOT_TOKEN)


asyncio.run(main())

Not sure if this is what you mean, but it doesn't make a difference.

burnt temple
#

Can you create a test bridge.command at the main file?

hidden ingot
#

Good idea i'll test it rn

burnt temple
#

And comment the load_extension out so you dont have to delete the line

hidden ingot
#

Yeah, it's working.

#

could itbe something with bridge compatibility with cogs?

burnt temple
#

Prefix and slash command?

burnt temple
hidden ingot
#
async def hello(ctx):
    await ctx.respond("Hello!")```
yep
hidden ingot
# burnt temple They should work at the cogs

hm Should I send more of my code? There are some warnings being shown by pycharm but I think they're unrelated..

For example,

"Unresolved attribute reference 'author' for class 'BridgeContext' "

#

I'm also pretty sure there's a decorator I can use for this functionality but w/e

#

even when I comment the majority of my group def, it still says the error in the post shrug

#

Here's the complete subcommand with options:

@create.bridge_command()
async def group(
self, ctx:bridge.BridgeContext,
group_category: str,
post_channel_id: discord.TextChannel,
emoji: str = ":thumbsup:",
std_admin_msg: str = ""):```
burnt temple
#

Can you create the same command at the cog without the bridge group stuff?

hidden ingot
#

so just use commands.command() right?

burnt temple
#

bridge.bridge_command

hidden ingot
#

mb I misread what you said, sure I'll try one sec

#

Yeah that works, dang I thought I tested this earlier. so it must be how I'm using the bridge_group

#

this must be the faulty code

    @bridge.bridge_group()
    @bridge.map_to("group")
    async def create(self, ctx: bridge.BridgeContext):
        # This will be the default behavior if someone just invokes '/create'
        # If not needed, you can keep it empty or provide some help message.
        await ctx.respond("Use a subcommand of create, e.g., '/create group'.")```
#
@bot.bridge_group()
@bridge.map_to("show")
async def config(ctx: BridgeContext):
    ...

@config.command()
async def toggle(ctx: BridgeContext):
    ...

example appears as:
/config show
/config toggle```
Although I basically copied this just with my own command
#

The difference is they map_to("show"), but define "toggle" inside @config.command() decorator, so im not sure what that is trying to do

#

I see.... I should be using @create.command not @create.bridge_command, lol

#

@burnt temple i'm bad at reading docs. Thank you for helping me debug this 🙂

#

🧡

#

While I have you, do you know how I can use my bot to add an 'emote' to a category channel? I've tried using discord message syntax :emoji:, but it doesn't work the same for channels.

burnt temple
#

Idk how it works sry

hidden ingot
burnt temple
#

I also dont know how the group stuff works at the bridge commands

#

Im so used to use slash_commands

hidden ingot
# burnt temple I also dont know how the group stuff works at the bridge commands

Yeah, I'm still figuring out the rest of it 🥲 . It's my first discord bot, it's working as intended now with a slash command having multiple subcommands (i.e. "group").

I need to learn how to add descriptions to my command options though. Or just change the appearance of my options, because nobody wants to see a bunch of snake_case words lol

hidden ingot
burnt temple
#

I use slash_commands for the autotranslation

hidden ingot
burnt temple
#

I mean full slash_command translation

#

Name, description and autocomplete

hidden ingot
# burnt temple I mean full slash_command translation

Oh! Could you show me the syntax for adding a name and description?

is it like..

async def group(self, ctx: bridge.BridgeContext,
group_category: str = discord.Option(description="What category is this group?", name="Group Category"))```