public async Task Banroyale([Remainder] string str = "") { var banroyale = await BanroyaleDb.GetBanroyale(Context.Channel.Id); if (banroyale == null) { await Context.Channel.SendMessageAsync($"There is no running Ban Royale in this channel. `{Program.GetPrefix(Context)}nbrl` to start a new one."); return; } var reqRole = Context.Guild.GetRole(banroyale.RoleReqId); var role = Context.Guild.GetRole(banroyale.ParticipantRoleId); var users = role.Members.ToList(); string participants = users.Count > 0 ? $"\n\nParticipants:\n{BanroyaleUtil.BanroyaleParticipants(users.Select(x => x.Username).ToList())}" : ""; await Context.Channel.SendMessageAsync(embed : BanroyaleUtil.BanroyaleDetailsEmbed(banroyale, Context.Guild.GetRole(banroyale.ParticipantRoleId), Context.Guild.GetRole(banroyale.RoleReqId), users.Count).Build()); }
public async Task JoinBanroyale([Remainder] string str = "") { var user = Context.User as SocketGuildUser; var banroyale = await BanroyaleDb.GetBanroyale(Context.Channel.Id); if (banroyale == null) { await Context.Channel.SendMessageAsync(":x: There is no running Ban Royale in this channel."); return; } if (banroyale.Running == true) { await Context.Channel.SendMessageAsync(":x: The ban royale already started. You're late to the party."); return; } if (banroyale.RoleReqId != 0) { if (!user.Roles.Any(x => x.Id == banroyale.RoleReqId)) { await Context.Channel.SendMessageAsync(":x: You do not have the required role to join!"); return; } } var role = Context.Guild.GetRole(banroyale.ParticipantRoleId); var users = role.Members.ToList(); if (users.Count >= banroyale.MaxParticipants - 1 && banroyale.MaxParticipants != 0) { await Context.Channel.SendMessageAsync("Ban Royale is full!"); return; } if (users.Contains(user)) { await Context.Channel.SendMessageAsync("You are already participating! Eager to get smoked, aren't you?"); return; } await user.AddRoleAsync(role); users.Add(user); string response = "You joined the Ban Royale. *Heh.*" + (users.Count > 10 ? "" : "\n\nList of Participants:\n" + BanroyaleUtil.BanroyaleParticipants(users.Select(x => x.Username).ToList())); await Context.Channel.SendMessageAsync(response); }