public async Task <RuntimeResult> Setup(int count = 3) { IRole role = Context.Guild.Roles.FirstOrDefault(x => x.Name == TTTService.RoleName); if (role == null) { role = await Context.Guild.CreateRoleAsync(TTTService.RoleName, isMentionable : false); } var existing = Context.Guild.VoiceChannels.Count(x => x.Name.StartsWith("ttt-")); ICategoryChannel category = Context.Guild.CategoryChannels.FirstOrDefault(x => x.Name == "TTT"); if (category == null) { category = await Context.Guild.CreateCategoryChannelAsync("TTT"); await category.AddPermissionOverwriteAsync(Context.Guild.EveryoneRole, Program.NoPerms); await category.AddPermissionOverwriteAsync(role, Program.ReadPerms); } for (int i = 0; i < (count * count); i++) { IVoiceChannel vc = Context.Guild.VoiceChannels.FirstOrDefault(x => x.Name.StartsWith($"ttt-{i}")); if (vc == null) { vc = await Context.Guild.CreateVoiceChannelAsync($"ttt-{i}", x => { x.CategoryId = category.Id; }); } var invites = await vc.GetInvitesAsync(); IInvite invite = invites.FirstOrDefault(); if (invite == null) { invite = await vc.CreateInviteAsync(maxAge : null, maxUses : 1, isTemporary : true); } await vc.ModifyAsync(x => x.Name = $"ttt-{i}-{invite.Code}"); } return(Success("Server has been setup for tic tac toe.")); }