mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-04-30 02:59:54 +03:00
Rename solution & project, move the project files one layer up
This commit is contained in:
parent
b486d2d3d9
commit
c220a0f379
27 changed files with 52 additions and 76 deletions
45
Commands/BanCommand.cs
Normal file
45
Commands/BanCommand.cs
Normal file
|
@ -0,0 +1,45 @@
|
|||
using Boyfriend.Data;
|
||||
using Discord;
|
||||
using Discord.WebSocket;
|
||||
|
||||
namespace Boyfriend.Commands;
|
||||
|
||||
public sealed class BanCommand : ICommand {
|
||||
public string[] Aliases { get; } = { "ban", "бан" };
|
||||
|
||||
public async Task RunAsync(CommandProcessor cmd, string[] args, string[] cleanArgs) {
|
||||
var toBan = cmd.GetUser(args, cleanArgs, 0);
|
||||
if (toBan is null || !cmd.HasPermission(GuildPermission.BanMembers)) return;
|
||||
|
||||
var memberToBan = cmd.GetMember(toBan.Item1);
|
||||
if (memberToBan is not null && !cmd.CanInteractWith(memberToBan, "Ban")) return;
|
||||
|
||||
var duration = CommandProcessor.GetTimeSpan(args, 1);
|
||||
var reason = cmd.GetRemaining(args, duration.TotalSeconds < 1 ? 1 : 2, "BanReason");
|
||||
if (reason is not null) await BanUserAsync(cmd, toBan, duration, reason);
|
||||
}
|
||||
|
||||
private static async Task BanUserAsync(CommandProcessor cmd, Tuple<ulong, SocketUser?> toBan, TimeSpan duration,
|
||||
string reason) {
|
||||
var author = cmd.Context.User;
|
||||
var guild = cmd.Context.Guild;
|
||||
if (toBan.Item2 is not null)
|
||||
await Utils.SendDirectMessage(toBan.Item2,
|
||||
string.Format(Messages.YouWereBanned, author.Mention, guild.Name, Utils.Wrap(reason)));
|
||||
|
||||
var guildBanMessage = $"({author}) {reason}";
|
||||
await guild.AddBanAsync(toBan.Item1, 0, guildBanMessage);
|
||||
|
||||
var memberData = GuildData.Get(guild).MemberData[toBan.Item1];
|
||||
memberData.BannedUntil
|
||||
= duration.TotalSeconds < 1 ? DateTimeOffset.MaxValue : DateTimeOffset.Now.Add(duration);
|
||||
memberData.Roles.Clear();
|
||||
|
||||
cmd.ConfigWriteScheduled = true;
|
||||
|
||||
var feedback = string.Format(Messages.FeedbackUserBanned, $"<@{toBan.Item1.ToString()}>",
|
||||
Utils.GetHumanizedTimeSpan(duration), Utils.Wrap(reason));
|
||||
cmd.Reply(feedback, ReplyEmojis.Banned);
|
||||
cmd.Audit(feedback);
|
||||
}
|
||||
}
|
25
Commands/ClearCommand.cs
Normal file
25
Commands/ClearCommand.cs
Normal file
|
@ -0,0 +1,25 @@
|
|||
using System.Diagnostics;
|
||||
using Discord;
|
||||
using Discord.WebSocket;
|
||||
|
||||
namespace Boyfriend.Commands;
|
||||
|
||||
public sealed class ClearCommand : ICommand {
|
||||
public string[] Aliases { get; } = { "clear", "purge", "очистить", "стереть" };
|
||||
|
||||
public async Task RunAsync(CommandProcessor cmd, string[] args, string[] cleanArgs) {
|
||||
if (cmd.Context.Channel is not SocketTextChannel channel) throw new UnreachableException();
|
||||
|
||||
if (!cmd.HasPermission(GuildPermission.ManageMessages)) return;
|
||||
|
||||
var toDelete = cmd.GetNumberRange(cleanArgs, 0, 1, 200, "ClearAmount");
|
||||
if (toDelete is null) return;
|
||||
var messages = await channel.GetMessagesAsync((int)(toDelete + 1)).FlattenAsync();
|
||||
|
||||
var user = (SocketGuildUser)cmd.Context.User;
|
||||
await channel.DeleteMessagesAsync(messages, Utils.GetRequestOptions(user.ToString()!));
|
||||
|
||||
cmd.Audit(string.Format(Messages.FeedbackMessagesCleared, (toDelete + 1).ToString(),
|
||||
Utils.MentionChannel(channel.Id)));
|
||||
}
|
||||
}
|
21
Commands/HelpCommand.cs
Normal file
21
Commands/HelpCommand.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
using Boyfriend.Data;
|
||||
using Humanizer;
|
||||
|
||||
namespace Boyfriend.Commands;
|
||||
|
||||
public sealed class HelpCommand : ICommand {
|
||||
public string[] Aliases { get; } = { "help", "помощь", "справка" };
|
||||
|
||||
public Task RunAsync(CommandProcessor cmd, string[] args, string[] cleanArgs) {
|
||||
var prefix = GuildData.Get(cmd.Context.Guild).Preferences["Prefix"];
|
||||
var toSend = Boyfriend.StringBuilder.Append(Messages.CommandHelp);
|
||||
|
||||
foreach (var command in CommandProcessor.Commands)
|
||||
toSend.Append(
|
||||
$"\n`{prefix}{command.Aliases[0]}`: {Utils.GetMessage($"CommandDescription{command.Aliases[0].Titleize()}")}");
|
||||
cmd.Reply(toSend.ToString(), ReplyEmojis.Help);
|
||||
toSend.Clear();
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
7
Commands/ICommand.cs
Normal file
7
Commands/ICommand.cs
Normal file
|
@ -0,0 +1,7 @@
|
|||
namespace Boyfriend.Commands;
|
||||
|
||||
public interface ICommand {
|
||||
public string[] Aliases { get; }
|
||||
|
||||
public Task RunAsync(CommandProcessor cmd, string[] args, string[] cleanArgs);
|
||||
}
|
34
Commands/KickCommand.cs
Normal file
34
Commands/KickCommand.cs
Normal file
|
@ -0,0 +1,34 @@
|
|||
using Boyfriend.Data;
|
||||
using Discord;
|
||||
using Discord.WebSocket;
|
||||
|
||||
namespace Boyfriend.Commands;
|
||||
|
||||
public sealed class KickCommand : ICommand {
|
||||
public string[] Aliases { get; } = { "kick", "кик", "выгнать" };
|
||||
|
||||
public async Task RunAsync(CommandProcessor cmd, string[] args, string[] cleanArgs) {
|
||||
var toKick = cmd.GetMember(args, 0);
|
||||
if (toKick is null || !cmd.HasPermission(GuildPermission.KickMembers)) return;
|
||||
|
||||
if (cmd.CanInteractWith(toKick, "Kick"))
|
||||
await KickMemberAsync(cmd, toKick, cmd.GetRemaining(args, 1, "KickReason"));
|
||||
}
|
||||
|
||||
private static async Task KickMemberAsync(CommandProcessor cmd, SocketGuildUser toKick, string? reason) {
|
||||
if (reason is null) return;
|
||||
var guildKickMessage = $"({cmd.Context.User}) {reason}";
|
||||
|
||||
await Utils.SendDirectMessage(toKick,
|
||||
string.Format(Messages.YouWereKicked, cmd.Context.User.Mention, cmd.Context.Guild.Name,
|
||||
Utils.Wrap(reason)));
|
||||
|
||||
GuildData.Get(cmd.Context.Guild).MemberData[toKick.Id].Roles.Clear();
|
||||
cmd.ConfigWriteScheduled = true;
|
||||
|
||||
await toKick.KickAsync(guildKickMessage);
|
||||
var format = string.Format(Messages.FeedbackMemberKicked, toKick.Mention, Utils.Wrap(reason));
|
||||
cmd.Reply(format, ReplyEmojis.Kicked);
|
||||
cmd.Audit(format);
|
||||
}
|
||||
}
|
66
Commands/MuteCommand.cs
Normal file
66
Commands/MuteCommand.cs
Normal file
|
@ -0,0 +1,66 @@
|
|||
using Boyfriend.Data;
|
||||
using Discord;
|
||||
using Discord.WebSocket;
|
||||
|
||||
namespace Boyfriend.Commands;
|
||||
|
||||
public sealed class MuteCommand : ICommand {
|
||||
public string[] Aliases { get; } = { "mute", "timeout", "заглушить", "мут" };
|
||||
|
||||
public async Task RunAsync(CommandProcessor cmd, string[] args, string[] cleanArgs) {
|
||||
var toMute = cmd.GetMember(args, 0);
|
||||
if (toMute is null) return;
|
||||
|
||||
var duration = CommandProcessor.GetTimeSpan(args, 1);
|
||||
var reason = cmd.GetRemaining(args, duration.TotalSeconds < 1 ? 1 : 2, "MuteReason");
|
||||
if (reason is null) return;
|
||||
var guildData = GuildData.Get(cmd.Context.Guild);
|
||||
var role = guildData.MuteRole;
|
||||
|
||||
if ((role is not null && toMute.Roles.Contains(role))
|
||||
|| (toMute.TimedOutUntil is not null
|
||||
&& toMute.TimedOutUntil.Value
|
||||
> DateTimeOffset.Now)) {
|
||||
cmd.Reply(Messages.MemberAlreadyMuted, ReplyEmojis.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (cmd.HasPermission(GuildPermission.ModerateMembers) && cmd.CanInteractWith(toMute, "Mute"))
|
||||
await MuteMemberAsync(cmd, toMute, duration, guildData, reason);
|
||||
}
|
||||
|
||||
private static async Task MuteMemberAsync(CommandProcessor cmd, SocketGuildUser toMute,
|
||||
TimeSpan duration, GuildData data, string reason) {
|
||||
var requestOptions = Utils.GetRequestOptions($"({cmd.Context.User}) {reason}");
|
||||
var role = data.MuteRole;
|
||||
var hasDuration = duration.TotalSeconds > 0;
|
||||
|
||||
if (role is not null) {
|
||||
if (data.Preferences["RemoveRolesOnMute"] is "true")
|
||||
await toMute.RemoveRolesAsync(toMute.Roles, requestOptions);
|
||||
|
||||
await toMute.AddRoleAsync(role, requestOptions);
|
||||
} else {
|
||||
if (!hasDuration || duration.TotalDays > 28) {
|
||||
cmd.Reply(Messages.DurationRequiredForTimeOuts, ReplyEmojis.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (toMute.IsBot) {
|
||||
cmd.Reply(Messages.CannotTimeOutBot, ReplyEmojis.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
await toMute.SetTimeOutAsync(duration, requestOptions);
|
||||
}
|
||||
|
||||
data.MemberData[toMute.Id].MutedUntil = DateTimeOffset.Now.Add(duration);
|
||||
cmd.ConfigWriteScheduled = true;
|
||||
|
||||
var feedback = string.Format(Messages.FeedbackMemberMuted, toMute.Mention,
|
||||
Utils.GetHumanizedTimeSpan(duration),
|
||||
Utils.Wrap(reason));
|
||||
cmd.Reply(feedback, ReplyEmojis.Muted);
|
||||
cmd.Audit(feedback);
|
||||
}
|
||||
}
|
18
Commands/PingCommand.cs
Normal file
18
Commands/PingCommand.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
namespace Boyfriend.Commands;
|
||||
|
||||
public sealed class PingCommand : ICommand {
|
||||
public string[] Aliases { get; } = { "ping", "latency", "pong", "пинг", "задержка", "понг" };
|
||||
|
||||
public Task RunAsync(CommandProcessor cmd, string[] args, string[] cleanArgs) {
|
||||
var builder = Boyfriend.StringBuilder;
|
||||
|
||||
builder.Append(Utils.GetBeep())
|
||||
.Append(Math.Round(Math.Abs(DateTimeOffset.Now.Subtract(cmd.Context.Message.Timestamp).TotalMilliseconds)))
|
||||
.Append(Messages.Milliseconds);
|
||||
|
||||
cmd.Reply(builder.ToString(), ReplyEmojis.Ping);
|
||||
builder.Clear();
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
23
Commands/RemindCommand.cs
Normal file
23
Commands/RemindCommand.cs
Normal file
|
@ -0,0 +1,23 @@
|
|||
using Boyfriend.Data;
|
||||
|
||||
namespace Boyfriend.Commands;
|
||||
|
||||
public sealed class RemindCommand : ICommand {
|
||||
public string[] Aliases { get; } = { "remind", "reminder", "remindme", "напомни", "напомнить", "напоминание" };
|
||||
|
||||
public Task RunAsync(CommandProcessor cmd, string[] args, string[] cleanArgs) {
|
||||
// TODO: actually make this good
|
||||
var remindIn = CommandProcessor.GetTimeSpan(args, 0);
|
||||
var reminderText = cmd.GetRemaining(cleanArgs, 1, "ReminderText");
|
||||
if (reminderText is not null)
|
||||
GuildData.Get(cmd.Context.Guild).MemberData[cmd.Context.User.Id].Reminders.Add(new Reminder {
|
||||
RemindAt = DateTimeOffset.Now.Add(remindIn),
|
||||
ReminderText = reminderText,
|
||||
ReminderChannel = cmd.Context.Channel.Id
|
||||
});
|
||||
|
||||
cmd.ConfigWriteScheduled = true;
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
173
Commands/SettingsCommand.cs
Normal file
173
Commands/SettingsCommand.cs
Normal file
|
@ -0,0 +1,173 @@
|
|||
using Boyfriend.Data;
|
||||
using Discord;
|
||||
|
||||
namespace Boyfriend.Commands;
|
||||
|
||||
public sealed class SettingsCommand : ICommand {
|
||||
public string[] Aliases { get; } = { "settings", "config", "настройки", "конфиг" };
|
||||
|
||||
public Task RunAsync(CommandProcessor cmd, string[] args, string[] cleanArgs) {
|
||||
if (!cmd.HasPermission(GuildPermission.ManageGuild)) return Task.CompletedTask;
|
||||
|
||||
var guild = cmd.Context.Guild;
|
||||
var data = GuildData.Get(guild);
|
||||
var config = data.Preferences;
|
||||
|
||||
if (args.Length is 0) {
|
||||
var currentSettings = Boyfriend.StringBuilder.AppendLine(Messages.CurrentSettings);
|
||||
|
||||
foreach (var setting in GuildData.DefaultPreferences) {
|
||||
var format = "{0}";
|
||||
var currentValue = config[setting.Key] is "default"
|
||||
? Messages.DefaultWelcomeMessage
|
||||
: config[setting.Key];
|
||||
|
||||
if (setting.Key.EndsWith("Channel")) {
|
||||
if (guild.GetTextChannel(ulong.Parse(currentValue)) is not null) format = "<#{0}>";
|
||||
else currentValue = Messages.ChannelNotSpecified;
|
||||
} else if (setting.Key.EndsWith("Role")) {
|
||||
if (guild.GetRole(ulong.Parse(currentValue)) is not null) format = "<@&{0}>";
|
||||
else currentValue = Messages.RoleNotSpecified;
|
||||
} else {
|
||||
if (!IsBool(currentValue)) format = Utils.Wrap("{0}")!;
|
||||
else currentValue = YesOrNo(currentValue is "true");
|
||||
}
|
||||
|
||||
currentSettings.Append($"{Utils.GetMessage($"Settings{setting.Key}")} (`{setting.Key}`): ")
|
||||
.AppendFormat(format, currentValue).AppendLine();
|
||||
}
|
||||
|
||||
cmd.Reply(currentSettings.ToString(), ReplyEmojis.SettingsList);
|
||||
currentSettings.Clear();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
var selectedSetting = args[0].ToLower();
|
||||
|
||||
var exists = false;
|
||||
foreach (var setting in GuildData.DefaultPreferences.Keys.Where(x => x.ToLower() == selectedSetting)) {
|
||||
selectedSetting = setting;
|
||||
exists = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!exists) {
|
||||
cmd.Reply(Messages.SettingDoesntExist, ReplyEmojis.Error);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
string? value;
|
||||
|
||||
if (args.Length >= 2) {
|
||||
value = cmd.GetRemaining(args, 1, "Setting");
|
||||
if (value is null) return Task.CompletedTask;
|
||||
if (selectedSetting is "EventStartedReceivers") {
|
||||
value = value.Replace(" ", "").ToLower();
|
||||
if (value.StartsWith(",") || value.Count(x => x is ',') > 1 ||
|
||||
(!value.Contains("interested") && !value.Contains("users") && !value.Contains("role"))) {
|
||||
cmd.Reply(Messages.InvalidSettingValue, ReplyEmojis.Error);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
} else { value = "reset"; }
|
||||
|
||||
if (IsBool(GuildData.DefaultPreferences[selectedSetting]) && !IsBool(value)) {
|
||||
value = value switch {
|
||||
"y" or "yes" or "д" or "да" => "true",
|
||||
"n" or "no" or "н" or "нет" => "false",
|
||||
_ => value
|
||||
};
|
||||
if (!IsBool(value)) {
|
||||
cmd.Reply(Messages.InvalidSettingValue, ReplyEmojis.Error);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
||||
var localizedSelectedSetting = Utils.GetMessage($"Settings{selectedSetting}");
|
||||
|
||||
var mention = Utils.ParseMention(value);
|
||||
if (mention is not 0 && selectedSetting is not "WelcomeMessage") value = mention.ToString();
|
||||
|
||||
var formatting = Utils.Wrap("{0}")!;
|
||||
if (selectedSetting is not "WelcomeMessage") {
|
||||
if (selectedSetting.EndsWith("Channel")) formatting = "<#{0}>";
|
||||
if (selectedSetting.EndsWith("Role")) formatting = "<@&{0}>";
|
||||
}
|
||||
|
||||
var formattedValue = selectedSetting switch {
|
||||
"WelcomeMessage" => Utils.Wrap(Messages.DefaultWelcomeMessage),
|
||||
"EventStartedReceivers" => Utils.Wrap(GuildData.DefaultPreferences[selectedSetting])!,
|
||||
_ => value is "reset" or "default" ? Messages.SettingNotDefined
|
||||
: IsBool(value) ? YesOrNo(value is "true")
|
||||
: string.Format(formatting, value)
|
||||
};
|
||||
|
||||
if (value is "reset" or "default") {
|
||||
config[selectedSetting] = GuildData.DefaultPreferences[selectedSetting];
|
||||
} else {
|
||||
if (value == config[selectedSetting]) {
|
||||
cmd.Reply(string.Format(Messages.SettingsNothingChanged, localizedSelectedSetting, formattedValue),
|
||||
ReplyEmojis.Error);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
if (selectedSetting is "Lang" && !Utils.CultureInfoCache.ContainsKey(value)) {
|
||||
var langNotSupported = Boyfriend.StringBuilder.Append($"{Messages.LanguageNotSupported} ");
|
||||
foreach (var lang in Utils.CultureInfoCache) langNotSupported.Append($"`{lang.Key}`, ");
|
||||
langNotSupported.Remove(langNotSupported.Length - 2, 2);
|
||||
cmd.Reply(langNotSupported.ToString(), ReplyEmojis.Error);
|
||||
langNotSupported.Clear();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
if (selectedSetting.EndsWith("Channel") && guild.GetTextChannel(mention) is null) {
|
||||
cmd.Reply(Messages.InvalidChannel, ReplyEmojis.Error);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
if (selectedSetting.EndsWith("Role") && guild.GetRole(mention) is null) {
|
||||
cmd.Reply(Messages.InvalidRole, ReplyEmojis.Error);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
if (selectedSetting.EndsWith("Offset") && !int.TryParse(value, out _)) {
|
||||
cmd.Reply(Messages.InvalidSettingValue, ReplyEmojis.Error);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
switch (selectedSetting) {
|
||||
case "MuteRole":
|
||||
data.MuteRole = guild.GetRole(mention);
|
||||
break;
|
||||
case "PublicFeedbackChannel":
|
||||
data.PublicFeedbackChannel = guild.GetTextChannel(mention);
|
||||
break;
|
||||
case "PrivateFeedbackChannel":
|
||||
data.PrivateFeedbackChannel = guild.GetTextChannel(mention);
|
||||
break;
|
||||
}
|
||||
|
||||
config[selectedSetting] = value;
|
||||
}
|
||||
|
||||
if (selectedSetting is "Lang") {
|
||||
Utils.SetCurrentLanguage(guild);
|
||||
localizedSelectedSetting = Utils.GetMessage($"Settings{selectedSetting}");
|
||||
}
|
||||
|
||||
cmd.ConfigWriteScheduled = true;
|
||||
|
||||
var replyFormat = string.Format(Messages.FeedbackSettingsUpdated, localizedSelectedSetting, formattedValue);
|
||||
cmd.Reply(replyFormat, ReplyEmojis.SettingsSet);
|
||||
cmd.Audit(replyFormat, false);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private static string YesOrNo(bool isYes) {
|
||||
return isYes ? Messages.Yes : Messages.No;
|
||||
}
|
||||
|
||||
private static bool IsBool(string value) {
|
||||
return value is "true" or "false";
|
||||
}
|
||||
}
|
25
Commands/UnbanCommand.cs
Normal file
25
Commands/UnbanCommand.cs
Normal file
|
@ -0,0 +1,25 @@
|
|||
using Discord;
|
||||
|
||||
namespace Boyfriend.Commands;
|
||||
|
||||
public sealed class UnbanCommand : ICommand {
|
||||
public string[] Aliases { get; } = { "unban", "разбан" };
|
||||
|
||||
public async Task RunAsync(CommandProcessor cmd, string[] args, string[] cleanArgs) {
|
||||
if (!cmd.HasPermission(GuildPermission.BanMembers)) return;
|
||||
|
||||
var id = cmd.GetBan(args, 0);
|
||||
if (id is null) return;
|
||||
var reason = cmd.GetRemaining(args, 1, "UnbanReason");
|
||||
if (reason is not null) await UnbanUserAsync(cmd, id.Value, reason);
|
||||
}
|
||||
|
||||
private static async Task UnbanUserAsync(CommandProcessor cmd, ulong id, string reason) {
|
||||
var requestOptions = Utils.GetRequestOptions($"({cmd.Context.User}) {reason}");
|
||||
await cmd.Context.Guild.RemoveBanAsync(id, requestOptions);
|
||||
|
||||
var feedback = string.Format(Messages.FeedbackUserUnbanned, $"<@{id.ToString()}>", Utils.Wrap(reason));
|
||||
cmd.Reply(feedback);
|
||||
cmd.Audit(feedback);
|
||||
}
|
||||
}
|
36
Commands/UnmuteCommand.cs
Normal file
36
Commands/UnmuteCommand.cs
Normal file
|
@ -0,0 +1,36 @@
|
|||
using Boyfriend.Data;
|
||||
using Discord;
|
||||
using Discord.WebSocket;
|
||||
|
||||
namespace Boyfriend.Commands;
|
||||
|
||||
public sealed class UnmuteCommand : ICommand {
|
||||
public string[] Aliases { get; } = { "unmute", "размут" };
|
||||
|
||||
public async Task RunAsync(CommandProcessor cmd, string[] args, string[] cleanArgs) {
|
||||
if (!cmd.HasPermission(GuildPermission.ModerateMembers)) return;
|
||||
|
||||
var toUnmute = cmd.GetMember(args, 0);
|
||||
if (toUnmute is null) return;
|
||||
var reason = cmd.GetRemaining(args, 1, "UnmuteReason");
|
||||
if (reason is not null && cmd.CanInteractWith(toUnmute, "Unmute"))
|
||||
await UnmuteMemberAsync(cmd, toUnmute, reason);
|
||||
}
|
||||
|
||||
private static async Task UnmuteMemberAsync(CommandProcessor cmd, SocketGuildUser toUnmute,
|
||||
string reason) {
|
||||
var isMuted = await Utils.UnmuteMemberAsync(GuildData.Get(cmd.Context.Guild), cmd.Context.User.ToString(),
|
||||
toUnmute, reason);
|
||||
|
||||
if (!isMuted) {
|
||||
cmd.Reply(Messages.MemberNotMuted, ReplyEmojis.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
cmd.ConfigWriteScheduled = true;
|
||||
|
||||
var feedback = string.Format(Messages.FeedbackMemberUnmuted, toUnmute.Mention, Utils.Wrap(reason));
|
||||
cmd.Reply(feedback, ReplyEmojis.Unmuted);
|
||||
cmd.Audit(feedback);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue