Add a deprecation warning for quoting by message ID
This commit is contained in:
parent
58bd4d17d0
commit
216188f61f
4 changed files with 24 additions and 6 deletions
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Discord;
|
using Discord;
|
||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
|
@ -211,10 +212,9 @@ namespace Geekbot.Bot.Commands.Utils.Quote
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// var transContext = await _translationHandler.GetGuildContext(Context);
|
|
||||||
var message = await Context.Channel.GetMessageAsync(messageId);
|
var message = await Context.Channel.GetMessageAsync(messageId);
|
||||||
|
|
||||||
await ProcessQuote(message, saveToDb);
|
await ProcessQuote(message, saveToDb, true);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -226,8 +226,6 @@ namespace Geekbot.Bot.Commands.Utils.Quote
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// var transContext = await _translationHandler.GetGuildContext(Context);
|
|
||||||
|
|
||||||
if (!MessageLink.IsValid(messageLink))
|
if (!MessageLink.IsValid(messageLink))
|
||||||
{
|
{
|
||||||
await ReplyAsync(Localization.Quote.NotAValidMessageLink);
|
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)
|
if (message.Author.Id == Context.Message.Author.Id && saveToDb && !_isDev)
|
||||||
{
|
{
|
||||||
|
@ -277,7 +275,12 @@ namespace Geekbot.Bot.Commands.Utils.Quote
|
||||||
}
|
}
|
||||||
|
|
||||||
var embed = QuoteBuilder(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)
|
private EmbedBuilder QuoteBuilder(QuoteModel quote)
|
||||||
|
|
9
src/Bot/Localization/Quote.Designer.cs
generated
9
src/Bot/Localization/Quote.Designer.cs
generated
|
@ -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>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Most quoted person.
|
/// Looks up a localized string similar to Most quoted person.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -44,4 +44,7 @@
|
||||||
<data name="OnlyQuoteFromSameServer" xml:space="preserve">
|
<data name="OnlyQuoteFromSameServer" xml:space="preserve">
|
||||||
<value>Du chasch numme nachrichte vom gliche server quote</value>
|
<value>Du chasch numme nachrichte vom gliche server quote</value>
|
||||||
</data>
|
</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>
|
</root>
|
|
@ -51,4 +51,7 @@
|
||||||
<data name="OnlyQuoteFromSameServer" xml:space="preserve">
|
<data name="OnlyQuoteFromSameServer" xml:space="preserve">
|
||||||
<value>You can only quote messages from the same server</value>
|
<value>You can only quote messages from the same server</value>
|
||||||
</data>
|
</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>
|
</root>
|
Loading…
Reference in a new issue