public async Task ChannelDestroyed(SocketChannel channel) { try { ServerList server = ServerListsManager.GetServer(((SocketGuildChannel)channel).Guild); //Check the server's welcome settings await BotCheckServerSettings.CheckServerWelcomeSettings(server); //Check the bot's auto voice channels BotCheckServerSettings.CheckServerVoiceChannels(server); BotCheckServerSettings.CheckServerActiveVoiceChannels(server); //Check the bot's rule message channel await BotCheckServerSettings.CheckServerRuleMessageChannel(server); } catch (Exception ex) { #if DEBUG Logger.Log(ex.ToString(), LogVerbosity.Error); #else Logger.Log(ex.Message, LogVerbosity.Error); #endif } }
public async Task RoleDeleted(SocketRole role) { try { SocketGuild guild = role.Guild; ServerList server = ServerListsManager.GetServer(guild); //Setup the dm channel even though we might not even use it just makes it so I don't have to repeat this a whole bunch of times. IDMChannel dm = await guild.Owner.GetOrCreateDMChannelAsync(); //The rule role was deleted if (role.Id == server.RuleRoleId) { server.RuleEnabled = false; ServerListsManager.SaveServerList(); await dm.SendMessageAsync( $"Your rule reaction on the Discord server **{guild.Name}** has been disabled due to the role being deleted.\n" + "You can enable it again after setting a new role with the command `setuprulerole` and then enabling the feature again with `togglerulereaction`."); return; } //Check all server role points roles List <ServerRolePoints> rolePointsToRemove = server.ServerRolePoints.Where(rolePoint => role.Id == rolePoint.RoleId).ToList(); foreach (ServerRolePoints toRemove in rolePointsToRemove) { await dm.SendMessageAsync( $"The **{role.Name}** was deleted which was apart of the {toRemove.PointsRequired} server points role. This server points role was deleted. ({guild.Name})"); server.ServerRolePoints.Remove(toRemove); ServerListsManager.SaveServerList(); return; } //Check to see if all the role to role pings still exist List <ServerRoleToRoleMention> rolesToRemove = server.RoleToRoleMentions .Where(roles => roles.RoleId == role.Id || roles.RoleNotToMentionId == role.Id).ToList(); foreach (ServerRoleToRoleMention roleToRemove in rolesToRemove) { await dm.SendMessageAsync( $"The **{role.Name}** role was deleted which was apart of the **{roleToRemove.RoleNotToMentionId}** => **{roleToRemove.RoleId}**. This role to role ping was deleted. ({guild.Name})"); server.RoleToRoleMentions.Remove(roleToRemove); ServerListsManager.SaveServerList(); return; } //Check all permission roles BotCheckServerSettings.CheckServerPerms(server); } catch (Exception ex) { Logger.Error("An error occured while managing role deleted event! {@Exception}", ex); } }
public async Task ChannelDestroyed(SocketChannel channel) { try { ServerList server = ServerListsManager.GetServer(((SocketGuildChannel)channel).Guild); //Check the server's welcome settings await BotCheckServerSettings.CheckServerWelcomeSettings(server); //Check the bot's auto voice channels BotCheckServerSettings.CheckServerVoiceChannels(server); BotCheckServerSettings.CheckServerActiveVoiceChannels(server); //Check the bot's rule message channel await BotCheckServerSettings.CheckServerRuleMessageChannel(server); } catch (Exception ex) { Logger.Error("An error occured while managing channel destroyed event! {@Exception}", ex); } }