public DiscordIntegratedEnqueueResult EnqueueWithDiscordRole(ulong userId, FFXIVRole role, IRole discordRole, SocketCommandContext context, string eventId) { if (context.Guild == null) { return(DiscordIntegratedEnqueueResult.NoGuild); } if (!context.Guild.GetUser(userId).HasRole(discordRole)) { return(DiscordIntegratedEnqueueResult.DoesNotHaveRole); } var queue = GetQueue(role); lock (queue) { if (queue.Any(s => EventValid(eventId)(s) && s.Id == userId)) { return(DiscordIntegratedEnqueueResult.AlreadyInQueue); } eventId ??= ""; var slot = new QueueSlot(userId, eventId, roleIds: new[] { discordRole.Id }); queue.Add(slot); return(DiscordIntegratedEnqueueResult.Success); } }
private static bool SlotHasRole(QueueSlot s, IRole discordRole, SocketCommandContext context) { // User-specified roles take absolute precedence over their role list if (s.RoleIds.Count() != 0) { return(s.RoleIds.Contains(discordRole?.Id ?? 0)); } // Alternatively, check their role list var discordUser = context.Guild.GetUser(s.Id); if (discordUser != null && discordUser.HasRole(discordRole)) { return(true); } return(false); }
public void AddSlot(QueueSlot slot, FFXIVRole role) { var queue = GetQueue(role); queue.Add(slot); }