#prefixed part of bridge command not working

1 messages · Page 1 of 1 (latest)

grizzled canyon
#

in the code below the event listener works and also the slash command gets recognised, but the prefixed version wont work (same thing when using ext.commands instead of bridge)

import asyncio
from hypercorn.config import Config
from hypercorn.asyncio import serve
from quart import Quart
import discord
from discord.ext import bridge
import signal


loop = asyncio.new_event_loop()

intends = discord.Intents.all()

token = "token"

bot = bridge.Bot(intends=intends, command_prefix="!", loop=loop, debug_guilds=[576380164250927124])

config = Config()
config.bind = ["localhost:8000"]

app = Quart(__name__)


@app.route("/")
async def index():
    return "Hello World"


@bot.bridge_command()
async def hello(ctx):
    print("test")
    await ctx.respond("Hello!")


@bot.event
async def on_ready():
    print("Bot ready")


shutdown_event = asyncio.Event()


def _signal_handler():
    shutdown_event.set()


# loop.add_signal_handler(signal.SIGTERM, _signal_handler)

try:
    bot_task = loop.create_task(bot.start(token))
    web_task = loop.create_task(serve(app, config, shutdown_trigger=shutdown_event.wait))
    loop.run_until_complete(asyncio.gather(bot_task, web_task))
except KeyboardInterrupt:
    loop.run_until_complete(bot.close())
finally:
    loop.close()
lost wharf
#

does the slash command show up in discord?

grizzled canyon
#

@lost wharf
#998272089343668364 message
you mean
loop.run_until_complete(asyncio.gather(bot_task, web_task))
to
asyncio.run(asyncio.gather(bot_task, web_task))

lost wharf
#

no

#

this whole part

try:
    bot_task = loop.create_task(bot.start(token))
    web_task = loop.create_task(serve(app, config, shutdown_trigger=shutdown_event.wait))
    loop.run_until_complete(asyncio.gather(bot_task, web_task))
except KeyboardInterrupt:
    loop.run_until_complete(bot.close())
finally:
    loop.close()
grizzled canyon
lost wharf
grizzled canyon
#

yepp

lost wharf
#

btw leaked token

grizzled canyon
#

opps

lost wharf
#

yea good idea to reset it

#

ngl i dont see a reason why prefix cmds should break

grizzled canyon
# grizzled canyon opps

discord doesn't seem to check your message if it's the start of a thread 🤔 in a normal message it warned me

lost wharf
#

you got intents enabled on the portal right

#

if you didnt then it would have raised error on startup, which it hasnt

grizzled canyon
#

yep, everything enabled and since it's a random bot I created for testing it's only on one server

grizzled canyon
lost wharf
grizzled canyon
#

yes

lost wharf
#

if so, use @bot.listen()

lost wharf
#

else, add await bot.process_commands(message) at the end of the func

lost wharf
lost wharf
#

you can still do it using loop = asyncio.get_running_loop() right

#

but tbh

#

.itworks

hazy nestBOT
grizzled canyon
grizzled canyon
lost wharf
lost wharf
grizzled canyon
# lost wharf what about this

this is what I did

@bot.listen()
async def on_message(message):
    print("message: ", message)
    await bot.process_commands(message)```
lost wharf
grizzled canyon
#

it's not reacting to the command either way

lost wharf
#

does print("message: ", message) work?

grizzled canyon
#

yea

lost wharf
#

huh

#

any errors? errors that might get suppressed?

grizzled canyon
#

nope, this is the entire log

D:\projects\python\flaskProject1\.venv\Scripts\python.exe D:\projects\python\flaskProject1\quart_app.py 
[2023-01-02 15:20:55 +0100] [21116] [INFO] Running on http://127.0.0.1:8000 (CTRL + C to quit)
Bot ready
message:  <Message id=1059476426857922560 channel=<TextChannel id=674359783439990816 name='commands' position=3 nsfw=False category_id=576380164250927125 news=False> type=<MessageType.default: 0> author=<Member id=264203029279014922 name='Darquaise' discriminator='0001' bot=False nick='Maxx' guild=<Guild id=576380164250927124 name='ProjectVibe - Vibebot testing' shard_id=0 chunked=False member_count=12>> flags=<MessageFlags value=0>>
test
message:  <Message id=1059476467475546182 channel=<TextChannel id=674359783439990816 name='commands' position=3 nsfw=False category_id=576380164250927125 news=False> type=<MessageType.application_command: 20> author=<Member id=345715570894700564 name='NOOBICON' discriminator='9802' bot=True nick=None guild=<Guild id=576380164250927124 name='ProjectVibe - Vibebot testing' shard_id=0 chunked=False member_count=12>> flags=<MessageFlags value=0>>
grizzled canyon
lost wharf
#

try running a debugger

#

||or yk, tons of print statements||

grizzled canyon
#

I mean, this is the entire code, so not much that can be tested really

#

the debugger positioned on these positions
when using the slash command it pauses at line 31
when using the prefixed command it pauses at line 42; when continuing, it will go into line 43 but after that it's done

lost wharf
#

hmm

#

add a listener for on_command

#

see if that is executed

#

it accepts ctx

grizzled canyon
#

ok I just tryed print("message: ", message.content) and got message: as the result, so it seems the content isn't received

lost wharf
#

oh hmm

#

show pip list

grizzled canyon
lost wharf
#

Looks clean

#

Dude that is so weird

#

Enable logging on debug level

#

See if anything is weird there

#

Or wait on someone with knowledge to help out

icy kernel
#

@grizzled canyon is this still an issue? If not, you can close this thread with /close

brazen latch
#

@grizzled canyon
intents is misspelled to be intends.
It should be

bot = bridge.Bot(intents=intends, command_prefix="!", loop=loop, debug_guilds=[576380164250927124])
lost wharf
#

Oh wtf. How did I miss that blobpain

grizzled canyon
#

oh wow lmao

#

thanks guys, I haven't really looked into it anymore since I didn't have the time, but now I know what I did wrong haha