Discord.py | 봇이 보낸 메시지에 대해 동일한 사용자가 하나 이상의 반응을 가져 오지 않도록합니다.

Ashhar Amir

임베드로 보낼 명령을 만들고 틱과 십자가의 두 가지 반응이있는 명령을 만들려고합니다. 사용자가 둘 다에 반응하지 않고 반응 중 하나에 반응하도록 만들고 싶습니다. 또한 반응하는 사람이 특정 역할을 갖도록 시스템을 만드는 데 도움이 필요합니다. 어떤 도움이라도 대단히 감사하겠습니다!

Diggy.

이것은 on_raw_reaction_add()이벤트를 사용하여 가능합니다 .

@bot.event
async def on_raw_reaction_add(payload): # checks whenever a reaction is added to a message
                                        # whether the message is in the cache or not

     # check which channel the reaction was added in
    if payload.channel_id == 112233445566778899:

        channel = await bot.fetch_channel(payload.channel_id)
        message = await channel.fetch_message(payload.message_id)

        # iterating through each reaction in the message
        for r in message.reactions:

            # checks the reactant isn't a bot and the emoji isn't the one they just reacted with
            if payload.member in await r.users().flatten() and not payload.member.bot and str(r) != str(payload.emoji):

                # removes the reaction
                await message.remove_reaction(r.emoji, payload.member)

참조 :

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

Related 관련 기사

뜨겁다태그

보관