breadsticku
breadsticku

Reputation: 1

Attempting to get a discord bot to react to all messages within a certain channel

This script isn't mine. The script is functional, but it only works for one user. I want it to react to all messages sent within a certain channel from any user. I think the problem lies in message.author.id thing, I tried just full out removing the line but it ended up just breaking the entire thing and it wouldn't start up the discord bot. Any help is greatly appreciated.

from discord.ext        import commands
from discord.ext.commands    import Bot
import asyncio

bot = commands.Bot(command_prefix = "$")

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

async def react(message):
    custom_emojis = [
    ":like:",
    ":emoji:",
    ":emoji:"
    ]
    guild_emoji_names = [str(guild_emoji) for guild_emoji in message.guild.emojis]
    for emoji in custom_emojis:
        if emoji in guild_emoji_names:
            await message.add_reaction(emoji)

@bot.event
async def on_message(message):
    if message.channel.id == 721485450790830111 and \
        message.author.id == 721483699719241748:
            await react(message)```

Upvotes: 0

Views: 418

Answers (1)

chluebi
chluebi

Reputation: 1829

Custom server emoji can't just be called by name. There is a certain string you need to use to call them: <:emoji_name:emoji_id>

This has all been detailed in this thread (or the github issue here).

This means you need to rewrite your custom_emojis list as to be made up of strings formatted like that.

Upvotes: 1

Related Questions