public async Task AddLogAsync() { if (!Context.GetIsSudo()) { await ReplyAsync("You are not permitted to use this command.").ConfigureAwait(false); return; } var c = Context.Channel; var cid = c.Id; if (Channels.TryGetValue(cid, out _)) { await ReplyAsync("Already logging here.").ConfigureAwait(false); return; } AddLogChannel(c, cid); // Add to discord global loggers (saves on program close) var loggers = ReusableActions.GetListFromString(SysCordInstance.Self.Hub.Config.GlobalDiscordLoggers); loggers.Add(cid.ToString()); SysCordInstance.Self.Hub.Config.GlobalDiscordLoggers = string.Join(", ", new HashSet <string>(loggers)); await ReplyAsync("Added logging output to this channel!").ConfigureAwait(false); }
public async Task UnBlackListIDs([Summary("Comma Separated Discord IDs")][Remainder] string content) { if (!await IsOwner(Context.Message.Author).ConfigureAwait(false)) { await ReplyAsync("You are not permitted to use this command.").ConfigureAwait(false); return; } var users = content.Split(new[] { ",", ", ", " " }, StringSplitOptions.RemoveEmptyEntries); var userids = ReusableActions.GetListFromString(SysCordInstance.Self.Hub.Config.DiscordBlackList); var iter = userids.ToList(); // Deepcopy foreach (var user in iter) { if (!ulong.TryParse(user, out var uid) || !users.Contains(uid.ToString())) { continue; } userids.Remove(uid.ToString()); } SysCordInstance.Self.Hub.Config.DiscordBlackList = string.Join(", ", new HashSet <string>(userids)); // empty string joins await ReplyAsync("Un-Blacklisted listed IDs from using the bot!").ConfigureAwait(false); }
public async Task UnBlackListUsers([Summary("Mentioned users that need to be unblacklisted")][Remainder] string content) { if (!await IsOwner(Context.Message.Author).ConfigureAwait(false)) { await ReplyAsync("You are not permitted to use this command.").ConfigureAwait(false); return; } var users = Context.Message.MentionedUsers.Select(z => z.Id); var blusers = ReusableActions.GetListFromString(SysCordInstance.Self.Hub.Config.DiscordBlackList); var iter = blusers.ToList(); // Deepclone foreach (var ch in iter) { if (!ulong.TryParse(ch, out var uid) || !users.Contains(uid)) { continue; } blusers.Remove(uid.ToString()); } SysCordInstance.Self.Hub.Config.DiscordBlackList = string.Join(", ", blusers); await ReplyAsync("Un-Blacklisted mentioned users from using the bot!").ConfigureAwait(false); }
public async Task RemoveSudoUsers([Summary("Mentioned users will be removed from the global sudo list")][Remainder] string content) { if (!await IsOwner(Context.Message.Author).ConfigureAwait(false)) { await ReplyAsync("You are not permitted to use this command.").ConfigureAwait(false); return; } var users = Context.Message.MentionedUsers; var userids = users.Select(z => z.Id.ToString()); var sudos = ReusableActions.GetListFromString(SysCordInstance.Self.Hub.Config.GlobalSudoList); var iter = sudos.ToList(); // Deepclone foreach (var ch in iter) { if (!ulong.TryParse(ch, out var uid) || !userids.Contains(uid.ToString())) { continue; } sudos.Remove(uid.ToString()); } SysCordInstance.Self.Hub.Config.GlobalSudoList = string.Join(", ", new HashSet <string>(sudos)); // unique values await ReplyAsync("Mentioned users are no longer sudo users for the bot!").ConfigureAwait(false); }
public static void RestoreLogging(DiscordSocketClient discord) { var cfg = SysCordInstance.Settings; var channels = ReusableActions.GetListFromString(cfg.LoggingChannels); foreach (var ch in channels) { if (!ulong.TryParse(ch, out var cid)) { continue; } var c = (ISocketMessageChannel)discord.GetChannel(cid); AddLogChannel(c, cid); } LogUtil.LogInfo("Added logging to Discord channel(s) on Bot startup.", "Discord"); }
public static void RestoreChannels(DiscordSocketClient discord) { var cfg = SysCordInstance.Settings; var channels = ReusableActions.GetListFromString(cfg.EchoChannels); foreach (var ch in channels) { if (!ulong.TryParse(ch, out var cid)) { continue; } var c = (ISocketMessageChannel)discord.GetChannel(cid); AddEchoChannel(c, cid); } EchoUtil.Echo("Added echo notification to Discord channel(s) on Bot startup."); }
public async Task BlackListUsers([Summary("Mentioned users that need to be blacklisted")][Remainder] string content) { if (!await IsOwner(Context.Message.Author).ConfigureAwait(false)) { await ReplyAsync("You are not permitted to use this command.").ConfigureAwait(false); return; } var users = Context.Message.MentionedUsers; var userids = users.Select(z => z.Id.ToString()); var blacklist = ReusableActions.GetListFromString(SysCordInstance.Self.Hub.Config.DiscordBlackList); blacklist.AddRange(userids); SysCordInstance.Self.Hub.Config.DiscordBlackList = string.Join(", ", new HashSet <string>(blacklist)); // unique values await ReplyAsync("Blacklisted mentioned users from using the bot!").ConfigureAwait(false); }
public async Task SudoUsers([Summary("Mentioned users will be added to the global sudo list")][Remainder] string content) { if (!await IsOwner(Context.Message.Author).ConfigureAwait(false)) { await ReplyAsync("You are not permitted to use this command.").ConfigureAwait(false); return; } var users = Context.Message.MentionedUsers; var userids = users.Select(z => z.Id.ToString()); var sudos = ReusableActions.GetListFromString(SysCordInstance.Self.Hub.Config.GlobalSudoList); sudos.AddRange(userids); SysCordInstance.Self.Hub.Config.GlobalSudoList = string.Join(", ", new HashSet <string>(sudos)); // unique values await ReplyAsync("Mentioned users are now sudo users for the bot!").ConfigureAwait(false); }
public async Task AddEchoAsync() { var c = Context.Channel; var cid = c.Id; if (Channels.TryGetValue(cid, out _)) { await ReplyAsync("Already start notifying here.").ConfigureAwait(false); return; } AddEchoChannel(c, cid); // Add to discord global loggers (saves on program close) var loggers = ReusableActions.GetListFromString(SysCordInstance.Settings.EchoChannels); loggers.Add(cid.ToString()); SysCordInstance.Settings.EchoChannels = string.Join(", ", new HashSet <string>(loggers)); await ReplyAsync("Added Echo output to this channel!").ConfigureAwait(false); }