forked from TeamInklings/Octobot
Keep reply emojis as consts in a separate class (#8)
This commit is contained in:
parent
1258496697
commit
2596b48bde
9 changed files with 65 additions and 52 deletions
|
@ -1,4 +1,4 @@
|
|||
using Discord;
|
||||
using Discord;
|
||||
using Discord.WebSocket;
|
||||
|
||||
namespace Boyfriend.Commands;
|
||||
|
@ -29,7 +29,7 @@ public sealed class BanCommand : ICommand {
|
|||
|
||||
var feedback = string.Format(Messages.FeedbackUserBanned, toBan.Mention,
|
||||
Utils.GetHumanizedTimeOffset(duration), Utils.Wrap(reason));
|
||||
cmd.Reply(feedback, ":hammer: ");
|
||||
cmd.Reply(feedback, ReplyEmojis.Banned);
|
||||
cmd.Audit(feedback);
|
||||
|
||||
if (duration.TotalSeconds > 0)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using Humanizer;
|
||||
using Humanizer;
|
||||
|
||||
namespace Boyfriend.Commands;
|
||||
|
||||
|
@ -12,7 +12,7 @@ public sealed class HelpCommand : ICommand {
|
|||
foreach (var command in CommandProcessor.Commands)
|
||||
toSend.Append(
|
||||
$"\n`{prefix}{command.Aliases[0]}`: {Utils.GetMessage($"CommandDescription{command.Aliases[0].Titleize()}")}");
|
||||
cmd.Reply(toSend.ToString(), ":page_facing_up: ");
|
||||
cmd.Reply(toSend.ToString(), ReplyEmojis.Help);
|
||||
toSend.Clear();
|
||||
|
||||
return Task.CompletedTask;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using Discord;
|
||||
using Discord;
|
||||
using Discord.WebSocket;
|
||||
|
||||
namespace Boyfriend.Commands;
|
||||
|
@ -24,7 +24,7 @@ public sealed class KickCommand : ICommand {
|
|||
|
||||
await toKick.KickAsync(guildKickMessage);
|
||||
var format = string.Format(Messages.FeedbackMemberKicked, toKick.Mention, Utils.Wrap(reason));
|
||||
cmd.Reply(format, ":police_car: ");
|
||||
cmd.Reply(format, ReplyEmojis.Kicked);
|
||||
cmd.Audit(format);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using Discord;
|
||||
using Discord;
|
||||
using Discord.Net;
|
||||
using Discord.WebSocket;
|
||||
|
||||
|
@ -20,7 +20,7 @@ public sealed class MuteCommand : ICommand {
|
|||
|| (toMute.TimedOutUntil is not null
|
||||
&& toMute.TimedOutUntil.Value.ToUnixTimeSeconds()
|
||||
> DateTimeOffset.Now.ToUnixTimeSeconds())) {
|
||||
cmd.Reply(Messages.MemberAlreadyMuted, ":x: ");
|
||||
cmd.Reply(Messages.MemberAlreadyMuted, ReplyEmojis.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ public sealed class MuteCommand : ICommand {
|
|||
foreach (var roleId in mutedRemovedRoles) await toMute.AddRoleAsync(roleId);
|
||||
rolesRemoved.Remove(toMute.Id);
|
||||
cmd.ConfigWriteScheduled = true;
|
||||
cmd.Reply(Messages.RolesReturned, ":warning: ");
|
||||
cmd.Reply(Messages.RolesReturned, ReplyEmojis.Warning);
|
||||
}
|
||||
|
||||
if (cmd.HasPermission(GuildPermission.ModerateMembers) && cmd.CanInteractWith(toMute, "Mute"))
|
||||
|
@ -55,7 +55,7 @@ public sealed class MuteCommand : ICommand {
|
|||
rolesRemoved.Add(userRole.Id);
|
||||
} catch (HttpException e) {
|
||||
cmd.Reply(string.Format(Messages.RoleRemovalFailed, $"<@&{userRole}>", Utils.Wrap(e.Reason)),
|
||||
":warning: ");
|
||||
ReplyEmojis.Warning);
|
||||
}
|
||||
|
||||
Boyfriend.GetRemovedRoles(guild.Id).Add(toMute.Id, rolesRemoved.AsReadOnly());
|
||||
|
@ -68,12 +68,12 @@ public sealed class MuteCommand : ICommand {
|
|||
await Task.FromResult(Utils.DelayedUnmuteAsync(cmd, toMute, Messages.PunishmentExpired, duration));
|
||||
} else {
|
||||
if (!hasDuration || duration.TotalDays > 28) {
|
||||
cmd.Reply(Messages.DurationRequiredForTimeOuts, ":x: ");
|
||||
cmd.Reply(Messages.DurationRequiredForTimeOuts, ReplyEmojis.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (toMute.IsBot) {
|
||||
cmd.Reply(Messages.CannotTimeOutBot, ":x: ");
|
||||
cmd.Reply(Messages.CannotTimeOutBot, ReplyEmojis.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ public sealed class MuteCommand : ICommand {
|
|||
var feedback = string.Format(Messages.FeedbackMemberMuted, toMute.Mention,
|
||||
Utils.GetHumanizedTimeOffset(duration),
|
||||
Utils.Wrap(reason));
|
||||
cmd.Reply(feedback, ":mute: ");
|
||||
cmd.Reply(feedback, ReplyEmojis.Muted);
|
||||
cmd.Audit(feedback);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Boyfriend.Commands;
|
||||
namespace Boyfriend.Commands;
|
||||
|
||||
public sealed class PingCommand : ICommand {
|
||||
public string[] Aliases { get; } = { "ping", "latency", "pong", "пинг", "задержка", "понг" };
|
||||
|
@ -10,7 +10,7 @@ public sealed class PingCommand : ICommand {
|
|||
.Append(Math.Abs(DateTimeOffset.Now.Subtract(cmd.Context.Message.Timestamp).TotalMilliseconds))
|
||||
.Append(Messages.Milliseconds);
|
||||
|
||||
cmd.Reply(builder.ToString(), ":signal_strength: ");
|
||||
cmd.Reply(builder.ToString(), ReplyEmojis.Ping);
|
||||
builder.Clear();
|
||||
|
||||
return Task.CompletedTask;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using Discord;
|
||||
using Discord;
|
||||
|
||||
namespace Boyfriend.Commands;
|
||||
|
||||
|
@ -33,7 +33,7 @@ public sealed class SettingsCommand : ICommand {
|
|||
.AppendFormat(format, currentValue).AppendLine();
|
||||
}
|
||||
|
||||
cmd.Reply(currentSettings.ToString(), ":gear: ");
|
||||
cmd.Reply(currentSettings.ToString(), ReplyEmojis.SettingsList);
|
||||
currentSettings.Clear();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public sealed class SettingsCommand : ICommand {
|
|||
}
|
||||
|
||||
if (!exists) {
|
||||
cmd.Reply(Messages.SettingDoesntExist, ":x: ");
|
||||
cmd.Reply(Messages.SettingDoesntExist, ReplyEmojis.Error);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ public sealed class SettingsCommand : ICommand {
|
|||
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, ":x: ");
|
||||
cmd.Reply(Messages.InvalidSettingValue, ReplyEmojis.Error);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ public sealed class SettingsCommand : ICommand {
|
|||
_ => value
|
||||
};
|
||||
if (!IsBool(value)) {
|
||||
cmd.Reply(Messages.InvalidSettingValue, ":x: ");
|
||||
cmd.Reply(Messages.InvalidSettingValue, ReplyEmojis.Error);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
@ -106,22 +106,22 @@ public sealed class SettingsCommand : ICommand {
|
|||
} else {
|
||||
if (value == config[selectedSetting]) {
|
||||
cmd.Reply(string.Format(Messages.SettingsNothingChanged, localizedSelectedSetting, formattedValue),
|
||||
":x: ");
|
||||
ReplyEmojis.Error);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
if (selectedSetting is "Lang" && !Utils.CultureInfoCache.ContainsKey(value)) {
|
||||
cmd.Reply(Messages.LanguageNotSupported, ":x: ");
|
||||
cmd.Reply(Messages.LanguageNotSupported, ReplyEmojis.Error);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
if (selectedSetting.EndsWith("Channel") && guild.GetTextChannel(mention) is null) {
|
||||
cmd.Reply(Messages.InvalidChannel, ":x: ");
|
||||
cmd.Reply(Messages.InvalidChannel, ReplyEmojis.Error);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
if (selectedSetting.EndsWith("Role") && guild.GetRole(mention) is null) {
|
||||
cmd.Reply(Messages.InvalidRole, ":x: ");
|
||||
cmd.Reply(Messages.InvalidRole, ReplyEmojis.Error);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
@ -138,7 +138,7 @@ public sealed class SettingsCommand : ICommand {
|
|||
cmd.ConfigWriteScheduled = true;
|
||||
|
||||
var replyFormat = string.Format(Messages.FeedbackSettingsUpdated, localizedSelectedSetting, formattedValue);
|
||||
cmd.Reply(replyFormat, ":control_knobs: ");
|
||||
cmd.Reply(replyFormat, ReplyEmojis.SettingsSet);
|
||||
cmd.Audit(replyFormat, false);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using Discord;
|
||||
using Discord;
|
||||
using Discord.WebSocket;
|
||||
|
||||
namespace Boyfriend.Commands;
|
||||
|
@ -34,7 +34,7 @@ public sealed class UnmuteCommand : ICommand {
|
|||
} else {
|
||||
if (toUnmute.TimedOutUntil is null || toUnmute.TimedOutUntil.Value.ToUnixTimeSeconds() <
|
||||
DateTimeOffset.Now.ToUnixTimeSeconds()) {
|
||||
cmd.Reply(Messages.MemberNotMuted, ":x: ");
|
||||
cmd.Reply(Messages.MemberNotMuted, ReplyEmojis.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ public sealed class UnmuteCommand : ICommand {
|
|||
}
|
||||
|
||||
var feedback = string.Format(Messages.FeedbackMemberUnmuted, toUnmute.Mention, Utils.Wrap(reason));
|
||||
cmd.Reply(feedback, ":loud_sound: ");
|
||||
cmd.Reply(feedback, ReplyEmojis.Unmuted);
|
||||
cmd.Audit(feedback);
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue