1
0
Fork 1
mirror of https://github.com/TeamOctolings/Octobot.git synced 2025-01-31 09:09:00 +03:00
Octobot/Boyfriend/Commands/SettingsModule.cs
2021-12-15 11:19:14 +05:00

46 lines
No EOL
1.8 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Discord.Commands;
// ReSharper disable UnusedType.Global
// ReSharper disable UnusedMember.Global
namespace Boyfriend.Commands;
public class SettingsModule : ModuleBase<SocketCommandContext> {
[Command("settings")]
[Summary("Настраивает бота")]
[Alias("config", "настройки", "конфиг")]
public async Task Run([Remainder] string s = "") {
var config = Boyfriend.GetGuildConfig(Context.Guild);
var sArray = s.Split(" ");
if (s == "") {
var nl = Environment.NewLine;
await Context.Channel.SendMessageAsync($"Текущие настройки:{nl}Язык: `{config.Lang}`" +
$"{nl}Префикс: `{config.Prefix}`" +
$"{nl}Удалять роли при муте: " +
$"{(config.RemoveRolesOnMute ? "Да" : "Нет")}");
return;
}
if (sArray[0].ToLower() == "lang") {
if (sArray[1].ToLower() != "ru") throw new Exception("Язык не поддерживается!");
config.Lang = sArray[1].ToLower();
}
if (sArray[0].ToLower() == "prefix")
config.Prefix = sArray[1];
if (sArray[0].ToLower() == "removerolesonmute") {
try {
config.RemoveRolesOnMute = bool.Parse(sArray[1].ToLower());
} catch (FormatException) {
await Context.Channel.SendMessageAsync("Неверный параметр! Требуется `true` или `false`");
return;
}
}
config.Save();
await Context.Channel.SendMessageAsync("Настройки успешно обновлены!");
}
}