ChocoMeow / Vocard

Vocard is a simple music bot. It leads to a comfortable experience which is user-friendly, It supports Youtube, Soundcloud, Spotify, Twitch and more!
MIT License
111 stars 38 forks source link

Messages from other bots #23

Closed en0o0n closed 3 months ago

en0o0n commented 3 months ago

Hello there,

i must say this music bot is amazing. There is a feature i need, to make the bot listen to messages from other bots.

I tried to remove if message.author.bot from on_message but the music bot still ignore messages from other bots

Can you please help me with this.

Best regards, En0o0n

ChocoMeow commented 3 months ago

have you enabled message_content intent for your bot?

en0o0n commented 3 months ago

Thanks for the fast reply. Yes i did: image

ChocoMeow commented 3 months ago

Have you tried to print the message from the on_message? it returns none or something else

en0o0n commented 3 months ago

Yes i have tried to print messages from other bots and it display it correctly but still music bot still ignoring it :

async def on_message(self, message: discord.Message, /) -> None: print(f"Message received from {message.author} (Bot: {message.author.bot}): {message.content}")

    # Removing the check that ignores messages from bots
    # if message.author.bot:
    #    return

    if not message.guild:
        print("Message not from a guild, ignoring.")
        return

    if self.user.id in message.raw_mentions and not message.mention_everyone:
        prefix = await self.command_prefix(self, message)
        if not prefix:
            return await message.channel.send("I don't have a bot prefix set.")
        await message.channel.send(f"My prefix is `{prefix}`")

    await self.process_commands(message)
    print("Processed commands for the message.")

the ouput is :
Message received from Writer#1622 (Bot: True): -play sia Processed commands for the message.

Playing music with normal user "-play sia" works

ChocoMeow commented 3 months ago

Can you show the code of your on_message function?

en0o0n commented 3 months ago

i just edit the last message above

en0o0n commented 3 months ago

as you can see the normal user works but the bot dont haha and i have the same code image

what else should i do?

ChocoMeow commented 3 months ago

I have tested again and it works fine

image image

async def on_message(self, message: discord.Message, /) -> None:
        # if message.author.bot or not message.guild:
        #     return False

        if self.user.id in message.raw_mentions and not message.mention_everyone:
            prefix = await self.command_prefix(self, message)
            if not prefix:
                return await message.channel.send("I don't have a bot prefix set.")
            await message.channel.send(f"My prefix is `{prefix}`")

        print(message.content)
        await self.process_commands(message)
en0o0n commented 3 months ago

U are trying as Choco, its a normal user not an "app" or "bot"

ChocoMeow commented 3 months ago

make sure your bot has permission to read messages from your channel

en0o0n commented 3 months ago

The music bot is administrator and it read messages from the channel if i wrote it as a normal user But when i write messages as another bot then it ignores it

ChocoMeow commented 3 months ago

the message "No voice channel to connect. Please either provide one or join one." are send from the bot

en0o0n commented 3 months ago

Yeah i understand, can u please try to play a song like sending "!p test" from a bot not from Choco

ChocoMeow commented 3 months ago

oh, you are talking about running a command by a bot. Of course, it is not working because discord.py is not allowed. in the process commands function it will bypass all the bot message

en0o0n commented 3 months ago

how can i avoid that :c?

ChocoMeow commented 3 months ago

you can modify the process_commands function in discord.py module

https://github.com/Rapptz/discord.py/blob/0e58a927ddbc300a17ef0137d948faa659565313/discord/ext/commands/bot.py#L1403

en0o0n commented 3 months ago

oh wait no u can edit that in the main.py I just added explicit command invocation and now it worksssss

ChocoMeow commented 3 months ago

good to hear that :D

en0o0n commented 3 months ago

Thanks for your answers, talking helps always ^^ And thanks for the great music bot. Can i ask another feature here or shall i make a new iissue for it?

ChocoMeow commented 3 months ago

You are welcome!

I generally prefer using Discord. however, since GitHub is more familiar to you, let’s create a separate issue there to discuss another topic.