2017-07-20 03:10:39 +00:00
|
|
|
|
using Discord;
|
|
|
|
|
using Discord.Commands;
|
|
|
|
|
using NadekoBot.Common;
|
|
|
|
|
using NadekoBot.Common.Attributes;
|
2017-10-13 04:14:54 +00:00
|
|
|
|
using NadekoBot.Core.Services;
|
2017-07-20 03:10:39 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace NadekoBot.Modules.Utility
|
|
|
|
|
{
|
|
|
|
|
public partial class Utility
|
|
|
|
|
{
|
2017-07-25 16:31:30 +00:00
|
|
|
|
public class BotConfigCommands : NadekoSubmodule
|
2017-07-20 03:10:39 +00:00
|
|
|
|
{
|
2017-07-25 16:31:30 +00:00
|
|
|
|
private readonly IBotConfigProvider _service;
|
|
|
|
|
|
|
|
|
|
public BotConfigCommands(IBotConfigProvider service)
|
|
|
|
|
{
|
|
|
|
|
_service = service;
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-20 03:10:39 +00:00
|
|
|
|
[NadekoCommand, Usage, Description, Aliases]
|
|
|
|
|
[OwnerOnly]
|
|
|
|
|
public async Task BotConfigEdit()
|
|
|
|
|
{
|
|
|
|
|
var names = Enum.GetNames(typeof(BotConfigEditType));
|
|
|
|
|
await ReplyAsync(string.Join(", ", names)).ConfigureAwait(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[NadekoCommand, Usage, Description, Aliases]
|
|
|
|
|
[OwnerOnly]
|
|
|
|
|
public async Task BotConfigEdit(BotConfigEditType type, [Remainder]string newValue = null)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(newValue))
|
|
|
|
|
newValue = null;
|
|
|
|
|
|
|
|
|
|
var success = _service.Edit(type, newValue);
|
|
|
|
|
|
|
|
|
|
if (!success)
|
|
|
|
|
await ReplyErrorLocalized("bot_config_edit_fail", Format.Bold(type.ToString()), Format.Bold(newValue ?? "NULL")).ConfigureAwait(false);
|
|
|
|
|
else
|
|
|
|
|
await ReplyConfirmLocalized("bot_config_edit_success", Format.Bold(type.ToString()), Format.Bold(newValue ?? "NULL")).ConfigureAwait(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|