Replies: 1 comment 2 replies
-
I definitely agree that there should be a waitForEvent, since I was planning to add advanced event handler stuff to dimscord (like Another thing to add here is that the disadvantage of using the onDispatch event is that is emitted before dimscord handles the event e.g. in For advanced use-case, as nim is statically-typed I'd say for any generic waitfor event, response could be ## inside messageCreate
let guild = s.cache.guilds[m.guild_id.get]
let evt = s.getGuildMembers(guild_id = guild.id, limit = m.member_count.get)
if not withTimeout(evt, 15000): echo "it appears that it is taking long for getting guild members"
let members = (await evt).members
let role_members: seq[Member] = @[]
for member in members:
if "<insert-role-id>" in member.roles: role_members.add(member)
echo role_members |
Beta Was this translation helpful? Give feedback.
-
Abstract
The goal of this issue is to discuss the design of this feature and provide bot developers with a convenient and self-contained solution to "wait for" specific events during the execution of a control flow without relying on traditional event handlers.
Motivation
To my knowledge, this came up a fair amount of times in the discord server but basically, practical use-cases for this would be:
Currently, users can somewhat cope with the lack of this feature by making it themselves in their code:
This works for basic and specific usecase but become quickly tedious as you need to handle different kinds of events, falling back to the second bullet point of keeping development smooth and code clean, hence why library support for this feature would be for the best imo.
Beta Was this translation helpful? Give feedback.
All reactions