diff --git a/Boyfriend/Boyfriend.cs b/Boyfriend/Boyfriend.cs index d757ccc..9bc80a9 100644 --- a/Boyfriend/Boyfriend.cs +++ b/Boyfriend/Boyfriend.cs @@ -8,11 +8,10 @@ namespace Boyfriend; public static class Boyfriend { public static readonly StringBuilder StringBuilder = new(); - private static readonly Dictionary GuildCache = new(); private static readonly DiscordSocketConfig Config = new() { MessageCacheSize = 250, - GatewayIntents = GatewayIntents.All, + GatewayIntents = GatewayIntents.AllUnprivileged | GatewayIntents.MessageContent | GatewayIntents.GuildMembers, AlwaysDownloadUsers = true, AlwaysResolveStickers = false, AlwaysDownloadDefaultStickers = false, @@ -37,23 +36,20 @@ public static class Boyfriend { new(); public static readonly Dictionary DefaultConfig = new() { - { "Lang", "en" }, { "Prefix", "!" }, - { "RemoveRolesOnMute", "false" }, - { "SendWelcomeMessages", "true" }, + { "Lang", "en" }, { "ReceiveStartupMessages", "false" }, - { "FrowningFace", "true" }, - { "WelcomeMessage", Messages.DefaultWelcomeMessage }, - { "EventStartedReceivers", "interested,role" }, + { "WelcomeMessage", "default" }, + { "SendWelcomeMessages", "true" }, + { "BotLogChannel", "0" }, { "StarterRole", "0" }, { "MuteRole", "0" }, - { "EventNotifyReceiverRole", "0" }, - { "AdminLogChannel", "0" }, - { "BotLogChannel", "0" }, - { "EventCreatedChannel", "0" }, - { "EventStartedChannel", "0" }, - { "EventCancelledChannel", "0" }, - { "EventCompletedChannel", "0" }, + { "RemoveRolesOnMute", "false" }, + { "FrowningFace", "true" }, + + { "EventStartedReceivers", "interested,role" }, + { "EventNotificationRole", "0" }, + { "EventNotificationChannel", "0" }, { "EventEarlyNotificationOffset", "0" } }; @@ -81,8 +77,29 @@ public static class Boyfriend { } private static Task Log(LogMessage msg) { - Console.WriteLine(msg.ToString()); + switch (msg.Severity) { + case LogSeverity.Critical: + Console.ForegroundColor = ConsoleColor.DarkRed; + Console.Error.WriteLine(msg.ToString()); + break; + case LogSeverity.Error: + Console.ForegroundColor = ConsoleColor.Red; + Console.Error.WriteLine(msg.ToString()); + break; + case LogSeverity.Warning: + Console.ForegroundColor = ConsoleColor.Yellow; + Console.WriteLine(msg.ToString()); + break; + case LogSeverity.Info: + Console.WriteLine(msg.ToString()); + break; + case LogSeverity.Verbose: + case LogSeverity.Debug: + default: return Task.CompletedTask; + } + + Console.ResetColor(); return Task.CompletedTask; } @@ -95,9 +112,6 @@ public static class Boyfriend { } public static Dictionary GetGuildConfig(ulong id) { - if (!RemovedRolesDictionary.ContainsKey(id)) - RemovedRolesDictionary.Add(id, new Dictionary>()); - if (GuildConfigDictionary.TryGetValue(id, out var cfg)) return cfg; var path = $"config_{id}.json"; @@ -110,13 +124,12 @@ public static class Boyfriend { if (config.Keys.Count < DefaultConfig.Keys.Count) { // ReSharper disable once ForeachCanBePartlyConvertedToQueryUsingAnotherGetEnumerator - // Avoids a closure allocation with the config variable + // Conversion will result in a lot of memory allocations foreach (var key in DefaultConfig.Keys) if (!config.ContainsKey(key)) config.Add(key, DefaultConfig[key]); } else if (config.Keys.Count > DefaultConfig.Keys.Count) { - foreach (var key in config.Keys.Where(key => !DefaultConfig.ContainsKey(key))) - config.Remove(key); + foreach (var key in config.Keys.Where(key => !DefaultConfig.ContainsKey(key))) config.Remove(key); } GuildConfigDictionary.Add(id, config); @@ -126,10 +139,9 @@ public static class Boyfriend { public static Dictionary> GetRemovedRoles(ulong id) { if (RemovedRolesDictionary.TryGetValue(id, out var dict)) return dict; - var path = $"removedroles_{id}.json"; - if (!File.Exists(path)) File.Create(path); + if (!File.Exists(path)) File.Create(path).Dispose(); var json = File.ReadAllText(path); var removedRoles = JsonConvert.DeserializeObject>>(json) @@ -139,18 +151,4 @@ public static class Boyfriend { return removedRoles; } - - public static SocketGuild FindGuild(ulong channel) { - if (GuildCache.TryGetValue(channel, out var gld)) return gld; - foreach (var guild in Client.Guilds) { - // ReSharper disable once LoopCanBeConvertedToQuery - foreach (var x in guild.Channels) - if (x.Id == channel) { - GuildCache.Add(channel, guild); - return guild; - } - } - - throw new Exception("Could not find guild by channel!"); - } } diff --git a/Boyfriend/CommandProcessor.cs b/Boyfriend/CommandProcessor.cs index 9d3b7ea..da21d00 100644 --- a/Boyfriend/CommandProcessor.cs +++ b/Boyfriend/CommandProcessor.cs @@ -27,7 +27,6 @@ public sealed class CommandProcessor { private readonly List _tasks = new(); public readonly SocketCommandContext Context; - private bool _serverBlacklisted; public bool ConfigWriteScheduled = false; @@ -39,6 +38,7 @@ public sealed class CommandProcessor { var guild = Context.Guild; var config = Boyfriend.GetGuildConfig(guild.Id); var muteRole = Utils.GetMuteRole(guild); + Utils.SetCurrentLanguage(guild.Id); if (GetMember().Roles.Contains(muteRole)) { await Context.Message.ReplyAsync(Messages.UserCannotUnmuteThemselves); @@ -49,15 +49,11 @@ public sealed class CommandProcessor { var cleanList = Context.Message.CleanContent.Split("\n"); for (var i = 0; i < list.Length; i++) { RunCommandOnLine(list[i], cleanList[i], config["Prefix"]); - if (_serverBlacklisted) { - await Context.Message.ReplyAsync(Messages.ServerBlacklisted); - return; - } if (_stackedReplyMessage.Length > 0) _ = Context.Channel.TriggerTypingAsync(); var member = Boyfriend.Client.GetGuild(Context.Guild.Id) .GetUser(Context.User.Id); // Getting an up-to-date copy - if (member == null || member.Roles.Contains(muteRole) + if (member is null || member.Roles.Contains(muteRole) || member.TimedOutUntil.GetValueOrDefault(DateTimeOffset.UnixEpoch).ToUnixTimeSeconds() > DateTimeOffset.Now.ToUnixTimeSeconds()) break; } @@ -89,25 +85,25 @@ public sealed class CommandProcessor { } public void Audit(string action, bool isPublic = true) { - var format = string.Format(Messages.FeedbackFormat, Context.User.Mention, action); + var format = $"*[{Context.User.Mention}: {action}]*"; if (isPublic) Utils.SafeAppendToBuilder(_stackedPublicFeedback, format, Context.Guild.SystemChannel); - Utils.SafeAppendToBuilder(_stackedPrivateFeedback, format, Utils.GetAdminLogChannel(Context.Guild.Id)); - if (_tasks.Count == 0) SendFeedbacks(false); + Utils.SafeAppendToBuilder(_stackedPrivateFeedback, format, Utils.GetBotLogChannel(Context.Guild.Id)); + if (_tasks.Count is 0) SendFeedbacks(false); } private void SendFeedbacks(bool reply = true) { if (reply && _stackedReplyMessage.Length > 0) _ = Context.Message.ReplyAsync(_stackedReplyMessage.ToString(), false, null, AllowedMentions.None); - var adminChannel = Utils.GetAdminLogChannel(Context.Guild.Id); + var adminChannel = Utils.GetBotLogChannel(Context.Guild.Id); var systemChannel = Context.Guild.SystemChannel; - if (_stackedPrivateFeedback.Length > 0 && adminChannel != null && + if (_stackedPrivateFeedback.Length > 0 && adminChannel is not null && adminChannel.Id != Context.Message.Channel.Id) { _ = Utils.SilentSendAsync(adminChannel, _stackedPrivateFeedback.ToString()); _stackedPrivateFeedback.Clear(); } - if (_stackedPublicFeedback.Length > 0 && systemChannel != null && systemChannel.Id != adminChannel?.Id + if (_stackedPublicFeedback.Length > 0 && systemChannel is not null && systemChannel.Id != adminChannel?.Id && systemChannel.Id != Context.Message.Channel.Id) { _ = Utils.SilentSendAsync(systemChannel, _stackedPublicFeedback.ToString()); _stackedPublicFeedback.Clear(); @@ -115,7 +111,7 @@ public sealed class CommandProcessor { } public string? GetRemaining(string[] from, int startIndex, string? argument) { - if (startIndex >= from.Length && argument != null) + if (startIndex >= from.Length && argument is not null) Utils.SafeAppendToBuilder(_stackedReplyMessage, $"{MissingArgument}{Utils.GetMessage($"Missing{argument}")}", Context.Message); else return string.Join(" ", from, startIndex, from.Length - startIndex); @@ -129,8 +125,8 @@ public sealed class CommandProcessor { return null; } - var user = Utils.ParseUser(args[index]); - if (user == null && argument != null) + var user = Boyfriend.Client.GetUser(Utils.ParseMention(args[index])); + if (user is null && argument is not null) Utils.SafeAppendToBuilder(_stackedReplyMessage, $"{InvalidArgument}{string.Format(Messages.InvalidUser, Utils.Wrap(cleanArgs[index]))}", Context.Message); @@ -154,7 +150,7 @@ public sealed class CommandProcessor { public SocketGuildUser? GetMember(SocketUser user, string? argument) { var member = Context.Guild.GetUser(user.Id); - if (member == null && argument != null) + if (member is null && argument is not null) Utils.SafeAppendToBuilder(_stackedReplyMessage, $":x: {Messages.UserNotInGuild}", Context.Message); return member; } @@ -167,7 +163,7 @@ public sealed class CommandProcessor { } var member = Context.Guild.GetUser(Utils.ParseMention(args[index])); - if (member == null && argument != null) + if (member is null && argument is not null) Utils.SafeAppendToBuilder(_stackedReplyMessage, $"{InvalidArgument}{string.Format(Messages.InvalidMember, Utils.Wrap(cleanArgs[index]))}", Context.Message); @@ -186,7 +182,7 @@ public sealed class CommandProcessor { } var id = Utils.ParseMention(args[index]); - if (Context.Guild.GetBanAsync(id) == null) { + if (Context.Guild.GetBanAsync(id) is null) { Utils.SafeAppendToBuilder(_stackedReplyMessage, Messages.UserNotBanned, Context.Message); return null; } @@ -209,7 +205,7 @@ public sealed class CommandProcessor { return null; } - if (argument == null) return i; + if (argument is null) return i; if (i < min) { Utils.SafeAppendToBuilder(_stackedReplyMessage, $"{InvalidArgument}{string.Format(Utils.GetMessage($"{argument}TooSmall"), min.ToString())}", @@ -232,7 +228,7 @@ public sealed class CommandProcessor { int days = 0, hours = 0, minutes = 0, seconds = 0; foreach (var c in chars) if (char.IsDigit(c)) { numberBuilder.Append(c); } else { - if (numberBuilder.Length == 0) return infinity; + if (numberBuilder.Length is 0) return infinity; switch (c) { case 'd' or 'D' or 'д' or 'Д': days += int.Parse(numberBuilder.ToString()); diff --git a/Boyfriend/Commands/BanCommand.cs b/Boyfriend/Commands/BanCommand.cs index 99676eb..b4d8e1b 100644 --- a/Boyfriend/Commands/BanCommand.cs +++ b/Boyfriend/Commands/BanCommand.cs @@ -8,19 +8,17 @@ public sealed class BanCommand : ICommand { public async Task RunAsync(CommandProcessor cmd, string[] args, string[] cleanArgs) { var toBan = cmd.GetUser(args, cleanArgs, 0, "ToBan"); - if (toBan == null || !cmd.HasPermission(GuildPermission.BanMembers)) return; + if (toBan is null || !cmd.HasPermission(GuildPermission.BanMembers)) return; var memberToBan = cmd.GetMember(toBan, null); - if (memberToBan != null && !cmd.CanInteractWith(memberToBan, "Ban")) return; + if (memberToBan is not null && !cmd.CanInteractWith(memberToBan, "Ban")) return; var duration = CommandProcessor.GetTimeSpan(args, 1); var reason = cmd.GetRemaining(args, duration.TotalSeconds < 1 ? 1 : 2, "BanReason"); - if (reason == null) return; - - await BanUser(cmd, toBan, duration, reason); + if (reason is not null) await BanUserAsync(cmd, toBan, duration, reason); } - public static async Task BanUser(CommandProcessor cmd, SocketUser toBan, TimeSpan duration, string reason) { + private static async Task BanUserAsync(CommandProcessor cmd, SocketUser toBan, TimeSpan duration, string reason) { var author = cmd.Context.User; var guild = cmd.Context.Guild; await Utils.SendDirectMessage(toBan, diff --git a/Boyfriend/Commands/ClearCommand.cs b/Boyfriend/Commands/ClearCommand.cs index 9c46ec8..ad5408e 100644 --- a/Boyfriend/Commands/ClearCommand.cs +++ b/Boyfriend/Commands/ClearCommand.cs @@ -12,7 +12,7 @@ public sealed class ClearCommand : ICommand { if (!cmd.HasPermission(GuildPermission.ManageMessages)) return; var toDelete = cmd.GetNumberRange(cleanArgs, 0, 1, 200, "ClearAmount"); - if (toDelete == null) return; + if (toDelete is null) return; var messages = await channel.GetMessagesAsync((int)(toDelete + 1)).FlattenAsync(); var user = (SocketGuildUser)cmd.Context.User; diff --git a/Boyfriend/Commands/KickCommand.cs b/Boyfriend/Commands/KickCommand.cs index b3eda26..5a32f93 100644 --- a/Boyfriend/Commands/KickCommand.cs +++ b/Boyfriend/Commands/KickCommand.cs @@ -8,15 +8,14 @@ public sealed class KickCommand : ICommand { public async Task RunAsync(CommandProcessor cmd, string[] args, string[] cleanArgs) { var toKick = cmd.GetMember(args, cleanArgs, 0, "ToKick"); - if (toKick == null || !cmd.HasPermission(GuildPermission.KickMembers)) return; + if (toKick is null || !cmd.HasPermission(GuildPermission.KickMembers)) return; - if (!cmd.CanInteractWith(toKick, "Kick")) return; - - await KickMemberAsync(cmd, toKick, cmd.GetRemaining(args, 1, "KickReason")); + if (cmd.CanInteractWith(toKick, "Kick")) + await KickMemberAsync(cmd, toKick, cmd.GetRemaining(args, 1, "KickReason")); } private static async Task KickMemberAsync(CommandProcessor cmd, SocketGuildUser toKick, string? reason) { - if (reason == null) return; + if (reason is null) return; var guildKickMessage = $"({cmd.Context.User}) {reason}"; await Utils.SendDirectMessage(toKick, diff --git a/Boyfriend/Commands/MuteCommand.cs b/Boyfriend/Commands/MuteCommand.cs index bc608f9..fb258ca 100644 --- a/Boyfriend/Commands/MuteCommand.cs +++ b/Boyfriend/Commands/MuteCommand.cs @@ -9,15 +9,15 @@ public sealed class MuteCommand : ICommand { public async Task RunAsync(CommandProcessor cmd, string[] args, string[] cleanArgs) { var toMute = cmd.GetMember(args, cleanArgs, 0, "ToMute"); - if (toMute == null) return; + if (toMute is null) return; var duration = CommandProcessor.GetTimeSpan(args, 1); var reason = cmd.GetRemaining(args, duration.TotalSeconds < 1 ? 1 : 2, "MuteReason"); - if (reason == null) return; + if (reason is null) return; var role = Utils.GetMuteRole(cmd.Context.Guild); - if ((role != null && toMute.Roles.Contains(role)) - || (toMute.TimedOutUntil != null + if ((role is not null && toMute.Roles.Contains(role)) + || (toMute.TimedOutUntil is not null && toMute.TimedOutUntil.Value.ToUnixTimeSeconds() > DateTimeOffset.Now.ToUnixTimeSeconds())) { cmd.Reply(Messages.MemberAlreadyMuted, ":x: "); @@ -33,9 +33,8 @@ public sealed class MuteCommand : ICommand { cmd.Reply(Messages.RolesReturned, ":warning: "); } - if (!cmd.HasPermission(GuildPermission.ModerateMembers) || !cmd.CanInteractWith(toMute, "Mute")) return; - - await MuteMemberAsync(cmd, toMute, duration, reason); + if (cmd.HasPermission(GuildPermission.ModerateMembers) && cmd.CanInteractWith(toMute, "Mute")) + await MuteMemberAsync(cmd, toMute, duration, reason); } private static async Task MuteMemberAsync(CommandProcessor cmd, SocketGuildUser toMute, @@ -46,7 +45,7 @@ public sealed class MuteCommand : ICommand { var role = Utils.GetMuteRole(guild); var hasDuration = duration.TotalSeconds > 0; - if (role != null) { + if (role is not null) { if (config["RemoveRolesOnMute"] is "true") { var rolesRemoved = new List(); foreach (var userRole in toMute.Roles) diff --git a/Boyfriend/Commands/SettingsCommand.cs b/Boyfriend/Commands/SettingsCommand.cs index 34d2bc5..baccdc2 100644 --- a/Boyfriend/Commands/SettingsCommand.cs +++ b/Boyfriend/Commands/SettingsCommand.cs @@ -11,7 +11,7 @@ public sealed class SettingsCommand : ICommand { var guild = cmd.Context.Guild; var config = Boyfriend.GetGuildConfig(guild.Id); - if (args.Length == 0) { + if (args.Length is 0) { var currentSettings = Boyfriend.StringBuilder.AppendLine(Messages.CurrentSettings); foreach (var setting in Boyfriend.DefaultConfig) { @@ -19,20 +19,14 @@ public sealed class SettingsCommand : ICommand { var currentValue = config[setting.Key]; if (setting.Key.EndsWith("Channel")) { - if (guild.GetTextChannel(Convert.ToUInt64(currentValue)) != null) - format = "<#{0}>"; - else - currentValue = Messages.ChannelNotSpecified; + if (guild.GetTextChannel(ulong.Parse(currentValue)) is not null) format = "<#{0}>"; + else currentValue = Messages.ChannelNotSpecified; } else if (setting.Key.EndsWith("Role")) { - if (guild.GetRole(Convert.ToUInt64(currentValue)) != null) - format = "<@&{0}>"; - else - currentValue = Messages.RoleNotSpecified; + if (guild.GetRole(ulong.Parse(currentValue)) is not null) format = "<@&{0}>"; + else currentValue = Messages.RoleNotSpecified; } else { - if (IsBool(currentValue)) - currentValue = YesOrNo(currentValue is "true"); - else - format = Utils.Wrap("{0}")!; + if (!IsBool(currentValue)) format = Utils.Wrap("{0}")!; + else currentValue = YesOrNo(currentValue is "true"); } currentSettings.Append($"{Utils.GetMessage($"Settings{setting.Key}")} (`{setting.Key}`): ") @@ -65,11 +59,11 @@ public sealed class SettingsCommand : ICommand { if (args.Length >= 2) { value = cmd.GetRemaining(args, 1, "Setting"); - if (value == null) return Task.CompletedTask; + if (value is null) return Task.CompletedTask; if (selectedSetting is "EventStartedReceivers") { value = value.Replace(" ", "").ToLower(); - if (value.StartsWith(",") || value.Count(x => x == ',') > 1 || - (!value.Contains("interested") && !value.Contains("role"))) { + if (value.StartsWith(",") || value.Count(x => x is ',') > 1 || + (!value.Contains("interested") && !value.Contains("users") && !value.Contains("role"))) { cmd.Reply(Messages.InvalidSettingValue, ":x: "); return Task.CompletedTask; } @@ -91,14 +85,12 @@ public sealed class SettingsCommand : ICommand { var localizedSelectedSetting = Utils.GetMessage($"Settings{selectedSetting}"); var mention = Utils.ParseMention(value); - if (mention != 0 && selectedSetting is not "WelcomeMessage") value = mention.ToString(); + if (mention is not 0 && selectedSetting is not "WelcomeMessage") value = mention.ToString(); var formatting = Utils.Wrap("{0}")!; if (selectedSetting is not "WelcomeMessage") { - if (selectedSetting.EndsWith("Channel")) - formatting = "<#{0}>"; - if (selectedSetting.EndsWith("Role")) - formatting = "<@&{0}>"; + if (selectedSetting.EndsWith("Channel")) formatting = "<#{0}>"; + if (selectedSetting.EndsWith("Role")) formatting = "<@&{0}>"; } var formattedValue = selectedSetting switch { @@ -110,9 +102,7 @@ public sealed class SettingsCommand : ICommand { }; if (value is "reset" or "default") { - config[selectedSetting] = selectedSetting is "WelcomeMessage" - ? Messages.DefaultWelcomeMessage - : Boyfriend.DefaultConfig[selectedSetting]; + config[selectedSetting] = Boyfriend.DefaultConfig[selectedSetting]; } else { if (value == config[selectedSetting]) { cmd.Reply(string.Format(Messages.SettingsNothingChanged, localizedSelectedSetting, formattedValue), @@ -120,17 +110,17 @@ public sealed class SettingsCommand : ICommand { return Task.CompletedTask; } - if (selectedSetting is "Lang" && value is not "ru" and not "en" and not "mctaylors-ru") { + if (selectedSetting is "Lang" && !Utils.CultureInfoCache.ContainsKey(value)) { cmd.Reply(Messages.LanguageNotSupported, ":x: "); return Task.CompletedTask; } - if (selectedSetting.EndsWith("Channel") && guild.GetTextChannel(mention) == null) { + if (selectedSetting.EndsWith("Channel") && guild.GetTextChannel(mention) is null) { cmd.Reply(Messages.InvalidChannel, ":x: "); return Task.CompletedTask; } - if (selectedSetting.EndsWith("Role") && guild.GetRole(mention) == null) { + if (selectedSetting.EndsWith("Role") && guild.GetRole(mention) is null) { cmd.Reply(Messages.InvalidRole, ":x: "); return Task.CompletedTask; } diff --git a/Boyfriend/Commands/UnbanCommand.cs b/Boyfriend/Commands/UnbanCommand.cs index 3ef5c15..f1eb9e6 100644 --- a/Boyfriend/Commands/UnbanCommand.cs +++ b/Boyfriend/Commands/UnbanCommand.cs @@ -9,11 +9,9 @@ public sealed class UnbanCommand : ICommand { if (!cmd.HasPermission(GuildPermission.BanMembers)) return; var id = cmd.GetBan(args, 0); - if (id == null) return; + if (id is null) return; var reason = cmd.GetRemaining(args, 1, "UnbanReason"); - if (reason == null) return; - - await UnbanUserAsync(cmd, id.Value, reason); + if (reason is not null) await UnbanUserAsync(cmd, id.Value, reason); } public static async Task UnbanUserAsync(CommandProcessor cmd, ulong id, string reason) { diff --git a/Boyfriend/Commands/UnmuteCommand.cs b/Boyfriend/Commands/UnmuteCommand.cs index b6a1aa9..976ce61 100644 --- a/Boyfriend/Commands/UnmuteCommand.cs +++ b/Boyfriend/Commands/UnmuteCommand.cs @@ -10,9 +10,10 @@ public sealed class UnmuteCommand : ICommand { if (!cmd.HasPermission(GuildPermission.ModerateMembers)) return; var toUnmute = cmd.GetMember(args, cleanArgs, 0, "ToUnmute"); + if (toUnmute is null) return; var reason = cmd.GetRemaining(args, 1, "UnmuteReason"); - if (toUnmute == null || reason == null || !cmd.CanInteractWith(toUnmute, "Unmute")) return; - await UnmuteMemberAsync(cmd, toUnmute, reason); + if (reason is not null && cmd.CanInteractWith(toUnmute, "Unmute")) + await UnmuteMemberAsync(cmd, toUnmute, reason); } public static async Task UnmuteMemberAsync(CommandProcessor cmd, SocketGuildUser toUnmute, @@ -20,7 +21,7 @@ public sealed class UnmuteCommand : ICommand { var requestOptions = Utils.GetRequestOptions($"({cmd.Context.User}) {reason}"); var role = Utils.GetMuteRole(cmd.Context.Guild); - if (role != null && toUnmute.Roles.Contains(role)) { + if (role is not null && toUnmute.Roles.Contains(role)) { var rolesRemoved = Boyfriend.GetRemovedRoles(cmd.Context.Guild.Id); if (rolesRemoved.TryGetValue(toUnmute.Id, out var unmutedRemovedRoles)) { @@ -31,7 +32,7 @@ public sealed class UnmuteCommand : ICommand { await toUnmute.RemoveRoleAsync(role, requestOptions); } else { - if (toUnmute.TimedOutUntil == null || toUnmute.TimedOutUntil.Value.ToUnixTimeSeconds() < + if (toUnmute.TimedOutUntil is null || toUnmute.TimedOutUntil.Value.ToUnixTimeSeconds() < DateTimeOffset.Now.ToUnixTimeSeconds()) { cmd.Reply(Messages.MemberNotMuted, ":x: "); return; diff --git a/Boyfriend/EventHandler.cs b/Boyfriend/EventHandler.cs index cd34119..be3ff2a 100644 --- a/Boyfriend/EventHandler.cs +++ b/Boyfriend/EventHandler.cs @@ -1,7 +1,6 @@ using Discord; using Discord.Rest; using Discord.WebSocket; -using Humanizer; namespace Boyfriend; @@ -23,14 +22,14 @@ public static class EventHandler { private static Task ReadyEvent() { if (!_sendReadyMessages) return Task.CompletedTask; - var i = Utils.Random.Next(3); + var i = Random.Shared.Next(3); foreach (var guild in Client.Guilds) { var config = Boyfriend.GetGuildConfig(guild.Id); - var channel = guild.GetTextChannel(Convert.ToUInt64(config["BotLogChannel"])); + var channel = guild.GetTextChannel(Utils.ParseMention(config["BotLogChannel"])); Utils.SetCurrentLanguage(guild.Id); - if (config["ReceiveStartupMessages"] is not "true" || channel == null) continue; + if (config["ReceiveStartupMessages"] is not "true" || channel is null) continue; _ = channel.SendMessageAsync(string.Format(Messages.Ready, Utils.GetBeep(i))); } @@ -41,9 +40,10 @@ public static class EventHandler { private static async Task MessageDeletedEvent(Cacheable message, Cacheable channel) { var msg = message.Value; - if (msg is null or ISystemMessage || msg.Author.IsBot) return; + if (channel.Value is not SocketGuildChannel gChannel || msg is null or ISystemMessage || + msg.Author.IsBot) return; - var guild = Boyfriend.FindGuild(channel.Value.Id); + var guild = gChannel.Guild; Utils.SetCurrentLanguage(guild.Id); @@ -61,11 +61,7 @@ public static class EventHandler { } private static Task MessageReceivedEvent(SocketMessage messageParam) { - if (messageParam is not SocketUserMessage { Author: SocketGuildUser user } message) return Task.CompletedTask; - - var guild = user.Guild; - - Utils.SetCurrentLanguage(guild.Id); + if (messageParam is not SocketUserMessage message) return Task.CompletedTask; _ = message.CleanContent.ToLower() switch { "whoami" => message.ReplyAsync("`nobody`"), @@ -81,11 +77,10 @@ public static class EventHandler { private static async Task MessageUpdatedEvent(Cacheable messageCached, SocketMessage messageSocket, ISocketMessageChannel channel) { var msg = messageCached.Value; + if (channel is not SocketGuildChannel gChannel || msg is null or ISystemMessage || + msg.CleanContent == messageSocket.CleanContent || msg.Author.IsBot) return; - if (msg is null or ISystemMessage || msg.CleanContent == messageSocket.CleanContent || msg.Author.IsBot) return; - - var guild = Boyfriend.FindGuild(channel.Id); - + var guild = gChannel.Guild; Utils.SetCurrentLanguage(guild.Id); var isLimitedSpace = msg.CleanContent.Length + messageSocket.CleanContent.Length < 1940; @@ -98,10 +93,13 @@ public static class EventHandler { private static async Task UserJoinedEvent(SocketGuildUser user) { var guild = user.Guild; var config = Boyfriend.GetGuildConfig(guild.Id); + Utils.SetCurrentLanguage(guild.Id); if (config["SendWelcomeMessages"] is "true") await Utils.SilentSendAsync(guild.SystemChannel, - string.Format(config["WelcomeMessage"], user.Mention, guild.Name)); + config["WelcomeMessage"] is "default" + ? Messages.DefaultWelcomeMessage + : string.Format(config["WelcomeMessage"], user.Mention, guild.Name)); if (config["StarterRole"] is not "0") await user.AddRoleAsync(ulong.Parse(config["StarterRole"])); } @@ -109,34 +107,35 @@ public static class EventHandler { private static async Task ScheduledEventCreatedEvent(SocketGuildEvent scheduledEvent) { var guild = scheduledEvent.Guild; var eventConfig = Boyfriend.GetGuildConfig(guild.Id); - var channel = guild.GetTextChannel(Convert.ToUInt64(eventConfig["EventCreatedChannel"])); + var channel = Utils.GetEventNotificationChannel(guild); - if (channel != null) { - var roleMention = ""; - var role = guild.GetRole(Convert.ToUInt64(eventConfig["EventNotifyReceiverRole"])); - if (role != null) roleMention = $"{role.Mention} "; + if (channel is not null) { + var role = guild.GetRole(ulong.Parse(eventConfig["EventNotificationRole"])); + var mentions = role is not null + ? $"{role.Mention} {scheduledEvent.Creator.Mention}" + : "{scheduledEvent.Creator.Mention}"; var location = Utils.Wrap(scheduledEvent.Location) ?? Utils.MentionChannel(scheduledEvent.Channel.Id); + var descAndLink + = $"{Utils.Wrap(scheduledEvent.Description)}\nhttps://discord.com/events/{guild.Id}/{scheduledEvent.Id}"; await Utils.SilentSendAsync(channel, - string.Format(Messages.EventCreated, "\n", roleMention, scheduledEvent.Creator.Mention, + string.Format(Messages.EventCreated, mentions, Utils.Wrap(scheduledEvent.Name), location, - scheduledEvent.StartTime.ToUnixTimeSeconds().ToString(), Utils.Wrap(scheduledEvent.Description), - guild.Id, scheduledEvent.Id), + scheduledEvent.StartTime.ToUnixTimeSeconds().ToString(), descAndLink), true); } - if (eventConfig["EventEarlyNotificationOffset"] != "0") { + if (eventConfig["EventEarlyNotificationOffset"] is not "0") _ = Utils.SendEarlyEventStartNotificationAsync(channel, scheduledEvent, - Convert.ToInt32(eventConfig["EventEarlyNotificationOffset"])); - } + int.Parse(eventConfig["EventEarlyNotificationOffset"])); } private static async Task ScheduledEventCancelledEvent(SocketGuildEvent scheduledEvent) { var guild = scheduledEvent.Guild; var eventConfig = Boyfriend.GetGuildConfig(guild.Id); - var channel = guild.GetTextChannel(Convert.ToUInt64(eventConfig["EventCancelledChannel"])); - if (channel != null) + var channel = Utils.GetEventNotificationChannel(guild); + if (channel is not null) await channel.SendMessageAsync(string.Format(Messages.EventCancelled, Utils.Wrap(scheduledEvent.Name), eventConfig["FrowningFace"] is "true" ? $" {Messages.SettingsFrowningFace}" : "")); } @@ -144,14 +143,14 @@ public static class EventHandler { private static async Task ScheduledEventStartedEvent(SocketGuildEvent scheduledEvent) { var guild = scheduledEvent.Guild; var eventConfig = Boyfriend.GetGuildConfig(guild.Id); - var channel = guild.GetTextChannel(Convert.ToUInt64(eventConfig["EventStartedChannel"])); + var channel = Utils.GetEventNotificationChannel(guild); - if (channel != null) { + if (channel is not null) { var receivers = eventConfig["EventStartedReceivers"]; - var role = guild.GetRole(Convert.ToUInt64(eventConfig["EventNotifyReceiverRole"])); + var role = guild.GetRole(ulong.Parse(eventConfig["EventNotificationRole"])); var mentions = Boyfriend.StringBuilder; - if (receivers.Contains("role") && role != null) mentions.Append($"{role.Mention} "); + if (receivers.Contains("role") && role is not null) mentions.Append($"{role.Mention} "); if (receivers.Contains("users") || receivers.Contains("interested")) mentions = (await scheduledEvent.GetUsersAsync(15)).Aggregate(mentions, (current, user) => current.Append($"{user.Mention} ")); @@ -165,10 +164,9 @@ public static class EventHandler { private static async Task ScheduledEventCompletedEvent(SocketGuildEvent scheduledEvent) { var guild = scheduledEvent.Guild; - var eventConfig = Boyfriend.GetGuildConfig(guild.Id); - var channel = guild.GetTextChannel(Convert.ToUInt64(eventConfig["EventCompletedChannel"])); - if (channel != null) + var channel = Utils.GetEventNotificationChannel(guild); + if (channel is not null) await channel.SendMessageAsync(string.Format(Messages.EventCompleted, Utils.Wrap(scheduledEvent.Name), - Utils.Wrap(scheduledEvent.StartTime.Subtract(DateTimeOffset.Now).Negate().Humanize()))); + Utils.GetHumanizedTimeOffset(DateTimeOffset.Now.Subtract(scheduledEvent.StartTime)))); } } diff --git a/Boyfriend/Messages.Designer.cs b/Boyfriend/Messages.Designer.cs index 093cc8b..1264e3f 100644 --- a/Boyfriend/Messages.Designer.cs +++ b/Boyfriend/Messages.Designer.cs @@ -11,32 +11,46 @@ namespace Boyfriend { using System; - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [System.Diagnostics.DebuggerNonUserCodeAttribute()] - [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Messages { - private static System.Resources.ResourceManager resourceMan; + private static global::System.Resources.ResourceManager resourceMan; - private static System.Globalization.CultureInfo resourceCulture; + private static global::System.Globalization.CultureInfo resourceCulture; - [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal Messages() { } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] - internal static System.Resources.ResourceManager ResourceManager { + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { get { - if (object.Equals(null, resourceMan)) { - System.Resources.ResourceManager temp = new System.Resources.ResourceManager("Boyfriend.Messages", typeof(Messages).Assembly); + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Boyfriend.Messages", typeof(Messages).Assembly); resourceMan = temp; } return resourceMan; } } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] - internal static System.Globalization.CultureInfo Culture { + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { get { return resourceCulture; } @@ -45,736 +59,1066 @@ namespace Boyfriend { } } - internal static string Ready { - get { - return ResourceManager.GetString("Ready", resourceCulture); - } - } - - internal static string CachedMessageDeleted { - get { - return ResourceManager.GetString("CachedMessageDeleted", resourceCulture); - } - } - - internal static string AutobanReason { - get { - return ResourceManager.GetString("AutobanReason", resourceCulture); - } - } - - internal static string CachedMessageEdited { - get { - return ResourceManager.GetString("CachedMessageEdited", resourceCulture); - } - } - - internal static string DefaultWelcomeMessage { - get { - return ResourceManager.GetString("DefaultWelcomeMessage", resourceCulture); - } - } - + /// + /// Looks up a localized string similar to Bah! . + /// internal static string Beep1 { get { return ResourceManager.GetString("Beep1", resourceCulture); } } + /// + /// Looks up a localized string similar to Bop! . + /// internal static string Beep2 { get { return ResourceManager.GetString("Beep2", resourceCulture); } } + /// + /// Looks up a localized string similar to Beep! . + /// internal static string Beep3 { get { return ResourceManager.GetString("Beep3", resourceCulture); } } - internal static string CommandNoPermissionBot { - get { - return ResourceManager.GetString("CommandNoPermissionBot", resourceCulture); - } - } - - internal static string CommandNoPermissionUser { - get { - return ResourceManager.GetString("CommandNoPermissionUser", resourceCulture); - } - } - - internal static string YouWereBanned { - get { - return ResourceManager.GetString("YouWereBanned", resourceCulture); - } - } - - internal static string PunishmentExpired { - get { - return ResourceManager.GetString("PunishmentExpired", resourceCulture); - } - } - - internal static string ClearAmountTooSmall { - get { - return ResourceManager.GetString("ClearAmountTooSmall", resourceCulture); - } - } - - internal static string ClearAmountTooLarge { - get { - return ResourceManager.GetString("ClearAmountTooLarge", resourceCulture); - } - } - - internal static string CommandHelp { - get { - return ResourceManager.GetString("CommandHelp", resourceCulture); - } - } - - internal static string YouWereKicked { - get { - return ResourceManager.GetString("YouWereKicked", resourceCulture); - } - } - - internal static string Milliseconds { - get { - return ResourceManager.GetString("Milliseconds", resourceCulture); - } - } - - internal static string MemberAlreadyMuted { - get { - return ResourceManager.GetString("MemberAlreadyMuted", resourceCulture); - } - } - - internal static string ChannelNotSpecified { - get { - return ResourceManager.GetString("ChannelNotSpecified", resourceCulture); - } - } - - internal static string RoleNotSpecified { - get { - return ResourceManager.GetString("RoleNotSpecified", resourceCulture); - } - } - - internal static string CurrentSettings { - get { - return ResourceManager.GetString("CurrentSettings", resourceCulture); - } - } - - internal static string SettingsLang { - get { - return ResourceManager.GetString("SettingsLang", resourceCulture); - } - } - - internal static string SettingsPrefix { - get { - return ResourceManager.GetString("SettingsPrefix", resourceCulture); - } - } - - internal static string SettingsRemoveRolesOnMute { - get { - return ResourceManager.GetString("SettingsRemoveRolesOnMute", resourceCulture); - } - } - - internal static string SettingsSendWelcomeMessages { - get { - return ResourceManager.GetString("SettingsSendWelcomeMessages", resourceCulture); - } - } - - internal static string SettingsStarterRole { - get { - return ResourceManager.GetString("SettingsStarterRole", resourceCulture); - } - } - - internal static string SettingsMuteRole { - get { - return ResourceManager.GetString("SettingsMuteRole", resourceCulture); - } - } - - internal static string SettingsAdminLogChannel { - get { - return ResourceManager.GetString("SettingsAdminLogChannel", resourceCulture); - } - } - - internal static string SettingsBotLogChannel { - get { - return ResourceManager.GetString("SettingsBotLogChannel", resourceCulture); - } - } - - internal static string LanguageNotSupported { - get { - return ResourceManager.GetString("LanguageNotSupported", resourceCulture); - } - } - - internal static string Yes { - get { - return ResourceManager.GetString("Yes", resourceCulture); - } - } - - internal static string No { - get { - return ResourceManager.GetString("No", resourceCulture); - } - } - - internal static string UserNotBanned { - get { - return ResourceManager.GetString("UserNotBanned", resourceCulture); - } - } - - internal static string MemberNotMuted { - get { - return ResourceManager.GetString("MemberNotMuted", resourceCulture); - } - } - - internal static string RolesReturned { - get { - return ResourceManager.GetString("RolesReturned", resourceCulture); - } - } - - internal static string SettingsWelcomeMessage { - get { - return ResourceManager.GetString("SettingsWelcomeMessage", resourceCulture); - } - } - - internal static string ClearAmountInvalid { - get { - return ResourceManager.GetString("ClearAmountInvalid", resourceCulture); - } - } - - internal static string FeedbackUserBanned { - get { - return ResourceManager.GetString("FeedbackUserBanned", resourceCulture); - } - } - - internal static string UserNotInGuild { - get { - return ResourceManager.GetString("UserNotInGuild", resourceCulture); - } - } - - internal static string SettingDoesntExist { - get { - return ResourceManager.GetString("SettingDoesntExist", resourceCulture); - } - } - - internal static string SettingsReceiveStartupMessages { - get { - return ResourceManager.GetString("SettingsReceiveStartupMessages", resourceCulture); - } - } - - internal static string InvalidSettingValue { - get { - return ResourceManager.GetString("InvalidSettingValue", resourceCulture); - } - } - - internal static string InvalidRole { - get { - return ResourceManager.GetString("InvalidRole", resourceCulture); - } - } - - internal static string InvalidChannel { - get { - return ResourceManager.GetString("InvalidChannel", resourceCulture); - } - } - - internal static string RoleRemovalFailed { - get { - return ResourceManager.GetString("RoleRemovalFailed", resourceCulture); - } - } - - internal static string DurationRequiredForTimeOuts { - get { - return ResourceManager.GetString("DurationRequiredForTimeOuts", resourceCulture); - } - } - - internal static string CannotTimeOutBot { - get { - return ResourceManager.GetString("CannotTimeOutBot", resourceCulture); - } - } - - internal static string EventCreated { - get { - return ResourceManager.GetString("EventCreated", resourceCulture); - } - } - - internal static string SettingsEventNotifyReceiverRole { - get { - return ResourceManager.GetString("SettingsEventNotifyReceiverRole", resourceCulture); - } - } - - internal static string SettingsEventCreatedChannel { - get { - return ResourceManager.GetString("SettingsEventCreatedChannel", resourceCulture); - } - } - - internal static string SettingsEventStartedChannel { - get { - return ResourceManager.GetString("SettingsEventStartedChannel", resourceCulture); - } - } - - internal static string SettingsEventStartedReceivers { - get { - return ResourceManager.GetString("SettingsEventStartedReceivers", resourceCulture); - } - } - - internal static string EventStarted { - get { - return ResourceManager.GetString("EventStarted", resourceCulture); - } - } - - internal static string SettingsFrowningFace { - get { - return ResourceManager.GetString("SettingsFrowningFace", resourceCulture); - } - } - - internal static string EventCancelled { - get { - return ResourceManager.GetString("EventCancelled", resourceCulture); - } - } - - internal static string SettingsEventCancelledChannel { - get { - return ResourceManager.GetString("SettingsEventCancelledChannel", resourceCulture); - } - } - - internal static string SettingsEventCompletedChannel { - get { - return ResourceManager.GetString("SettingsEventCompletedChannel", resourceCulture); - } - } - - internal static string EventCompleted { - get { - return ResourceManager.GetString("EventCompleted", resourceCulture); - } - } - - internal static string FeedbackFormat { - get { - return ResourceManager.GetString("FeedbackFormat", resourceCulture); - } - } - - internal static string Ever { - get { - return ResourceManager.GetString("Ever", resourceCulture); - } - } - - internal static string FeedbackMessagesCleared { - get { - return ResourceManager.GetString("FeedbackMessagesCleared", resourceCulture); - } - } - - internal static string FeedbackMemberKicked { - get { - return ResourceManager.GetString("FeedbackMemberKicked", resourceCulture); - } - } - - internal static string FeedbackMemberMuted { - get { - return ResourceManager.GetString("FeedbackMemberMuted", resourceCulture); - } - } - - internal static string FeedbackUserUnbanned { - get { - return ResourceManager.GetString("FeedbackUserUnbanned", resourceCulture); - } - } - - internal static string FeedbackMemberUnmuted { - get { - return ResourceManager.GetString("FeedbackMemberUnmuted", resourceCulture); - } - } - - internal static string SettingsNothingChanged { - get { - return ResourceManager.GetString("SettingsNothingChanged", resourceCulture); - } - } - - internal static string SettingNotDefined { - get { - return ResourceManager.GetString("SettingNotDefined", resourceCulture); - } - } - - internal static string FeedbackSettingsUpdated { - get { - return ResourceManager.GetString("FeedbackSettingsUpdated", resourceCulture); - } - } - - internal static string CommandDescriptionBan { - get { - return ResourceManager.GetString("CommandDescriptionBan", resourceCulture); - } - } - - internal static string CommandDescriptionClear { - get { - return ResourceManager.GetString("CommandDescriptionClear", resourceCulture); - } - } - - internal static string CommandDescriptionHelp { - get { - return ResourceManager.GetString("CommandDescriptionHelp", resourceCulture); - } - } - - internal static string CommandDescriptionKick { - get { - return ResourceManager.GetString("CommandDescriptionKick", resourceCulture); - } - } - - internal static string CommandDescriptionMute { - get { - return ResourceManager.GetString("CommandDescriptionMute", resourceCulture); - } - } - - internal static string CommandDescriptionPing { - get { - return ResourceManager.GetString("CommandDescriptionPing", resourceCulture); - } - } - - internal static string CommandDescriptionSettings { - get { - return ResourceManager.GetString("CommandDescriptionSettings", resourceCulture); - } - } - - internal static string CommandDescriptionUnban { - get { - return ResourceManager.GetString("CommandDescriptionUnban", resourceCulture); - } - } - - internal static string CommandDescriptionUnmute { - get { - return ResourceManager.GetString("CommandDescriptionUnmute", resourceCulture); - } - } - - internal static string MissingNumber { - get { - return ResourceManager.GetString("MissingNumber", resourceCulture); - } - } - - internal static string MissingUser { - get { - return ResourceManager.GetString("MissingUser", resourceCulture); - } - } - - internal static string InvalidUser { - get { - return ResourceManager.GetString("InvalidUser", resourceCulture); - } - } - - internal static string MissingMember { - get { - return ResourceManager.GetString("MissingMember", resourceCulture); - } - } - - internal static string InvalidMember { - get { - return ResourceManager.GetString("InvalidMember", resourceCulture); - } - } - - internal static string UserCannotBanMembers { - get { - return ResourceManager.GetString("UserCannotBanMembers", resourceCulture); - } - } - - internal static string UserCannotManageMessages { - get { - return ResourceManager.GetString("UserCannotManageMessages", resourceCulture); - } - } - - internal static string UserCannotKickMembers { - get { - return ResourceManager.GetString("UserCannotKickMembers", resourceCulture); - } - } - - internal static string UserCannotModerateMembers { - get { - return ResourceManager.GetString("UserCannotModerateMembers", resourceCulture); - } - } - - internal static string UserCannotManageGuild { - get { - return ResourceManager.GetString("UserCannotManageGuild", resourceCulture); - } - } - + /// + /// Looks up a localized string similar to I cannot ban users from this guild!. + /// internal static string BotCannotBanMembers { get { return ResourceManager.GetString("BotCannotBanMembers", resourceCulture); } } - internal static string BotCannotManageMessages { - get { - return ResourceManager.GetString("BotCannotManageMessages", resourceCulture); - } - } - - internal static string BotCannotKickMembers { - get { - return ResourceManager.GetString("BotCannotKickMembers", resourceCulture); - } - } - - internal static string BotCannotModerateMembers { - get { - return ResourceManager.GetString("BotCannotModerateMembers", resourceCulture); - } - } - - internal static string BotCannotManageGuild { - get { - return ResourceManager.GetString("BotCannotManageGuild", resourceCulture); - } - } - - internal static string MissingBanReason { - get { - return ResourceManager.GetString("MissingBanReason", resourceCulture); - } - } - - internal static string MissingKickReason { - get { - return ResourceManager.GetString("MissingKickReason", resourceCulture); - } - } - - internal static string MissingMuteReason { - get { - return ResourceManager.GetString("MissingMuteReason", resourceCulture); - } - } - - internal static string MissingUnbanReason { - get { - return ResourceManager.GetString("MissingUnbanReason", resourceCulture); - } - } - - internal static string MissingUnmuteReason { - get { - return ResourceManager.GetString("MissingUnmuteReason", resourceCulture); - } - } - - internal static string MissingSetting { - get { - return ResourceManager.GetString("MissingSetting", resourceCulture); - } - } - - internal static string UserCannotBanOwner { - get { - return ResourceManager.GetString("UserCannotBanOwner", resourceCulture); - } - } - - internal static string UserCannotBanThemselves { - get { - return ResourceManager.GetString("UserCannotBanThemselves", resourceCulture); - } - } - - internal static string UserCannotBanBot { - get { - return ResourceManager.GetString("UserCannotBanBot", resourceCulture); - } - } - + /// + /// Looks up a localized string similar to I cannot ban this user!. + /// internal static string BotCannotBanTarget { get { return ResourceManager.GetString("BotCannotBanTarget", resourceCulture); } } - internal static string UserCannotBanTarget { + /// + /// Looks up a localized string similar to I cannot kick members from this guild!. + /// + internal static string BotCannotKickMembers { get { - return ResourceManager.GetString("UserCannotBanTarget", resourceCulture); - } - } - - internal static string UserCannotKickOwner { - get { - return ResourceManager.GetString("UserCannotKickOwner", resourceCulture); - } - } - - internal static string UserCannotKickThemselves { - get { - return ResourceManager.GetString("UserCannotKickThemselves", resourceCulture); - } - } - - internal static string UserCannotKickBot { - get { - return ResourceManager.GetString("UserCannotKickBot", resourceCulture); + return ResourceManager.GetString("BotCannotKickMembers", resourceCulture); } } + /// + /// Looks up a localized string similar to I cannot kick this member!. + /// internal static string BotCannotKickTarget { get { return ResourceManager.GetString("BotCannotKickTarget", resourceCulture); } } - internal static string UserCannotKickTarget { + /// + /// Looks up a localized string similar to I cannot manage this guild!. + /// + internal static string BotCannotManageGuild { get { - return ResourceManager.GetString("UserCannotKickTarget", resourceCulture); + return ResourceManager.GetString("BotCannotManageGuild", resourceCulture); } } - internal static string UserCannotMuteOwner { + /// + /// Looks up a localized string similar to I cannot manage messages in this guild!. + /// + internal static string BotCannotManageMessages { get { - return ResourceManager.GetString("UserCannotMuteOwner", resourceCulture); + return ResourceManager.GetString("BotCannotManageMessages", resourceCulture); } } - internal static string UserCannotMuteThemselves { + /// + /// Looks up a localized string similar to I cannot moderate members in this guild!. + /// + internal static string BotCannotModerateMembers { get { - return ResourceManager.GetString("UserCannotMuteThemselves", resourceCulture); - } - } - - internal static string UserCannotMuteBot { - get { - return ResourceManager.GetString("UserCannotMuteBot", resourceCulture); + return ResourceManager.GetString("BotCannotModerateMembers", resourceCulture); } } + /// + /// Looks up a localized string similar to I cannot mute this member!. + /// internal static string BotCannotMuteTarget { get { return ResourceManager.GetString("BotCannotMuteTarget", resourceCulture); } } - internal static string UserCannotMuteTarget { - get { - return ResourceManager.GetString("UserCannotMuteTarget", resourceCulture); - } - } - - internal static string UserCannotUnmuteOwner { - get { - return ResourceManager.GetString("UserCannotUnmuteOwner", resourceCulture); - } - } - - internal static string UserCannotUnmuteThemselves { - get { - return ResourceManager.GetString("UserCannotUnmuteThemselves", resourceCulture); - } - } - - internal static string UserCannotUnmuteBot { - get { - return ResourceManager.GetString("UserCannotUnmuteBot", resourceCulture); - } - } - + /// + /// Looks up a localized string similar to I cannot unmute this member!. + /// internal static string BotCannotUnmuteTarget { get { return ResourceManager.GetString("BotCannotUnmuteTarget", resourceCulture); } } - internal static string UserCannotUnmuteTarget { + /// + /// Looks up a localized string similar to Deleted message from {0} in channel {1}: {2}. + /// + internal static string CachedMessageDeleted { get { - return ResourceManager.GetString("UserCannotUnmuteTarget", resourceCulture); + return ResourceManager.GetString("CachedMessageDeleted", resourceCulture); } } - internal static string CommandDescriptionCavepleaselisten { + /// + /// Looks up a localized string similar to Edited message in channel {0}: {1} -> {2}. + /// + internal static string CachedMessageEdited { get { - return ResourceManager.GetString("CommandDescriptionCavepleaselisten", resourceCulture); + return ResourceManager.GetString("CachedMessageEdited", resourceCulture); } } - internal static string ServerBlacklisted { + /// + /// Looks up a localized string similar to I cannot use time-outs on other bots! Try to set a mute role in settings. + /// + internal static string CannotTimeOutBot { get { - return ResourceManager.GetString("ServerBlacklisted", resourceCulture); + return ResourceManager.GetString("CannotTimeOutBot", resourceCulture); } } + /// + /// Looks up a localized string similar to Not specified. + /// + internal static string ChannelNotSpecified { + get { + return ResourceManager.GetString("ChannelNotSpecified", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You need to specify an integer from {0} to {1} instead of {2}!. + /// + internal static string ClearAmountInvalid { + get { + return ResourceManager.GetString("ClearAmountInvalid", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You specified more than {0} messages!. + /// + internal static string ClearAmountTooLarge { + get { + return ResourceManager.GetString("ClearAmountTooLarge", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You specified less than {0} messages!. + /// + internal static string ClearAmountTooSmall { + get { + return ResourceManager.GetString("ClearAmountTooSmall", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Bans a user. + /// + internal static string CommandDescriptionBan { + get { + return ResourceManager.GetString("CommandDescriptionBan", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Deletes a specified amount of messages in this channel. + /// + internal static string CommandDescriptionClear { + get { + return ResourceManager.GetString("CommandDescriptionClear", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Shows this message. + /// + internal static string CommandDescriptionHelp { + get { + return ResourceManager.GetString("CommandDescriptionHelp", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Kicks a member. + /// + internal static string CommandDescriptionKick { + get { + return ResourceManager.GetString("CommandDescriptionKick", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Mutes a member. + /// + internal static string CommandDescriptionMute { + get { + return ResourceManager.GetString("CommandDescriptionMute", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Shows (inaccurate) latency. + /// + internal static string CommandDescriptionPing { + get { + return ResourceManager.GetString("CommandDescriptionPing", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Allows you to change certain preferences for this guild. + /// + internal static string CommandDescriptionSettings { + get { + return ResourceManager.GetString("CommandDescriptionSettings", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Unbans a user. + /// + internal static string CommandDescriptionUnban { + get { + return ResourceManager.GetString("CommandDescriptionUnban", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Unmutes a member. + /// + internal static string CommandDescriptionUnmute { + get { + return ResourceManager.GetString("CommandDescriptionUnmute", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Command help:. + /// + internal static string CommandHelp { + get { + return ResourceManager.GetString("CommandHelp", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to I do not have permission to execute this command!. + /// + internal static string CommandNoPermissionBot { + get { + return ResourceManager.GetString("CommandNoPermissionBot", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You do not have permission to execute this command!. + /// + internal static string CommandNoPermissionUser { + get { + return ResourceManager.GetString("CommandNoPermissionUser", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Current settings:. + /// + internal static string CurrentSettings { + get { + return ResourceManager.GetString("CurrentSettings", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0}, welcome to {1}. + /// + internal static string DefaultWelcomeMessage { + get { + return ResourceManager.GetString("DefaultWelcomeMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to I cannot mute someone for more than 28 days using timeouts! Either specify a duration shorter than 28 days, or set a mute role in settings. + /// + internal static string DurationRequiredForTimeOuts { + get { + return ResourceManager.GetString("DurationRequiredForTimeOuts", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Event {0} is cancelled!{1}. + /// + internal static string EventCancelled { + get { + return ResourceManager.GetString("EventCancelled", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Event {0} has completed! Duration: {1}. + /// + internal static string EventCompleted { + get { + return ResourceManager.GetString("EventCompleted", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0} has created event {1}! It will take place in {2} and will start <t:{3}:R>!\n{4}. + /// + internal static string EventCreated { + get { + return ResourceManager.GetString("EventCreated", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0}Event {1} will start <t:{2}:R>!. + /// internal static string EventEarlyNotification { get { return ResourceManager.GetString("EventEarlyNotification", resourceCulture); } } + /// + /// Looks up a localized string similar to {0}Event {1} is starting at {2}!. + /// + internal static string EventStarted { + get { + return ResourceManager.GetString("EventStarted", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to ever. + /// + internal static string Ever { + get { + return ResourceManager.GetString("Ever", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Kicked {0}: {1}. + /// + internal static string FeedbackMemberKicked { + get { + return ResourceManager.GetString("FeedbackMemberKicked", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Muted {0} for{1}: {2}. + /// + internal static string FeedbackMemberMuted { + get { + return ResourceManager.GetString("FeedbackMemberMuted", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Unmuted {0}: {1}. + /// + internal static string FeedbackMemberUnmuted { + get { + return ResourceManager.GetString("FeedbackMemberUnmuted", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Deleted {0} messages in {1}. + /// + internal static string FeedbackMessagesCleared { + get { + return ResourceManager.GetString("FeedbackMessagesCleared", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Value of setting `{0}` is now set to {1}. + /// + internal static string FeedbackSettingsUpdated { + get { + return ResourceManager.GetString("FeedbackSettingsUpdated", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Banned {0} for{1}: {2}. + /// + internal static string FeedbackUserBanned { + get { + return ResourceManager.GetString("FeedbackUserBanned", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Unbanned {0}: {1}. + /// + internal static string FeedbackUserUnbanned { + get { + return ResourceManager.GetString("FeedbackUserUnbanned", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to This channel does not exist!. + /// + internal static string InvalidChannel { + get { + return ResourceManager.GetString("InvalidChannel", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You need to specify a guild member instead of {0}!. + /// + internal static string InvalidMember { + get { + return ResourceManager.GetString("InvalidMember", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to This role does not exist!. + /// + internal static string InvalidRole { + get { + return ResourceManager.GetString("InvalidRole", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Invalid setting value specified!. + /// + internal static string InvalidSettingValue { + get { + return ResourceManager.GetString("InvalidSettingValue", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You need to specify a user instead of {0}!. + /// + internal static string InvalidUser { + get { + return ResourceManager.GetString("InvalidUser", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Language not supported!. + /// + internal static string LanguageNotSupported { + get { + return ResourceManager.GetString("LanguageNotSupported", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Member is already muted!. + /// + internal static string MemberAlreadyMuted { + get { + return ResourceManager.GetString("MemberAlreadyMuted", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Member not muted!. + /// + internal static string MemberNotMuted { + get { + return ResourceManager.GetString("MemberNotMuted", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to ms. + /// + internal static string Milliseconds { + get { + return ResourceManager.GetString("Milliseconds", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You need to specify a reason to ban this user!. + /// + internal static string MissingBanReason { + get { + return ResourceManager.GetString("MissingBanReason", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You need to specify a reason to kick this member!. + /// + internal static string MissingKickReason { + get { + return ResourceManager.GetString("MissingKickReason", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You need to specify a guild member!. + /// + internal static string MissingMember { + get { + return ResourceManager.GetString("MissingMember", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You need to specify a reason to mute this member!. + /// + internal static string MissingMuteReason { + get { + return ResourceManager.GetString("MissingMuteReason", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You need to specify an integer from {0} to {1}!. + /// + internal static string MissingNumber { + get { + return ResourceManager.GetString("MissingNumber", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You need to specify a setting to change!. + /// + internal static string MissingSetting { + get { + return ResourceManager.GetString("MissingSetting", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You need to specify a reason to unban this user!. + /// + internal static string MissingUnbanReason { + get { + return ResourceManager.GetString("MissingUnbanReason", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You need to specify a reason for unmute this member!. + /// + internal static string MissingUnmuteReason { + get { + return ResourceManager.GetString("MissingUnmuteReason", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You need to specify a user!. + /// + internal static string MissingUser { + get { + return ResourceManager.GetString("MissingUser", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to No. + /// + internal static string No { + get { + return ResourceManager.GetString("No", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Punishment expired. + /// + internal static string PunishmentExpired { + get { + return ResourceManager.GetString("PunishmentExpired", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0}I'm ready!. + /// + internal static string Ready { + get { + return ResourceManager.GetString("Ready", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Not specified. + /// + internal static string RoleNotSpecified { + get { + return ResourceManager.GetString("RoleNotSpecified", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to I couldn't remove role {0} because of an error! {1}. + /// + internal static string RoleRemovalFailed { + get { + return ResourceManager.GetString("RoleRemovalFailed", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Someone removed the mute role manually! I added back all roles that I removed during the mute. + /// + internal static string RolesReturned { + get { + return ResourceManager.GetString("RolesReturned", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to That setting doesn't exist!. + /// + internal static string SettingDoesntExist { + get { + return ResourceManager.GetString("SettingDoesntExist", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Not specified. + /// + internal static string SettingNotDefined { + get { + return ResourceManager.GetString("SettingNotDefined", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Admin log channel. + /// + internal static string SettingsAdminLogChannel { + get { + return ResourceManager.GetString("SettingsAdminLogChannel", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Bot log channel. + /// + internal static string SettingsBotLogChannel { + get { + return ResourceManager.GetString("SettingsBotLogChannel", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Channel for event cancellation notifications. + /// + internal static string SettingsEventCancelledChannel { + get { + return ResourceManager.GetString("SettingsEventCancelledChannel", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Channel for event completion notifications. + /// + internal static string SettingsEventCompletedChannel { + get { + return ResourceManager.GetString("SettingsEventCompletedChannel", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Channel for event creation notifications. + /// + internal static string SettingsEventCreatedChannel { + get { + return ResourceManager.GetString("SettingsEventCreatedChannel", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Early event start notification offset. + /// internal static string SettingsEventEarlyNotificationOffset { get { return ResourceManager.GetString("SettingsEventEarlyNotificationOffset", resourceCulture); } } + + /// + /// Looks up a localized string similar to Role for event creation notifications. + /// + internal static string SettingsEventNotifyReceiverRole { + get { + return ResourceManager.GetString("SettingsEventNotifyReceiverRole", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Channel for event start notifications. + /// + internal static string SettingsEventStartedChannel { + get { + return ResourceManager.GetString("SettingsEventStartedChannel", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Event start notifications receivers. + /// + internal static string SettingsEventStartedReceivers { + get { + return ResourceManager.GetString("SettingsEventStartedReceivers", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to :(. + /// + internal static string SettingsFrowningFace { + get { + return ResourceManager.GetString("SettingsFrowningFace", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Language. + /// + internal static string SettingsLang { + get { + return ResourceManager.GetString("SettingsLang", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Mute role. + /// + internal static string SettingsMuteRole { + get { + return ResourceManager.GetString("SettingsMuteRole", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Nothing changed! `{0}` is already set to {1}. + /// + internal static string SettingsNothingChanged { + get { + return ResourceManager.GetString("SettingsNothingChanged", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Prefix. + /// + internal static string SettingsPrefix { + get { + return ResourceManager.GetString("SettingsPrefix", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Receive startup messages. + /// + internal static string SettingsReceiveStartupMessages { + get { + return ResourceManager.GetString("SettingsReceiveStartupMessages", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Remove roles on mute. + /// + internal static string SettingsRemoveRolesOnMute { + get { + return ResourceManager.GetString("SettingsRemoveRolesOnMute", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Send welcome messages. + /// + internal static string SettingsSendWelcomeMessages { + get { + return ResourceManager.GetString("SettingsSendWelcomeMessages", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Starter role. + /// + internal static string SettingsStarterRole { + get { + return ResourceManager.GetString("SettingsStarterRole", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Welcome message. + /// + internal static string SettingsWelcomeMessage { + get { + return ResourceManager.GetString("SettingsWelcomeMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You cannot ban me!. + /// + internal static string UserCannotBanBot { + get { + return ResourceManager.GetString("UserCannotBanBot", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You cannot ban users from this guild!. + /// + internal static string UserCannotBanMembers { + get { + return ResourceManager.GetString("UserCannotBanMembers", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You cannot ban the owner of this guild!. + /// + internal static string UserCannotBanOwner { + get { + return ResourceManager.GetString("UserCannotBanOwner", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You cannot ban this user!. + /// + internal static string UserCannotBanTarget { + get { + return ResourceManager.GetString("UserCannotBanTarget", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You cannot ban yourself!. + /// + internal static string UserCannotBanThemselves { + get { + return ResourceManager.GetString("UserCannotBanThemselves", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You cannot kick me!. + /// + internal static string UserCannotKickBot { + get { + return ResourceManager.GetString("UserCannotKickBot", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You cannot kick members from this guild!. + /// + internal static string UserCannotKickMembers { + get { + return ResourceManager.GetString("UserCannotKickMembers", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You cannot kick the owner of this guild!. + /// + internal static string UserCannotKickOwner { + get { + return ResourceManager.GetString("UserCannotKickOwner", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You cannot kick this member!. + /// + internal static string UserCannotKickTarget { + get { + return ResourceManager.GetString("UserCannotKickTarget", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You cannot kick yourself!. + /// + internal static string UserCannotKickThemselves { + get { + return ResourceManager.GetString("UserCannotKickThemselves", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You cannot manage this guild!. + /// + internal static string UserCannotManageGuild { + get { + return ResourceManager.GetString("UserCannotManageGuild", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You cannot manage messages in this guild!. + /// + internal static string UserCannotManageMessages { + get { + return ResourceManager.GetString("UserCannotManageMessages", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You cannot moderate members in this guild!. + /// + internal static string UserCannotModerateMembers { + get { + return ResourceManager.GetString("UserCannotModerateMembers", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You cannot mute me!. + /// + internal static string UserCannotMuteBot { + get { + return ResourceManager.GetString("UserCannotMuteBot", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You cannot mute the owner of this guild!. + /// + internal static string UserCannotMuteOwner { + get { + return ResourceManager.GetString("UserCannotMuteOwner", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You cannot mute this member!. + /// + internal static string UserCannotMuteTarget { + get { + return ResourceManager.GetString("UserCannotMuteTarget", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You cannot mute yourself!. + /// + internal static string UserCannotMuteThemselves { + get { + return ResourceManager.GetString("UserCannotMuteThemselves", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to .... + /// + internal static string UserCannotUnmuteBot { + get { + return ResourceManager.GetString("UserCannotUnmuteBot", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You don't need to unmute the owner of this guild!. + /// + internal static string UserCannotUnmuteOwner { + get { + return ResourceManager.GetString("UserCannotUnmuteOwner", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You cannot unmute this user!. + /// + internal static string UserCannotUnmuteTarget { + get { + return ResourceManager.GetString("UserCannotUnmuteTarget", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You are muted!. + /// + internal static string UserCannotUnmuteThemselves { + get { + return ResourceManager.GetString("UserCannotUnmuteThemselves", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to This user is not banned!. + /// + internal static string UserNotBanned { + get { + return ResourceManager.GetString("UserNotBanned", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The specified user is not a member of this server!. + /// + internal static string UserNotInGuild { + get { + return ResourceManager.GetString("UserNotInGuild", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Yes. + /// + internal static string Yes { + get { + return ResourceManager.GetString("Yes", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You were banned by {0} in guild {1} for {2}. + /// + internal static string YouWereBanned { + get { + return ResourceManager.GetString("YouWereBanned", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You were kicked by {0} in guild {1} for {2}. + /// + internal static string YouWereKicked { + get { + return ResourceManager.GetString("YouWereKicked", resourceCulture); + } + } } } diff --git a/Boyfriend/Messages.resx b/Boyfriend/Messages.resx index a06e8cc..5b41851 100644 --- a/Boyfriend/Messages.resx +++ b/Boyfriend/Messages.resx @@ -25,14 +25,11 @@ - {0}I'm ready! (C#) + {0}I'm ready! Deleted message from {0} in channel {1}: {2} - - Too many mentions in 1 message - Edited message in channel {0}: {1} -> {2} @@ -166,7 +163,7 @@ I cannot use time-outs on other bots! Try to set a mute role in settings - {1}{2} created event {3}! It will take place in {4} and will start <t:{5}:R>!{0}{6}{0}https://discord.com/events/{7}/{8} + {0} has created event {1}! It will take place in {2} and will start <t:{3}:R>!\n{4} Role for event creation notifications @@ -198,9 +195,6 @@ Event {0} has completed! Duration: {1} - - *[{0}: {1}]* - ever @@ -378,12 +372,6 @@ You cannot unmute this user! - - We do not support hate towards our fellow members. And sometimes, we are not able to ban the offender. - - - This feature is unavailable because this guild is currently blacklisted. - {0}Event {1} will start <t:{2}:R>! diff --git a/Boyfriend/Messages.ru.resx b/Boyfriend/Messages.ru.resx index b593ef5..f009e22 100644 --- a/Boyfriend/Messages.ru.resx +++ b/Boyfriend/Messages.ru.resx @@ -16,14 +16,11 @@ - {0}Я запустился! (C#) + {0}Я запустился! Удалено сообщение от {0} в канале {1}: {2} - - Слишком много упоминаний в одном сообщении - Отредактировано сообщение в канале {0}: {1} -> {2} @@ -157,7 +154,7 @@ Начальная роль - {1}{2} создал событие {3}! Оно пройдёт в {4} и начнётся <t:{5}:R>!{0}{6}{0}https://discord.com/events/{7}/{8} + {0} создал событие {1}! Оно пройдёт в {2} и начнётся <t:{3}:R>!\n{4} Роль для уведомлений о создании событий @@ -189,9 +186,6 @@ Событие {0} завершено! Продолжительность: {1} - - *[{0}: {1}]* - всегда @@ -369,12 +363,6 @@ Я не могу вернуть из мута этого пользователя! - - Мы не поддерживаем ненависть против участников. И иногда, мы не способны забанить нарушителя. - - - Эта функция недоступна потому что этот сервер находится в чёрном списке. - {0}Событие {1} начнется <t:{2}:R>! diff --git a/Boyfriend/Messages.tt-ru.resx b/Boyfriend/Messages.tt-ru.resx index 4917af6..2b8c8ae 100644 --- a/Boyfriend/Messages.tt-ru.resx +++ b/Boyfriend/Messages.tt-ru.resx @@ -6,20 +6,21 @@ 1.3 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + - - {0}я родился! (C#) + + {0}я родился! вырезано {0} в канале {1}: {2} - - ты тут распинался сильно, иди отдохни. - переделано {0}: {1} -> {2} @@ -153,7 +154,7 @@ базовое звание - {1}{2} приготовил новый квест {3}! он пройдёт в {4} и начнётся <t:{5}:R>!{0}{6}{0}https://discord.com/events/{7}/{8} + {0} приготовил новый квест {1}! он пройдёт в {2} и начнётся <t:{3}:R>!\n{4} роль для уведомлений о создании квеста @@ -185,9 +186,6 @@ квест {0} завершен! все это длилось {1} - - *[{0}: {1}]* - всегда @@ -365,12 +363,6 @@ я не могу его раззамутить... - - каве пропал. - - - упс, кажется ваш сервер в черном списке, и я вам ничем помочь не смогу) - {0}квест {1} начнется <t:{2}:R>! diff --git a/Boyfriend/Utils.cs b/Boyfriend/Utils.cs index b2c798f..d9c2bd6 100644 --- a/Boyfriend/Utils.cs +++ b/Boyfriend/Utils.cs @@ -12,10 +12,9 @@ using Humanizer.Localisation; namespace Boyfriend; public static class Utils { - public static readonly Random Random = new(); private static readonly Dictionary ReflectionMessageCache = new(); - private static readonly Dictionary CultureInfoCache = new() { + public static readonly Dictionary CultureInfoCache = new() { { "ru", new CultureInfo("ru-RU") }, { "en", new CultureInfo("en-US") }, { "mctaylors-ru", new CultureInfo("tt-RU") } @@ -28,16 +27,16 @@ public static class Utils { }; public static string GetBeep(int i = -1) { - return GetMessage($"Beep{(i < 0 ? Random.Next(3) + 1 : ++i)}"); + return GetMessage($"Beep{(i < 0 ? Random.Shared.Next(3) + 1 : ++i)}"); } - public static SocketTextChannel? GetAdminLogChannel(ulong id) { + public static SocketTextChannel? GetBotLogChannel(ulong id) { return Boyfriend.Client.GetGuild(id) - .GetTextChannel(ParseMention(Boyfriend.GetGuildConfig(id)["AdminLogChannel"])); + .GetTextChannel(ParseMention(Boyfriend.GetGuildConfig(id)["BotLogChannel"])); } public static string? Wrap(string? original, bool limitedSpace = false) { - if (original == null) return null; + if (original is null) return null; var maxChars = limitedSpace ? 970 : 1940; if (original.Length > maxChars) original = original[..maxChars]; var style = original.Contains('\n') ? "```" : "`"; @@ -52,29 +51,22 @@ public static class Utils { return ulong.TryParse(Regex.Replace(mention, "[^0-9]", ""), out var id) ? id : 0; } - public static SocketUser? ParseUser(string mention) { - var user = Boyfriend.Client.GetUser(ParseMention(mention)); - return user; - } - public static async Task SendDirectMessage(SocketUser user, string toSend) { try { await user.SendMessageAsync(toSend); } catch (HttpException e) { - if (e.DiscordCode != DiscordErrorCode.CannotSendMessageToUser) throw; + if (e.DiscordCode is not DiscordErrorCode.CannotSendMessageToUser) throw; } } public static SocketRole? GetMuteRole(SocketGuild guild) { var id = ulong.Parse(Boyfriend.GetGuildConfig(guild.Id)["MuteRole"]); if (MuteRoleCache.TryGetValue(id, out var cachedMuteRole)) return cachedMuteRole; - SocketRole? role = null; foreach (var x in guild.Roles) { if (x.Id != id) continue; - role = x; - MuteRoleCache.Add(id, role); - break; + MuteRoleCache.Add(id, x); + return x; } - return role; + return null; } public static void RemoveMuteRoleFromCache(ulong id) { @@ -82,7 +74,7 @@ public static class Utils { } public static async Task SilentSendAsync(SocketTextChannel? channel, string text, bool allowRoles = false) { - if (channel == null || text.Length is 0 or > 2000) + if (channel is null || text.Length is 0 or > 2000) throw new Exception($"Message length is out of range: {text.Length}"); await channel.SendMessageAsync(text, false, null, null, allowRoles ? AllowRoles : AllowedMentions.None); @@ -102,8 +94,8 @@ public static class Utils { var toReturn = typeof(Messages).GetProperty(propertyName, BindingFlags.NonPublic | BindingFlags.Static)?.GetValue(null) ?.ToString(); - if (toReturn == null) { - Console.WriteLine($@"Could not find localized property: {propertyName}"); + if (toReturn is null) { + Console.Error.WriteLine($@"Could not find localized property: {propertyName}"); return name; } @@ -113,11 +105,11 @@ public static class Utils { public static async Task SendFeedbackAsync(string feedback, ulong guildId, string mention, bool sendPublic = false) { - var adminChannel = GetAdminLogChannel(guildId); + var adminChannel = GetBotLogChannel(guildId); var systemChannel = Boyfriend.Client.GetGuild(guildId).SystemChannel; - var toSend = string.Format(Messages.FeedbackFormat, mention, feedback); - if (adminChannel != null) await SilentSendAsync(adminChannel, toSend); - if (sendPublic && systemChannel != null) await SilentSendAsync(systemChannel, toSend); + var toSend = $"*[{mention}: {feedback}]*"; + if (adminChannel is not null) await SilentSendAsync(adminChannel, toSend); + if (sendPublic && systemChannel is not null) await SilentSendAsync(systemChannel, toSend); } public static string GetHumanizedTimeOffset(TimeSpan span) { @@ -131,7 +123,7 @@ public static class Utils { } public static void SafeAppendToBuilder(StringBuilder appendTo, string appendWhat, SocketTextChannel? channel) { - if (channel == null) return; + if (channel is null) return; if (appendTo.Length + appendWhat.Length > 2000) { _ = SilentSendAsync(channel, appendTo.ToString()); appendTo.Clear(); @@ -169,15 +161,19 @@ public static class Utils { var eventConfig = Boyfriend.GetGuildConfig(guild.Id); var receivers = eventConfig["EventStartedReceivers"]; - var role = guild.GetRole(Convert.ToUInt64(eventConfig["EventNotifyReceiverRole"])); + var role = guild.GetRole(ulong.Parse(eventConfig["EventNotificationRole"])); var mentions = Boyfriend.StringBuilder; - if (receivers.Contains("role") && role != null) mentions.Append($"{role.Mention} "); + if (receivers.Contains("role") && role is not null) mentions.Append($"{role.Mention} "); if (receivers.Contains("users") || receivers.Contains("interested")) mentions = (await scheduledEvent.GetUsersAsync(15)).Aggregate(mentions, (current, user) => current.Append($"{user.Mention} ")); await channel?.SendMessageAsync(string.Format(Messages.EventEarlyNotification, mentions, - Wrap(scheduledEvent.Name), scheduledEvent.StartTime.ToUnixTimeSeconds()))!; + Wrap(scheduledEvent.Name), scheduledEvent.StartTime.ToUnixTimeSeconds().ToString()))!; mentions.Clear(); } + + public static SocketTextChannel? GetEventNotificationChannel(SocketGuild guild) { + return guild.GetTextChannel(ParseMention(Boyfriend.GetGuildConfig(guild.Id)["EventCreatedChannel"])); + } }