Add a deprecation warning for quoting by message ID

This commit is contained in:
runebaas 2020-09-23 16:46:13 +02:00
parent 58bd4d17d0
commit 216188f61f
No known key found for this signature in database
GPG key ID: 2677AF508D0300D6
4 changed files with 24 additions and 6 deletions

View file

@ -1,5 +1,6 @@
using System;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Discord;
using Discord.Commands;
@ -211,10 +212,9 @@ namespace Geekbot.Bot.Commands.Utils.Quote
{
try
{
// var transContext = await _translationHandler.GetGuildContext(Context);
var message = await Context.Channel.GetMessageAsync(messageId);
await ProcessQuote(message, saveToDb);
await ProcessQuote(message, saveToDb, true);
}
catch (Exception e)
{
@ -226,8 +226,6 @@ namespace Geekbot.Bot.Commands.Utils.Quote
{
try
{
// var transContext = await _translationHandler.GetGuildContext(Context);
if (!MessageLink.IsValid(messageLink))
{
await ReplyAsync(Localization.Quote.NotAValidMessageLink);
@ -255,7 +253,7 @@ namespace Geekbot.Bot.Commands.Utils.Quote
}
}
private async Task ProcessQuote(IMessage message, bool saveToDb)
private async Task ProcessQuote(IMessage message, bool saveToDb, bool showMessageIdWarning = false)
{
if (message.Author.Id == Context.Message.Author.Id && saveToDb && !_isDev)
{
@ -277,7 +275,12 @@ namespace Geekbot.Bot.Commands.Utils.Quote
}
var embed = QuoteBuilder(quote);
await ReplyAsync(saveToDb ? Localization.Quote.QuoteAdded : string.Empty, false, embed.Build());
var sb = new StringBuilder();
if (saveToDb) sb.AppendLine(Localization.Quote.QuoteAdded);
if (showMessageIdWarning) sb.AppendLine(Localization.Quote.MessageIdDeprecation);
await ReplyAsync(sb.ToString(), false, embed.Build());
}
private EmbedBuilder QuoteBuilder(QuoteModel quote)

View file

@ -78,6 +78,15 @@ namespace Geekbot.Bot.Localization {
}
}
/// <summary>
/// Looks up a localized string similar to :warning: Creating quotes by message ID is deprecated in favour of message links and will be removed on 1 December 2020.
/// </summary>
internal static string MessageIdDeprecation {
get {
return ResourceManager.GetString("MessageIdDeprecation", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Most quoted person.
/// </summary>

View file

@ -44,4 +44,7 @@
<data name="OnlyQuoteFromSameServer" xml:space="preserve">
<value>Du chasch numme nachrichte vom gliche server quote</value>
</data>
<data name="MessageIdDeprecation" xml:space="preserve">
<value>:warning: Es mache vo quotes mit message-IDs isch zgunste vo message-links veraltet und wird am 1. dezember 2020 entfernt</value>
</data>
</root>

View file

@ -51,4 +51,7 @@
<data name="OnlyQuoteFromSameServer" xml:space="preserve">
<value>You can only quote messages from the same server</value>
</data>
<data name="MessageIdDeprecation" xml:space="preserve">
<value>:warning: Creating quotes by message ID is deprecated in favour of message links and will be removed on 1 December 2020</value>
</data>
</root>