mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 09:48:26 -04:00
Small refactoring. Finally made use of the type parameter in NadekoTypeReader<T> class
This commit is contained in:
@@ -341,38 +341,6 @@ public class GreetService : INService, IReadyExecutor
|
||||
return settings;
|
||||
}
|
||||
|
||||
public async Task<bool> SetSettings(ulong guildId, GreetSettings settings)
|
||||
{
|
||||
if (settings.AutoDeleteByeMessagesTimer is > 600 or < 0
|
||||
|| settings.AutoDeleteGreetMessagesTimer is > 600 or < 0)
|
||||
return false;
|
||||
|
||||
await using var uow = _db.GetDbContext();
|
||||
var conf = uow.GuildConfigsForId(guildId, set => set);
|
||||
conf.DmGreetMessageText = settings.DmGreetMessageText?.SanitizeMentions();
|
||||
conf.ChannelGreetMessageText = settings.ChannelGreetMessageText?.SanitizeMentions();
|
||||
conf.ChannelByeMessageText = settings.ChannelByeMessageText?.SanitizeMentions();
|
||||
|
||||
conf.AutoDeleteGreetMessagesTimer = settings.AutoDeleteGreetMessagesTimer;
|
||||
conf.AutoDeleteGreetMessages = settings.AutoDeleteGreetMessagesTimer > 0;
|
||||
|
||||
conf.AutoDeleteByeMessagesTimer = settings.AutoDeleteByeMessagesTimer;
|
||||
conf.AutoDeleteByeMessages = settings.AutoDeleteByeMessagesTimer > 0;
|
||||
|
||||
conf.GreetMessageChannelId = settings.GreetMessageChannelId;
|
||||
conf.ByeMessageChannelId = settings.ByeMessageChannelId;
|
||||
|
||||
conf.SendChannelGreetMessage = settings.SendChannelGreetMessage;
|
||||
conf.SendChannelByeMessage = settings.SendChannelByeMessage;
|
||||
|
||||
await uow.SaveChangesAsync();
|
||||
|
||||
var toAdd = GreetSettings.Create(conf);
|
||||
_guildConfigsCache[guildId] = toAdd;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public async Task<bool> SetGreet(ulong guildId, ulong channelId, bool? value = null)
|
||||
{
|
||||
await using var uow = _db.GetDbContext();
|
||||
|
@@ -56,13 +56,13 @@ public partial class Administration
|
||||
CultureInfo ci;
|
||||
if (name.Trim().ToLowerInvariant() == "default")
|
||||
{
|
||||
Localization.RemoveGuildCulture(ctx.Guild);
|
||||
ci = Localization.DefaultCultureInfo;
|
||||
_localization.RemoveGuildCulture(ctx.Guild);
|
||||
ci = _localization.DefaultCultureInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
ci = new(name);
|
||||
Localization.SetGuildCulture(ctx.Guild, ci);
|
||||
_localization.SetGuildCulture(ctx.Guild, ci);
|
||||
}
|
||||
|
||||
await ReplyConfirmLocalizedAsync(strs.lang_set(Format.Bold(ci.ToString()), Format.Bold(ci.NativeName)));
|
||||
@@ -76,7 +76,7 @@ public partial class Administration
|
||||
[Cmd]
|
||||
public async partial Task LanguageSetDefault()
|
||||
{
|
||||
var cul = Localization.DefaultCultureInfo;
|
||||
var cul = _localization.DefaultCultureInfo;
|
||||
await ReplyErrorLocalizedAsync(strs.lang_set_bot_show(cul, cul.NativeName));
|
||||
}
|
||||
|
||||
@@ -89,13 +89,13 @@ public partial class Administration
|
||||
CultureInfo ci;
|
||||
if (name.Trim().ToLowerInvariant() == "default")
|
||||
{
|
||||
Localization.ResetDefaultCulture();
|
||||
ci = Localization.DefaultCultureInfo;
|
||||
_localization.ResetDefaultCulture();
|
||||
ci = _localization.DefaultCultureInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
ci = new(name);
|
||||
Localization.SetDefaultCulture(ci);
|
||||
_localization.SetDefaultCulture(ci);
|
||||
}
|
||||
|
||||
await ReplyConfirmLocalizedAsync(strs.lang_set_bot(Format.Bold(ci.ToString()),
|
||||
|
@@ -14,7 +14,7 @@ public partial class Administration
|
||||
[Cmd]
|
||||
[Priority(1)]
|
||||
public async partial Task Prefix()
|
||||
=> await ReplyConfirmLocalizedAsync(strs.prefix_current(Format.Code(CmdHandler.GetPrefix(ctx.Guild))));
|
||||
=> await ReplyConfirmLocalizedAsync(strs.prefix_current(Format.Code(_cmdHandler.GetPrefix(ctx.Guild))));
|
||||
|
||||
[Cmd]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
@@ -33,7 +33,7 @@ public partial class Administration
|
||||
return;
|
||||
|
||||
var oldPrefix = prefix;
|
||||
var newPrefix = CmdHandler.SetPrefix(ctx.Guild, toSet);
|
||||
var newPrefix = _cmdHandler.SetPrefix(ctx.Guild, toSet);
|
||||
|
||||
await ReplyConfirmLocalizedAsync(strs.prefix_new(Format.Code(oldPrefix), Format.Code(newPrefix)));
|
||||
}
|
||||
@@ -44,12 +44,12 @@ public partial class Administration
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(toSet))
|
||||
{
|
||||
await ReplyConfirmLocalizedAsync(strs.defprefix_current(CmdHandler.GetPrefix()));
|
||||
await ReplyConfirmLocalizedAsync(strs.defprefix_current(_cmdHandler.GetPrefix()));
|
||||
return;
|
||||
}
|
||||
|
||||
var oldPrefix = CmdHandler.GetPrefix();
|
||||
var newPrefix = CmdHandler.SetDefaultPrefix(toSet);
|
||||
var oldPrefix = _cmdHandler.GetPrefix();
|
||||
var newPrefix = _cmdHandler.SetDefaultPrefix(toSet);
|
||||
|
||||
await ReplyConfirmLocalizedAsync(strs.defprefix_new(Format.Code(oldPrefix), Format.Code(newPrefix)));
|
||||
}
|
||||
|
Reference in New Issue
Block a user