public static async Task SendErrorMessageByDescription(IGuild guild, ISocketMessageChannel channel, string description) { // Get the language for this Guild Language language = DiscordUtil.GetDefaultLanguage(guild); // Start building an Embed EmbedBuilder embedBuilder = new EmbedBuilder() .WithTitle(Localizer.Localize("discord.error", language)) .WithColor(Color.Red) .WithDescription(description); await channel.SendMessageAsync(embed : embedBuilder.Build()); }
public static async Task SendErrorMessageByTypeAndMessage(IGuild guild, ISocketMessageChannel channel, string type, string message, bool isException = false) { // Get the language for this Guild Language language = DiscordUtil.GetDefaultLanguage(guild); // Start building an Embed EmbedBuilder embedBuilder = new EmbedBuilder() .WithTitle(Localizer.Localize("discord.error", language)) .WithColor(Color.Red) .WithDescription(Localizer.Localize($"discord.error.{(isException ? "exception" : "unknown")}", language)) .AddField(Localizer.Localize("discord.error.type", language), type) .AddField(Localizer.Localize("discord.error.message", language), message); await channel.SendMessageAsync(embed : embedBuilder.Build()); }
public static async Task DeactivateInteractiveMessage(InteractiveMessage message, bool isBecauseInactive = false) { // Acquire the semaphore await InteractiveMessageSemaphore.WaitAsync(); // Check if this message is inactive if (!message.IsActive) { goto done; } // Set as inactive message.IsActive = false; // Add this to the active messages bool isSuccess = ActiveInteractiveMessages.Remove(message); // Clear all reactions if needed if (isSuccess) { await message.ClearReactions(); } // Get a Language if possible IGuildChannel guildChannel = message.Channel as IGuildChannel; Language language = guildChannel != null?DiscordUtil.GetDefaultLanguage(guildChannel.Guild, guildChannel) : Language.EnglishUS; // Modify the message to say that it has timed out if needed if (isBecauseInactive) { await message.TargetMessage.ModifyAsync(p => { p.Content = null; p.Embed = new EmbedBuilder() .WithTitle(Localizer.Localize("discord.interactive_timeout.title", language)) .WithDescription(Localizer.Localize("discord.interactive_timeout.description", language)) .Build(); }); } done: // Release the semaphore InteractiveMessageSemaphore.Release(); }