private async Task CloseThread(CommandArguments commandArgs, bool notify = true) { Match match = this.IdRegex.Match(commandArgs.Channel.Topic); if (!match.Success || !guid.TryParse(match.Value, out guid userId)) { await commandArgs.SendReplySafe("This does not seem to be a modmail thread. This command can only be used in a modmail thread channel."); return; } await commandArgs.Channel.ModifyAsync(c => c.CategoryId = this.Client.Config.ModmailArchiveCategoryId); SocketCategoryChannel category = commandArgs.Channel.Guild.GetCategoryChannel(this.Client.Config.ModmailArchiveCategoryId); while ((category?.Channels.Count ?? 0) > this.Client.Config.ModmailArchiveLimit) { SocketGuildChannel oldChannel = category.Channels.OrderBy(c => c.Id).FirstOrDefault(); if (oldChannel == null) { break; } await oldChannel.DeleteAsync(); } if (notify) { await SendModmailPm(commandArgs, userId, "Thread closed. You're welcome to send another message, should you wish to contact the moderators again."); } }
public override Task <PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services) { if ((CasinoGuild.Channels.Where(x => x.Id == context.Channel.Id).Count() <= 0) || context.Guild == null) { // Channel not in Four Aces return(Task.FromResult(PreconditionResult.FromError($"Command must be used in the Four Aces Server, in a channel."))); } ITextChannel chnl = CasinoGuild.Channels.FirstOrDefault(x => x.Id == context.Channel.Id) as ITextChannel; SocketCategoryChannel category = CasinoGuild.Channels.FirstOrDefault(x => x.Id == chnl.CategoryId) as SocketCategoryChannel; bool inValid = false; if (category != null) { inValid = category.Name.StartsWith("Investigation"); if (_startsWith) { inValid = category.Name.StartsWith(_name) || (string.IsNullOrWhiteSpace(chnl.Topic) ? "":chnl.Topic).Contains(_name); } else { bool nameCat = CultureInfo.InvariantCulture.CompareInfo.IndexOf(category.Name, _name, CompareOptions.IgnoreCase) >= 0; bool topicCat = chnl.Topic.ToLower().Contains(_name.ToLower()); inValid = nameCat || topicCat; } } if (inValid) { return(Task.FromResult(PreconditionResult.FromSuccess())); } return(Task.FromResult( PreconditionResult.FromError($"Command can not be used in this channel"))); }
public static async Task RemoveAllCategoryChannels(SocketCategoryChannel cat) { foreach (SocketGuildChannel chan in cat.Channels) { await chan.DeleteAsync(); } }
public OrikivoCommandContext(DiscordSocketClient client, DataContainer data, SocketUserMessage msg) : base(client, msg) { if (Guild.TryGetTextChannel(msg.Channel.Id, out SocketTextChannel t)) { if (t.Category.Exists()) { Category = t.Category as SocketCategoryChannel; } } Data = data; Global = Data.Global; if (Guild.Exists()) { Server = Data.GetOrAddServer(Guild); } if (User.Exists()) { if (Data.TryGetAccount(User, out OldAccount _a)) { Account = _a; Account.Username = User.Username; } } }
private static void Load() { games = DataStorage.LoadGames(); pendingGames = DataStorage.LoadPendingGames(); if (GlobalUtils.client == null) { return; } ulong chanId = ulong.Parse(DataStorage.GetData("gameChannel")); gameChannel = (SocketGuildChannel)GlobalUtils.client.GetChannel(chanId); chanId = ulong.Parse(DataStorage.GetData("gamesText")); SocketGuild guild = GlobalUtils.client.Guilds.FirstOrDefault(); var result = from a in guild.CategoryChannels where a.Id == chanId select a; gamesText = result.FirstOrDefault(); chanId = ulong.Parse(DataStorage.GetData("gamesVoice")); result = from a in guild.CategoryChannels where a.Id == chanId select a; gamesVoice = result.FirstOrDefault(); roleMessageId = ulong.Parse(DataStorage.GetData("gameRoleMessageId")); }
public async Task DeleteSection() { GuildBson guild = await Database.LoadRecordsByGuildId(Context.Guild.Id); if (guild.CategoryId != null) { SocketCategoryChannel categoryChannel = Context.Guild.GetCategoryChannel(guild.CategoryId.Value); foreach (SocketGuildChannel channel in categoryChannel.Channels) { await channel.DeleteAsync(); } foreach (PropertyInfo info in guild.GetType().GetProperties() .Where(c => c.PropertyType == typeof(ulong?) && c.GetValue(guild) != null)) { guild.GetType().GetProperty(info.Name)?.SetValue(guild, (ulong?)1); } await categoryChannel.DeleteAsync(); } guild.CategoryId = null; await Database.UpdateGuild(guild); await SendSuccessAsync("Deleted Auditor sections."); }
private async Task <ITextChannel> CreateApplicationChannel(SocketGuild guild, GuildTB dbentry) { logger.Log(new LogMessage(LogSeverity.Info, "State", $"Creating an application channel for {guild.Name}.")); // find the correct category SocketCategoryChannel category = null; if (dbentry.Public != null) { foreach (var c in guild.CategoryChannels) { if (c.Channels.Any(x => x.Id == dbentry.Public)) { category = c; break; } } } try { // try to create a text channel return(await guild.CreateTextChannelAsync("Applications", (x) => { x.Topic = "Are you interested in our community? Write your application here!"; x.CategoryId = category?.Id; })); } catch (Exception e) { // report failure logger.Log(new LogMessage(LogSeverity.Error, "State", $"Attempted to create a channel for '{guild.Name}', but failed: {e.Message}\n{e.StackTrace}")); return(null); } }
bool hasAccessTo(SocketCategoryChannel c) { if (canViewAllChannels) { return(true); } return(c.GetUser(Context.User.Id) != null); }
//sends a message makred diffrently then other messages public async Task AdminMessage(SocketMessage message, SocketCategoryChannel catagory) { string anonMessage = message.Content; anonMessage = anonMessage.Remove(0, 3);//removes command prefix Console.WriteLine(anonMessage); await SendMsgToEveryChanInCatagory($":o2:**{DateTime.Now.TimeOfDay.Ticks % 42069}**\n{anonMessage}", catagory); }
/// <summary> /// Fires when every user leaves/joins voice channel in every guild (if bot is in that guild) /// </summary> /// <param name="user">User who joined/left voice channel</param> /// <param name="voiceState1">First state of user's voice channel</param> /// <param name="voiceState2">Second state of user's voice channel</param> /// <returns></returns> private static async Task <Task> HandleAsEvent(SocketUser user, SocketVoiceState voiceState1, SocketVoiceState voiceState2) { //Reading servers configuration JsonClasses.ServersConfig serversConfig; using (StreamReader streamReader = new StreamReader("serversconfig.json")) { serversConfig = JsonConvert.DeserializeObject <JsonClasses.ServersConfig>(streamReader.ReadToEnd()); } //Reading categories from user ineractions SocketCategoryChannel category1 = (SocketCategoryChannel)voiceState1.VoiceChannel?.Category; SocketCategoryChannel category2 = (SocketCategoryChannel)voiceState2.VoiceChannel?.Category; //If voice channel from first state exists if (category1 != null) { //Searching first voice channel guild in configuration List <JsonClasses.Server> servWithIdList = serversConfig.Servers.Where(x => x.Id == category1.Guild.Id).ToList(); //If found if (servWithIdList.Count != 0) { //Searching first voice channel category in configuration List <JsonClasses.Category> categoryWithIdList = servWithIdList[0].Categories.Where(x => x.Id == category1.Id).ToList(); //If found if (categoryWithIdList.Count != 0) { await ProcessChannels(category1, categoryWithIdList[0]); } } } //If voice channel from first state exists and categoriess not equals if (category2 != null && category2 != category1) { //Searching second voice channel guild in configuration List <JsonClasses.Server> servWithIdList = serversConfig.Servers.Where(x => x.Id == category2.Guild.Id).ToList(); //If found if (servWithIdList.Count != 0) { //Searching second voice channel category in configuration List <JsonClasses.Category> categoryWithIdList = servWithIdList[0].Categories.Where(x => x.Id == category2.Id).ToList(); //If found if (categoryWithIdList.Count != 0) { await ProcessChannels(category2, categoryWithIdList[0]); } } } return(Task.CompletedTask); }
public static bool TryGetCategory(this SocketGuild g, string s, out SocketCategoryChannel cg) { cg = null; if (!g.HasCategory(s)) { return(false); } cg = g.CategoryChannels.Where(x => x.Name.ToLower() == s.ToLower()).First(); return(true); }
public async Task Message(SocketMessage message, SocketCategoryChannel catagory) { var guildData = new AnonServer().GetGuildSettings(catagory.Guild.Id); if (catagory.Id == guildData.CatagoryID) { await SendAnonMessage(message, catagory); await message.DeleteAsync(); } }
HTMLBase getCategoryChannel(SocketCategoryChannel chnl) { var container = new Div(cls: "containerDefault-3tr_sE"); var iconVisibility = new Div(cls: "iconVisibility-fhcwiH wrapper-PY0fhH clickable-536fPF"); container.Children.Add(iconVisibility); var mainContent = new Div(cls: "mainContent-2h-GEV"); iconVisibility.Children.Add(mainContent); mainContent.Children.Add(new H2(cls: "name-3l27Hl container-2ax-kl").WithRawText(chnl.Name.ToUpper())); return(container); }
//send a message to every channel in a catagory that the channel the message was sent in private async Task SendMsgToEveryChanInCatagory(string msg, SocketCategoryChannel catagory) { //get all text channels in the guild the message was sent from var guildTextChannels = catagory.Guild.TextChannels.OfType <SocketTextChannel>(); foreach (var txChannel in guildTextChannels) //go though all channels on server { if (txChannel.Category.Id == 1) //check if channel is in the correct catagory name and send the message { await txChannel.SendMessageAsync(msg); //send message to all } } }
private async Task EndBreakoutSession() { SocketCategoryChannel datingSocketCategory = Context.Guild.GetCategoryChannel(_session.DatingCategory.Id); var socketVoiceChannels = from channel in datingSocketCategory.Channels select channel as SocketVoiceChannel; foreach (SocketVoiceChannel channel in socketVoiceChannels) { await channel.RemoveVoiceChannelAsync(Context.Guild.GetVoiceChannel(_waitingRoomId)); await Task.Delay(500); } }
/// <summary> /// Updates private chat category in database. If no category is specified, the private chat category will be /// reset. /// </summary> /// <param name="context"> The command context. </param> /// <param name="category"> The category to set as the private chat category. </param> public async Task ChangePrivateChat(SocketCommandContext context, SocketCategoryChannel category = null) { var guildSettings = await _botContext.GetGuildSettings(context.Guild.Id); if (category?.Id == guildSettings.PrivChannelsCategory) { await context.Channel.SendMessageAsync( embed : CustomFormats.CreateErrorEmbed($"Private chats category is already {category.Name}!")); return; } guildSettings.PrivChannelsCategory = category?.Id ?? 0; await _botContext.SaveChangesAsync(); }
public DiscordBot(string key) { _bot.MessageReceived += OnMessageReceived; _bot.LoginAsync(TokenType.Bot, key); _bot.StartAsync(); while (_bot.LoginState == LoginState.LoggingIn) { Thread.Sleep(1); } SetStatus(UserStatus.DoNotDisturb, "Setting everything up."); while ((_guild = _bot.GetGuild(GuildId)) == null) { Thread.Sleep(1); } while ((_categoryChannel = _guild.GetCategoryChannel(CategoryId)) == null) { Thread.Sleep(1); } IReadOnlyCollection <SocketGuildUser> sockets; while ((sockets = _guild.Users).Count <= 1) { Thread.Sleep(1); } _players = sockets.Where(user => user.Roles.Any(role => role.Id == RoleId)) .Select(user => { var channelName = user.Nickname.ToLower() + "s-tattoo"; if (_categoryChannel.Channels.FirstOrDefault(c => c.Name == channelName) is not ITextChannel channel) { channel = _guild.CreateTextChannelAsync(channelName, properties => properties.CategoryId = CategoryId).Result; channel.AddPermissionOverwriteAsync(user, new OverwritePermissions(viewChannel: PermValue.Allow, sendMessages: PermValue.Allow)); } var player = new Player(user, channel); _channelIdToPlayer.Add(channel.Id, player); return(player); }).ToArray(); SetStatus(UserStatus.Online, "Working"); }
public async Task SetVoiceCat([Remainder] string arg = "") { var result = from a in Context.Guild.CategoryChannels where a.Name == arg select a; SocketCategoryChannel socketCategory = result.FirstOrDefault(); if (socketCategory == null) { await Context.Channel.SendMessageAsync($"Couldn't find `{arg}` in Guild.CategoryChannels"); return; } gamesVoice = socketCategory; Save(); await Context.Channel.SendMessageAsync($"Gaming voice channel category set to `{arg}`"); }
public async Task TempVoiceCategory(SocketCategoryChannel category = null) { var props = SpService.GetProperties(Context.Guild.Id); if (category == null) { var tempCategory = Context.Guild.GetCategoryChannel(props.TempVoiceCategoryId); if (tempCategory == null) { await Context.Channel.SendMessageAsync("There is no temporary voice channel category set."); return; } await Context.Channel.SendMessageAsync("The temporary voice channel category is " + tempCategory.Name); } props.TempVoiceCategoryId = category.Id; SpService.UpdateProperties(props); await Context.Channel.SendMessageAsync("Set the temporary voice chat category to " + category.Name); }
public async Task Initialize(DiscordSocketClient client) { this.Client = client; this.Client.GuildMemberUpdated += UserUpdated; this.Guild = this.Client.Guilds.First(x => x.Id == OmgSpidersBotDriver.OmgSpidersGuildId); await this.Guild.DownloadUsersAsync(); this.Raiders = this.Guild.Users.Where(x => x.Roles.Any(x => x.Id == FeedbackCommon.TrialRoleId || x.Id == FeedbackCommon.MainRaiderRoleId)); this.FeedbackCategory = this.Guild.GetFeedbackCategory(); this.ArchiveCategory = this.Guild.GetFeedbackArchiveCategory(); this.RaiderChannels = FeedbackCommon.GetExistingChannelsAndTopics(FeedbackCategory); this.ArchiveChannels = FeedbackCommon.GetExistingChannelsAndTopics(ArchiveCategory); await SetupPerRaiderChannels(); await ArchiveChannelsForNonRaiders(); await SortChannelsByName(); }
public MessageHandler(SocketUserMessage socketMessage, List <string> commandList, BotChannelSetting channelSettings = null) { SocketMessage = socketMessage; // verify what to do when these 2 cant be cast SocketGuildUser = socketMessage.Author as SocketGuildUser; SocketTextChannel = socketMessage.Channel as SocketTextChannel; SocketCategoryChannel = SocketTextChannel.Category as SocketCategoryChannel; SocketThreadChannel = socketMessage.Channel as SocketThreadChannel; SocketGuildChannel = socketMessage.Channel as SocketGuildChannel; if (socketMessage.Channel is SocketThreadChannel) { // The message if from a thread -> Replace the SocketChannel to the parent channel if (SocketThreadChannel.ParentChannel is SocketTextChannel) { SocketTextChannel = SocketThreadChannel.ParentChannel as SocketTextChannel; } SocketGuildChannel = SocketThreadChannel.ParentChannel; // TODO Fix the correct setting from the calling method channelSettings = CommonHelper.GetChannelSettingByThreadId(SocketThreadChannel.Id).Setting; } // Dont handle DM's if (SocketGuildChannel == null) { return; } SocketGuild = SocketGuildChannel.Guild; ChannelSettings = channelSettings; CommandInfos = commandList; DatabaseManager = DatabaseManager.Instance(); }
public async Task DeleteCategory([Remainder] string category) { SocketCategoryChannel categoryChannel = Context.Guild.CategoryChannels.FirstOrDefault(c => c.Name == category); if (categoryChannel == null) { await Context.Channel.SendMessageAsync($"Cannot find a category with the name of '{category}'."); return; } foreach (SocketGuildChannel channel in categoryChannel.Channels) { await channel.DeleteAsync(); await Task.Delay(200); } await Task.Delay(500); await categoryChannel.DeleteAsync(); }
private static bool TryParseSocketCategoryChannelArgumentGuild(IGuildCommandContext context, out SocketCategoryChannel value) { value = null; if (ulong.TryParse(context.Arguments.First, out ulong Id)) { value = context.Guild.GetCategoryChannel(Id); return(value != null); } return(false); }
private static bool TryParseSocketCategoryChannelArgument(IDMCommandContext context, out SocketCategoryChannel value) { value = null; return(false); }
/// <summary> /// Creates a new guild (includes role, channel, etc) /// </summary> /// <param name="guild">Discord Server Guild to create channel and role on</param> /// <param name="name">Guild Name</param> /// <param name="color">Guild Display Color</param> /// <param name="captain">Guild Captain</param> /// <param name="members">Guild Users</param> /// <returns>true, if operation succeeds</returns> public static async Task <bool> CreateGuildAsync(SocketGuild guild, string name, GuildColor color, SocketGuildUser captain, List <SocketGuildUser> members) { string errorhint = "Failed a precheck"; try { if (TryGetGuildOfUser(captain.Id, out MinecraftGuild existingCaptainGuild)) { if (existingCaptainGuild.Active || captain.Id == existingCaptainGuild.CaptainId) { errorhint = "Precheck failed on " + captain.Mention; return(false); } else { existingCaptainGuild.MateIds.Remove(captain.Id); existingCaptainGuild.MemberIds.Remove(captain.Id); } } foreach (SocketGuildUser member in members) { if (TryGetGuildOfUser(member.Id, out MinecraftGuild existingMemberGuild)) { if (existingCaptainGuild.Active || member.Id == existingCaptainGuild.CaptainId) { return(false); } else { errorhint = "Precheck failed on " + member.Mention; existingCaptainGuild.MateIds.Remove(member.Id); existingCaptainGuild.MemberIds.Remove(member.Id); } } } errorhint = "Failed to create Guild Role!"; RestRole guildRole = await guild.CreateRoleAsync(name, color : MinecraftGuild.ToDiscordColor(color), isHoisted : true); errorhint = "Move role into position"; await guildRole.ModifyAsync(RoleProperties => { RoleProperties.Position = GUILD_ROLE_POSITION; }); errorhint = "Failed to create Guild Channel!"; SocketCategoryChannel guildCategory = guild.GetChannel(GuildChannelHelper.GuildCategoryId) as SocketCategoryChannel; if (guildCategory == null) { throw new Exception("Could not find Guild Category Channel!"); } RestTextChannel guildChannel = await guild.CreateTextChannelAsync(name, TextChannelProperties => { TextChannelProperties.CategoryId = GuildChannelHelper.GuildCategoryId; TextChannelProperties.Topic = "Private Guild Channel for " + name; }); errorhint = "Failed to copy guildcategories permissions"; foreach (Overwrite overwrite in guildCategory.PermissionOverwrites) { IRole role = guild.GetRole(overwrite.TargetId); if (role != null) { await guildChannel.AddPermissionOverwriteAsync(role, overwrite.Permissions); } } errorhint = "Failed to set Guild Channel Permissions!"; await guildChannel.AddPermissionOverwriteAsync(guildRole, GuildRoleChannelPerms); await guildChannel.AddPermissionOverwriteAsync(captain, CaptainChannelPerms); errorhint = "Failed to add Guild Role to Captain!"; await captain.AddRoleAsync(guildRole); errorhint = "Failed to add GuildCaptain Role to Captain!"; SocketRole captainRole = guild.GetRole(SettingsModel.GuildCaptainRole); if (captainRole != null) { await captain.AddRoleAsync(captainRole); } errorhint = "Failed to add Guild Role to a Member!"; foreach (SocketGuildUser member in members) { await member.AddRoleAsync(guildRole); } errorhint = "Failed to create MinecraftGuild!"; StringBuilder memberPingString = new StringBuilder(); MinecraftGuild minecraftGuild = new MinecraftGuild(guildChannel.Id, guildRole.Id, color, name, captain.Id); for (int i = 0; i < members.Count; i++) { SocketGuildUser member = members[i]; minecraftGuild.MemberIds.Add(member.Id); memberPingString.Append(member.Mention); if (i < members.Count - 1) { memberPingString.Append(", "); } } guilds.Add(minecraftGuild); errorhint = "Failed to save MinecraftGuild!"; await SaveAll(); errorhint = "Failed to send or pin guild info embed"; var infomessage = await guildChannel.SendMessageAsync(embed : GuildHelpEmbed.Build()); await infomessage.PinAsync(); errorhint = "Notify Admins"; await AdminTaskInteractiveMessage.CreateAdminTaskMessage($"Create ingame represantation for guild \"{name}\"", $"Name: `{name}`, Color: `{color}` (`0x{((uint)color).ToString("X")}`)\nCaptain: {captain.Mention}\nMembers: {memberPingString}"); return(true); } catch (Exception e) { await GuildChannelHelper.SendExceptionNotification(e, $"Error creating guild {name}. Hint: {errorhint}"); return(false); } }
public static IDictionary <string, ITextChannel> GetExistingChannelsAndTopics(SocketCategoryChannel category) { var channelsAsSocketText = category.Channels.Select(x => x as ITextChannel).Where(x => x.Id != TeamFeedbackChannelId); var topicsWithUserId = channelsAsSocketText.ToDictionary(x => x.Topic, x => x); return(topicsWithUserId); }
/// <summary> /// Managing channels in specified <paramref name="category"/> with <paramref name="categoryDefinition"/> parameters /// </summary> /// <param name="category">Сategory to check/change channels</param> /// <param name="categoryDefinition">Category parameters</param> /// <returns></returns> private static async Task ProcessChannels(SocketCategoryChannel category, JsonClasses.Category categoryDefinition) { //Reading channels from category and channels limits from definition List <SocketVoiceChannel> channels = category.Channels.ToList().Cast <SocketVoiceChannel>().ToList(); List <int?> channelsCapacity = categoryDefinition.ChannelsCapacity; //Sorting channels in right order (from 1 to biggest number after channel name) channels.Sort(new ChannelsComparer()); //If there is more channels, than default if (channels.Count >= categoryDefinition.DefaultChannelsCount * channelsCapacity.Count) { //Counting channels with specified in ChannelsCapacity limits List <int> uniqueChannelsCount = new List <int>(); foreach (int?i in channelsCapacity) { uniqueChannelsCount.Add(channels.Where(x => x.UserLimit == i && x.Users.Count < 1).Count()); } //Iterating through channels count for (int i = 0; i < uniqueChannelsCount.Count; i++) { //If there is more (with specified limit) channels than default if (uniqueChannelsCount[i] > categoryDefinition.DefaultChannelsCount) { //Delete channel (iterating from end, searching empty channel with specified limit) uniqueChannelsCount[i]--; for (int j = channels.Count - 1; j + 1 > categoryDefinition.DefaultChannelsCount * channelsCapacity.Count; j--) { if (channels[j].Users.Count > 0) { break; } if (channels[j].UserLimit == channelsCapacity[i]) { await channels[j].DeleteAsync(); channels.RemoveAt(j); } } } } //Iterating through channels count for (int i = 0; i < uniqueChannelsCount.Count; i++) { //If there is less (with specified limit) channels than default if (uniqueChannelsCount[i] < categoryDefinition.DefaultChannelsCount) { //Creating voice channel await category.Guild.CreateVoiceChannelAsync($"{channels[0].Name.Substring(0, channels[0].Name.LastIndexOf(' '))} {channels.Count + 1}", (properties) => { properties.CategoryId = category.Id; properties.UserLimit = channelsCapacity[i]; }); } } } else { //There is less than default channels, creating missing for (int i = channels.Count; i < categoryDefinition.DefaultChannelsCount * channelsCapacity.Count; ++i) { await category.Guild.CreateVoiceChannelAsync($"{channels[0].Name.Substring(0, channels[0].Name.LastIndexOf(' '))} {i + 1}", (properties) => { properties.CategoryId = category.Id; properties.UserLimit = channelsCapacity[i % channelsCapacity.Count]; }); } } }
private static ChannelQualifier ChannelCategoryQualifier(SocketCategoryChannel category) { return(channel => category.Channels.Any(categoryChannel => categoryChannel.Id == channel.Id)); }
public async Task StartGame(SocketCommandContext context, string nameset) { if (gamesInProgress.ContainsKey(context.Guild.Id)) { gamesInProgress[context.Guild.Id] = true; } else { gamesInProgress.Add(context.Guild.Id, true); } string settings = DBUtils.CheckDBsForServer(context.Guild.Id.ToString()); if (GuildUtils.NumberOfOnlineUsers(context.Guild) < int.Parse(Settings.ReadSetting(settings, "minplayers")) && !MafiaBot.DEBUG_MODE) { await context.Channel.SendMessageAsync("\u274C Looks like the Mafia's finished everyone off. Try again when more people are online!"); return; } FileStream fs = File.OpenRead(AppDomain.CurrentDomain.BaseDirectory + "/name-sets/" + nameset + ".json"); StreamReader reader = new StreamReader(fs); Nameset names = JsonConvert.DeserializeObject <Nameset>(reader.ReadToEnd()); fs.Close(); fs.Dispose(); reader.Close(); reader.Dispose(); //CREATE CATEGORY SocketCategoryChannel cat = await GuildUtils.AddCategoryChannel("Mafia Game Channels", context.Guild); await GuildUtils.RemoveAllCategoryChannels(cat); List <RestTextChannel> channels = new List <RestTextChannel>(); //SETTING UP CHANNELS --------------------- RestTextChannel town = await GuildUtils.AddChannel("Town", context.Guild, catergory : cat.Id); await GuildUtils.SetAccessPermissions(town, (new List <IUser>(context.Guild.Users)).ToArray(), GuildUtils.CANT_SEND); channels.Add(town); RestTextChannel mafia = await GuildUtils.AddChannel(names.mafia, context.Guild, catergory : cat.Id); await GuildUtils.SetAccessPermissions(mafia, (new List <IUser>(context.Guild.Users)).ToArray(), GuildUtils.CANT_SEND); await GuildUtils.SetAccessPermissions(mafia, (new List <IUser>(context.Guild.Users)).ToArray(), GuildUtils.BANNED_PERMISSIONS); channels.Add(mafia); RestTextChannel doctor = await GuildUtils.AddChannel(names.doctor, context.Guild, catergory : cat.Id); await GuildUtils.SetAccessPermissions(doctor, (new List <IUser>(context.Guild.Users)).ToArray(), GuildUtils.CANT_SEND); await GuildUtils.SetAccessPermissions(doctor, (new List <IUser>(context.Guild.Users)).ToArray(), GuildUtils.BANNED_PERMISSIONS); channels.Add(doctor); RestTextChannel detective = await GuildUtils.AddChannel(names.cop, context.Guild, catergory : cat.Id); await GuildUtils.SetAccessPermissions(detective, (new List <IUser>(context.Guild.Users)).ToArray(), GuildUtils.CANT_SEND); await GuildUtils.SetAccessPermissions(detective, (new List <IUser>(context.Guild.Users)).ToArray(), GuildUtils.BANNED_PERMISSIONS); channels.Add(detective); CreateGame(context, settings, channels.ToArray(), names); return; }
public static SocketVoiceChannel GetAllVoiceChannelsInCategory(this SocketCategoryChannel category) { Console.WriteLine("TODO SocketVoiceChannel GetAllVoiceChannelsInCategory"); return(null); }