Parially translate quote
This commit is contained in:
parent
03d1607d64
commit
e5742165d1
3 changed files with 45 additions and 12 deletions
|
@ -22,9 +22,9 @@ namespace Geekbot.net.Commands.Admin
|
||||||
private readonly DatabaseContext _database;
|
private readonly DatabaseContext _database;
|
||||||
private readonly IErrorHandler _errorHandler;
|
private readonly IErrorHandler _errorHandler;
|
||||||
private readonly IReactionListener _reactionListener;
|
private readonly IReactionListener _reactionListener;
|
||||||
private readonly TranslationHandler _translationHandler;
|
private readonly ITranslationHandler _translationHandler;
|
||||||
|
|
||||||
public Role(DatabaseContext database, IErrorHandler errorHandler, IReactionListener reactionListener, TranslationHandler translationHandler)
|
public Role(DatabaseContext database, IErrorHandler errorHandler, IReactionListener reactionListener, ITranslationHandler translationHandler)
|
||||||
{
|
{
|
||||||
_database = database;
|
_database = database;
|
||||||
_errorHandler = errorHandler;
|
_errorHandler = errorHandler;
|
||||||
|
|
|
@ -8,6 +8,7 @@ using Geekbot.net.Database.Models;
|
||||||
using Geekbot.net.Lib.CommandPreconditions;
|
using Geekbot.net.Lib.CommandPreconditions;
|
||||||
using Geekbot.net.Lib.ErrorHandling;
|
using Geekbot.net.Lib.ErrorHandling;
|
||||||
using Geekbot.net.Lib.Extensions;
|
using Geekbot.net.Lib.Extensions;
|
||||||
|
using Geekbot.net.Lib.Localization;
|
||||||
using Geekbot.net.Lib.Polyfills;
|
using Geekbot.net.Lib.Polyfills;
|
||||||
using Geekbot.net.Lib.RandomNumberGenerator;
|
using Geekbot.net.Lib.RandomNumberGenerator;
|
||||||
|
|
||||||
|
@ -20,12 +21,14 @@ namespace Geekbot.net.Commands.Utils.Quote
|
||||||
private readonly IErrorHandler _errorHandler;
|
private readonly IErrorHandler _errorHandler;
|
||||||
private readonly DatabaseContext _database;
|
private readonly DatabaseContext _database;
|
||||||
private readonly IRandomNumberGenerator _randomNumberGenerator;
|
private readonly IRandomNumberGenerator _randomNumberGenerator;
|
||||||
|
private readonly ITranslationHandler _translationHandler;
|
||||||
|
|
||||||
public Quote(IErrorHandler errorHandler, DatabaseContext database, IRandomNumberGenerator randomNumberGenerator)
|
public Quote(IErrorHandler errorHandler, DatabaseContext database, IRandomNumberGenerator randomNumberGenerator, ITranslationHandler translationHandler)
|
||||||
{
|
{
|
||||||
_errorHandler = errorHandler;
|
_errorHandler = errorHandler;
|
||||||
_database = database;
|
_database = database;
|
||||||
_randomNumberGenerator = randomNumberGenerator;
|
_randomNumberGenerator = randomNumberGenerator;
|
||||||
|
_translationHandler = translationHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Command]
|
[Command]
|
||||||
|
@ -38,7 +41,8 @@ namespace Geekbot.net.Commands.Utils.Quote
|
||||||
|
|
||||||
if (!s.Any())
|
if (!s.Any())
|
||||||
{
|
{
|
||||||
await ReplyAsync("This server doesn't seem to have any quotes yet. You can add a quote with `!quote save @user` or `!quote save <messageId>`");
|
var transContext = await _translationHandler.GetGuildContext(Context);
|
||||||
|
await ReplyAsync(transContext.GetString("NoQuotesFound"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,15 +64,16 @@ namespace Geekbot.net.Commands.Utils.Quote
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
var transContext = await _translationHandler.GetGuildContext(Context);
|
||||||
if (user.Id == Context.Message.Author.Id)
|
if (user.Id == Context.Message.Author.Id)
|
||||||
{
|
{
|
||||||
await ReplyAsync("You can't save your own quotes...");
|
await ReplyAsync(transContext.GetString("CannotSaveOwnQuotes"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user.IsBot)
|
if (user.IsBot)
|
||||||
{
|
{
|
||||||
await ReplyAsync("You can't save quotes by a bot...");
|
await ReplyAsync(transContext.GetString("CannotQuoteBots"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +85,7 @@ namespace Geekbot.net.Commands.Utils.Quote
|
||||||
await _database.SaveChangesAsync();
|
await _database.SaveChangesAsync();
|
||||||
|
|
||||||
var embed = QuoteBuilder(quote);
|
var embed = QuoteBuilder(quote);
|
||||||
await ReplyAsync("**Quote Added**", false, embed.Build());
|
await ReplyAsync(transContext.GetString("QuoteAdded"), false, embed.Build());
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -95,16 +100,17 @@ namespace Geekbot.net.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);
|
||||||
if (message.Author.Id == Context.Message.Author.Id)
|
if (message.Author.Id == Context.Message.Author.Id)
|
||||||
{
|
{
|
||||||
await ReplyAsync("You can't save your own quotes...");
|
await ReplyAsync(transContext.GetString("CannotSaveOwnQuotes"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.Author.IsBot)
|
if (message.Author.IsBot)
|
||||||
{
|
{
|
||||||
await ReplyAsync("You can't save quotes by a bot...");
|
await ReplyAsync(transContext.GetString("CannotQuoteBots"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +119,7 @@ namespace Geekbot.net.Commands.Utils.Quote
|
||||||
await _database.SaveChangesAsync();
|
await _database.SaveChangesAsync();
|
||||||
|
|
||||||
var embed = QuoteBuilder(quote);
|
var embed = QuoteBuilder(quote);
|
||||||
await ReplyAsync("**Quote Added**", false, embed.Build());
|
await ReplyAsync(transContext.GetString("QuoteAdded"), false, embed.Build());
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -168,17 +174,18 @@ namespace Geekbot.net.Commands.Utils.Quote
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
var transContext = await _translationHandler.GetGuildContext(Context);
|
||||||
var quote = _database.Quotes.Where(e => e.GuildId == Context.Guild.Id.AsLong() && e.InternalId == id)?.FirstOrDefault();
|
var quote = _database.Quotes.Where(e => e.GuildId == Context.Guild.Id.AsLong() && e.InternalId == id)?.FirstOrDefault();
|
||||||
if (quote != null)
|
if (quote != null)
|
||||||
{
|
{
|
||||||
_database.Quotes.Remove(quote);
|
_database.Quotes.Remove(quote);
|
||||||
await _database.SaveChangesAsync();
|
await _database.SaveChangesAsync();
|
||||||
var embed = QuoteBuilder(quote);
|
var embed = QuoteBuilder(quote);
|
||||||
await ReplyAsync($"**Removed #{id}**", false, embed.Build());
|
await ReplyAsync(transContext.GetString("Removed", id), false, embed.Build());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await ReplyAsync("I couldn't find a quote with that id :disappointed:");
|
await ReplyAsync(transContext.GetString("NotFoundWithId"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|
|
@ -190,5 +190,31 @@
|
||||||
"EN": ["Removed {0} from the whitelist"],
|
"EN": ["Removed {0} from the whitelist"],
|
||||||
"CHDE": ["{0} isch vo dr whitelist glöscht"]
|
"CHDE": ["{0} isch vo dr whitelist glöscht"]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"quote": {
|
||||||
|
"NoQuotesFound": {
|
||||||
|
"EN": ["This server doesn't seem to have any quotes yet. You can add a quote with `!quote save @user` or `!quote save <messageId>`"],
|
||||||
|
"CHDE": ["Dä server het no kei quotes. Du chasch quotes hinzuefüege mit `!quote save @user` oder `!quote save <messageId>`"]
|
||||||
|
},
|
||||||
|
"CannotSaveOwnQuotes": {
|
||||||
|
"EN": ["You can't save your own quotes..."],
|
||||||
|
"CHDE": ["Du chasch kei quotes vo dir selber speichere..."]
|
||||||
|
},
|
||||||
|
"CannotQuoteBots": {
|
||||||
|
"EN": ["You can't save quotes by a bot..."],
|
||||||
|
"CHDE": ["Du chasch kei quotes vomne bot speichere..."]
|
||||||
|
},
|
||||||
|
"QuoteAdded": {
|
||||||
|
"EN": ["**Quote Added**"],
|
||||||
|
"CHDE": ["**Quote hinzugfüegt**"]
|
||||||
|
},
|
||||||
|
"Removed": {
|
||||||
|
"EN": ["**Removed #{0}**"],
|
||||||
|
"CHDE": ["**#{0} glöscht**"]
|
||||||
|
},
|
||||||
|
"NotFoundWithId": {
|
||||||
|
"EN": ["I couldn't find a quote with that ID :disappointed:"],
|
||||||
|
"CHDE": ["Ich chan kei quote finde mit därri ID :disappointed:"]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue