원래는 반응을 하려고 했는데... 오늘은 이벤트에 대해서 알아보려고 합니다.
이벤트가 뭘까요? 이벤트는 특정한 상황을 뜻합니다.
예를 들자면, on_ready나 on_message가 이벤트라고 할 수 있습니다.
@app.event async def on_ready(): print("Bot Started") @app.event async def on_command_error(ctx, error): print("error!") @app.event async def on_error(event, *args, **kwargs): print("error!") @app.event async def on_message(message): print(message) @app.event async def on_typing(channel, user, when): print(f"{user} is typing") @app.event async def on_message_delete(message): print(f"{message} deleted") @app.event async def on_bulk_message_delete(messages): for message in messages: print(message) @app.event async def on_message_edit(before, after): print(before + " edited to " + after) @app.event async def on_reaction_add(reaction, user): print(user + "do" + reaction) @app.event async def on_reaction_remove(reaction, user): print(user + "removed" + reaction) @app.event async def on_reaction_clear(message, reactions): for i in reactions: print(i) @app.event async def on_member_join(member): print(member + " Joined") @app.event async def on_member_remove(member): print(member + " left the server") @app.event async def on_user_update(before, after): print(before + " to " + after) @app.event async def on_guild_join(guild): print(guild) @app.event async def on_guild_remove(guild): print(guild) @app.event async def on_guild_update(before, after): print(before + " to " + after) @app.event async def on_guild_role_create(role): print(f"{role} created!") @app.event async def on_guild_role_delete(role): pass # similar @app.event async def on_guild_role_update(before, after): print(f"{before} updated to {after}.") @app.event async def on_guild_emojis_update(guild, before, after): print(f"{guild}'s emoji, {before} updated to {after}") @app.event async def on_voice_state_update(member, before, after): print(f"{member}'s voice state update to {after}") @app.event async def on_member_ban(guild, user): print(f"{user} banned at {guild}") @app.event async def on_member_unban(guild, user): pass #similar @app.event async def on_invite_create(invite): print(f"{invite} created") @app.event async def on_invite_delete(invite): pass #similar
이렇게 굉장히 많은 이벤트가 discord.py에 있습니다.
이 이벤트들을 잘 사용하면 굉장히 다양한 것들을 할 수 있습니다.
이걸 잘 활용하셔서 좋은 봇 만드시길 바랍니다!