dimanche 15 juillet 2018

Is there a way I can limit a condition to matching only once in a time interval?

I'm working with discord.py and on_voice_state_update is an extremely general condition that matches a lot of things:

  • A member joins a voice room.
  • A member leaves a voice room.
  • A member is muted or deafened by their own accord.
  • A member is muted or deafened by a server administrator.

I'm trying to perform an action when a voice room is joined, but I have some other functions that also perform actions that trigger on_voice_state_update when someone joins a channel. This ends up with on_voice_state_update being triggered several times when a member joins a voice room, but I am trying to write a condition that I only want to be triggered once.

What I'm trying to do is use on_voice_state_update to create a new voice room if the current voice room is full. It's doing this three times though. Is there a way I can have Python only perform an action once if a condition is met in a short timespan?

Aucun commentaire:

Enregistrer un commentaire