public async Task PlayAsync(IGuildUser guildUser) { if (guildUser == null) { return; } if (!guildData.IsEnabled) { await Context.Message.ReplyAsync("The waiting list is closed."); return; } var userInGuild = guildData.GetOrCreateGuildUser(guildUser.Id, guildUser.Nickname ?? guildUser.Username); if (userInGuild.IsInWaitingList) { await Context.Message.ReplyAsync("You are already on the waiting list!"); } else { // Add user the the waiting list userInGuild.IsInWaitingList = true; userInGuild.JoinTime = DateTime.Now; userInGuild.IsSub = guildUser.RoleIds.Contains(guildData.SubRoleId); dataContext.Update(userInGuild); dataContext.SaveChanges(); await Context.Message.ReplyAsync($"Waiting list joined!"); await ButtonWaitingListModule.UpdatePublicMessageAsync(waitingList, Context.Guild, guildData); } }
public async Task <CommandResult> AddUserAsync(IGuildUser guildUser) { if (!guildData.IsEnabled) { return(CommandResult.FromError("Waiting list is not open")); } if (guildData.UsersInList.Any(x => x.UserId == guildUser.Id)) { return(CommandResult.FromError("You are already on the waiting list!")); } else { var userInList = guildData.GetOrCreateGuildUser(guildUser.Id, guildUser.Nickname ?? guildUser.Username); userInList.IsInWaitingList = true; userInList.JoinTime = DateTime.Now; userInList.IsSub = guildUser.RoleIds.Contains(guildData.SubRoleId); dataContext.Update(userInList); await dataContext.SaveChangesAsync(); return(CommandResult.FromSuccess($"Waiting list joined!")); } }