#How to go about getting a list of ids that respond to a message sent out

1 messages · Page 1 of 1 (latest)

stiff gyro
#

Making something like a giveaway bot and I want to have the bot dm a certain amount of people who react.
How do I go about doing this? I'm a beginner to hikari btw

modern lichen
#

This endpoint should point you In the right direction

stiff gyro
modern lichen
#

You can use member.send to send a message to them in dms

stiff gyro
stiff gyro
#
sent_embed = await message.respond(embed) # message object
    
    await asyncio.sleep(endtime_int) # wait for the end of a timer

    users = await sent_embed.fetch_reactions_for_emoji(1006722737668104325, embed, "moneybag") # collect users reactions to message object with moneybag emoji

    for user in users: #loop thry users
        await user.send('Thanks for reacting!') #send dm to each user who reacted

I wrote comments on it so I can understand what's going on, but am I missing something?

modern lichen
modern lichen
#

And I recommend you don't spam dm people btw

stiff gyro
stiff gyro
stiff gyro
modern lichen
#

It makes no sense to DM them all

stiff gyro
#

Oh yeah yeah I’m just testing to see that it works

modern lichen
modern lichen
#

I mean, considering you have a sleep before it, idk

stiff gyro
#

I took out that line and got an error

#

ResponseProxy object has no attribute fetch_reactions_for_emoji

#

I'm assuming its referring to my message in the form of an embed?

#

Does it have something to do with the way the message is sent to the channel by the bot? I'm not sure lol

modern lichen
#

Check lightbulb docs for how to get a message from a ResponseProxy

stiff gyro
#

I reran it and now theres a new error

#

that has something to do with the function itself right?

modern lichen
#

await (await sent_embed.message()).whatever

stiff gyro
#

interesting now it gives the error saying that the "Message" object doesn't have the attribute fetch_reactions_for_emoji

#

looking in the docs rn

modern lichen
#

because it doesnt

#

its in bot.rest.fetch_reactions_for_emoji

stiff gyro
#

OHHH

#

yknow that makes much more sense

stiff gyro
#

Now I would need to figure out how to get the snowflake from the ResponseProxy to pass into fetch_reactions

#

So to do this would it be something like: sent_embed.message().id() ?

#

where I turn the proxy into a message object and then get the id of the message obejct?

#

I tried the above and the result is this:

#

also, I get this warning

modern lichen
#

because you never awaited it

#

you just called .id() on a corroutine

modern lichen
stiff gyro
#

ok so a couple of things happened

#

I got this error and realized emd_msg is a snowflake object and so I passed it into the fetch method

#

I fixed that (yay) then I got this error:

#

It said 'Unknown Emoji' so i replaced it with the actual emoji again

#

Then I got this error:

#

It says it got a list, which is what I'm expecting, so I took the async out for the for loop

#

Now it runs without errors, but it still doesn't send a dm 😭

#

Here is the code:

#
bot = lightbulb.BotApp(token='', intents=hikari.intents.Intents.GUILD_MESSAGE_REACTIONS, default_enabled_guilds=(1006722736074264677))

@bot.listen(hikari.StartedEvent)
async def on_started(event):
    print('Bot has started')

@bot.listen(hikari.ReactionAddEvent) 
async def get_reaction_user(event):
    pass
    #if not event.is_for_emoji('U+1F4B0'):
        

@bot.command()
@lightbulb.option('amount','how much robux?',type=int, min_value= 500)
@lightbulb.option('time','how many minutes?',type=int, min_value= 1)
@lightbulb.command('startrain', 'starts giveaway')
@lightbulb.implements(lightbulb.SlashCommand)
async def embed_msg(message):
    
    rbux_val= message.options.amount  # robux amount
    rain_start = datetime.datetime.now() # datetime start time
    rain_end = rain_start + timedelta(minutes=message.options.time) #datetime end time
    endtime_int = int(rain_end.strftime("%Y%m%d%H%M%S")) #end time in secs

#Initialize Embed
    embed = hikari.Embed(title="💸 Enter the ROBUX rain! 💸",  #initialize embed
                        description="**RAIN AMOUNT:** " + str(rbux_val) +
                                 "\n**RAIN ENDS: **" + "<t:"+ str(int((time.mktime(rain_end.timetuple()))))+ ":R>" +
                                 "\n\nReact to enter the rain!",
                        color='#FFFF00'
    ) 
                    
    embed.set_footer("ROBUX RAIN started by" + " " + message.author.username) # set footer

    sent_embed = await message.respond(embed) # message object
    embed_msg = await sent_embed.message()
    

    #await asyncio.sleep(endtime_int) # wait for the end of a timer

    users = await bot.rest.fetch_reactions_for_emoji(1006722737668104325, embed_msg, "💰") # collect users reactions to message object with moneybag emoji

    for user in users: #loop thru users
        await user.send('Thanks for reacting!') #send dm to each user who reacted

bot.run()
modern lichen
#

print what users is and see if its empty or what @stiff gyro

stiff gyro
#

which is weird cause I reacted to it

modern lichen
#

well there is your issue :P

#

@stiff gyro you do the iteration over it right after you send the message

#

so you have no time to react

#

add the asyncio.sleep before and set it to 3 and then quickly react

#

and it should work

stiff gyro
#

bet bet bet

#

It worked!!

#

Much thanks @modern lichen