IW4M-Admin/SharedLibraryCore/Commands/PrivateMessageAdminsCommand.cs

39 lines
1.4 KiB
C#
Raw Normal View History

2022-01-26 11:32:16 -05:00
using System.Linq;
using System.Threading.Tasks;
2022-01-26 11:32:16 -05:00
using Data.Models.Client;
using SharedLibraryCore.Configuration;
using SharedLibraryCore.Interfaces;
using static SharedLibraryCore.Server;
namespace SharedLibraryCore.Commands
{
public class PrivateMessageAdminsCommand : Command
{
2022-01-26 11:32:16 -05:00
public PrivateMessageAdminsCommand(CommandConfiguration config, ITranslationLookup lookup) : base(config,
lookup)
{
Name = "privatemessageadmin";
Description = lookup["COMMANDS_PMADMINS_DESC"];
Alias = "pma";
Permission = EFClient.Permission.Moderator;
SupportedGames = new[] { Game.IW4, Game.IW5 };
}
public override Task ExecuteAsync(GameEvent E)
{
2022-01-26 11:32:16 -05:00
var isGameSupported = _config.Commands[nameof(PrivateMessageAdminsCommand)].SupportedGames.Length > 0 &&
_config.Commands[nameof(PrivateMessageAdminsCommand)].SupportedGames
.Contains(E.Owner.GameName);
if (!isGameSupported)
{
2022-01-26 11:32:16 -05:00
E.Origin.Tell(_translationLookup["COMMANDS_GAME_NOT_SUPPORTED"]
.FormatExt(nameof(PrivateMessageAdminsCommand)));
return Task.CompletedTask;
}
E.Owner.ToAdmins(E.Data);
return Task.CompletedTask;
}
}
2022-01-26 11:32:16 -05:00
}