Esempio n. 1
0
 private Func <Task> getRegisterUserAction(CommandContext ctx)
 {
     return(new Func <Task>(async() =>
     {
         var discordId = ctx.User.Id.ToString();
         var serverId = ctx.Guild.Id.ToString();
         var users = UserDbService.GetUsers();
         var servers = ServerDbService.GetServers(users);
         var server = servers[serverId];
         var config = LeagueConfigDbService.GetLeagueConfig(server.LeagueConfigId);
         if (!users.ContainsKey(discordId))
         {
             UserDbService.CreateUser(discordId, serverId, config);
         }
         if (!server.Users.Select(x => x.Id).Contains(discordId))
         {
             ServerDbService.AddUserToServer(discordId, serverId, false, false);
         }
         else
         {
             throw new Exception("You are already registered in this server");
         }
         ulong roleId = Convert.ToUInt64(server.LeagueRoleId);
         if (!ctx.Guild.Roles.ContainsKey(roleId))
         {
             throw new Exception("Error: League role not found");
         }
         await ctx.Member.GrantRoleAsync(ctx.Guild.Roles[roleId], "registering for riichi league");
         await ctx.RespondAsync($"<@{ctx.User.Id}> has been registered");
     }));
 }
Esempio n. 2
0
 private Func <Task> getRegisterUserAction(CommandContext ctx)
 {
     return(new Func <Task>(async() =>
     {
         var discordId = ctx.User.Id.ToString();
         var serverDiscordId = ctx.Guild.Id.ToString();
         var server = ServerDbService.GetServer(serverDiscordId);
         var config = LeagueConfigDbService.GetLeagueConfig(server.LeagueConfigId);
         UserDbService.CreateUser(discordId, serverDiscordId, config);
         ServerDbService.AddUserToServer(discordId, serverDiscordId, false, false);
         ulong roleId = Convert.ToUInt64(server.LeagueRoleId);
         if (!ctx.Guild.Roles.ContainsKey(roleId))
         {
             throw new Exception("Error: League role not found");
         }
         await ctx.Member.GrantRoleAsync(ctx.Guild.Roles[roleId], "registering for riichi league");
         await ctx.RespondAsync($"<@{ctx.User.Id}> has been registered");
     }));
 }
Esempio n. 3
0
 private Func <Task> getRegisterDummyAction(CommandContext ctx)
 {
     return(new Func <Task>(async() =>
     {
         var discordId = ctx.User.Id.ToString();
         var serverDiscordId = ctx.Guild.Id.ToString();
         var server = ServerDbService.GetServer(serverDiscordId);
         var config = LeagueConfigDbService.GetLeagueConfig(server.LeagueConfigId);
         var heatiro = "323096688904634377";
         var clubapero = "198974501709414401";
         var Neral = "273192430172372993";
         UserDbService.CreateUser(heatiro, serverDiscordId, config);
         UserDbService.CreateUser(clubapero, serverDiscordId, config);
         UserDbService.CreateUser(Neral, serverDiscordId, config);
         ServerDbService.AddUserToServer(heatiro, serverDiscordId, false, false);   //Heatiro
         ServerDbService.AddUserToServer(clubapero, serverDiscordId, false, false); //clubapero
         ServerDbService.AddUserToServer(Neral, serverDiscordId, false, false);     //Neral
         UserDbService.SetMahjsoulName(heatiro, "heairo");
         UserDbService.SetMahjsoulName(Neral, "Neral");
         UserDbService.SetMahjsoulName(clubapero, "clubapero");
         await Task.FromResult(false);
     }));
 }