IW4M-Admin/Plugins/Mute/MuteManager.cs

22 lines
748 B
C#
Raw Normal View History

using SharedLibraryCore;
namespace Mute;
public class MuteManager
{
public async Task<bool> Mute(GameEvent gameEvent)
{
if (await Plugin.DataManager.ReadPersistentData(gameEvent.Target) == MuteState.Muted)
{
await gameEvent.Owner.ExecuteCommandAsync($"unmute {gameEvent.Target.ClientNumber}");
await Plugin.DataManager.WritePersistentData(gameEvent.Target,
gameEvent.Target.IsIngame ? MuteState.Unmuted : MuteState.Unmuting);
return false;
}
await gameEvent.Owner.ExecuteCommandAsync($"muteClient {gameEvent.Target.ClientNumber}");
await Plugin.DataManager.WritePersistentData(gameEvent.Target, MuteState.Muted);
return true;
}
}