NadekoBot/NadekoBot.Modules.Utility/StreamRoleCommands.cs

94 lines
4.6 KiB
C#
Raw Normal View History

2017-07-14 03:00:30 +00:00
using Discord;
using Discord.Commands;
using System.Threading.Tasks;
2017-07-17 19:42:36 +00:00
using NadekoBot.Common.Attributes;
using NadekoBot.Modules.Utility.Services;
2017-07-19 08:38:14 +00:00
using NadekoBot.Common.TypeReaders;
using NadekoBot.Modules.Utility.Common;
using NadekoBot.Common;
2017-07-14 03:00:30 +00:00
2017-07-14 15:09:06 +00:00
namespace NadekoBot.Modules.Utility
2017-07-14 03:00:30 +00:00
{
2017-07-14 15:09:06 +00:00
public partial class Utility
2017-07-14 03:00:30 +00:00
{
2017-07-15 16:34:34 +00:00
public class StreamRoleCommands : NadekoSubmodule<StreamRoleService>
2017-07-14 03:00:30 +00:00
{
2017-07-14 15:09:06 +00:00
[NadekoCommand, Usage, Description, Aliases]
[RequireBotPermission(GuildPermission.ManageRoles)]
[RequireUserPermission(GuildPermission.ManageRoles)]
[RequireContext(ContextType.Guild)]
public async Task StreamRole(IRole fromRole, IRole addRole)
{
2017-07-19 08:38:14 +00:00
await this._service.SetStreamRole(fromRole, addRole).ConfigureAwait(false);
2017-07-14 03:00:30 +00:00
2017-07-14 15:09:06 +00:00
await ReplyConfirmLocalized("stream_role_enabled", Format.Bold(fromRole.ToString()), Format.Bold(addRole.ToString())).ConfigureAwait(false);
}
[NadekoCommand, Usage, Description, Aliases]
[RequireBotPermission(GuildPermission.ManageRoles)]
[RequireUserPermission(GuildPermission.ManageRoles)]
[RequireContext(ContextType.Guild)]
public async Task StreamRole()
{
await this._service.StopStreamRole(Context.Guild).ConfigureAwait(false);
2017-07-14 15:09:06 +00:00
await ReplyConfirmLocalized("stream_role_disabled").ConfigureAwait(false);
}
2017-07-19 08:38:14 +00:00
[NadekoCommand, Usage, Description, Aliases]
[RequireBotPermission(GuildPermission.ManageRoles)]
[RequireUserPermission(GuildPermission.ManageRoles)]
[RequireContext(ContextType.Guild)]
public async Task StreamRoleKeyword([Remainder]string keyword = null)
{
string kw = await this._service.SetKeyword(Context.Guild, keyword).ConfigureAwait(false);
2017-07-19 08:38:14 +00:00
if(string.IsNullOrWhiteSpace(keyword))
await ReplyConfirmLocalized("stream_role_kw_reset").ConfigureAwait(false);
else
await ReplyConfirmLocalized("stream_role_kw_set", Format.Bold(kw)).ConfigureAwait(false);
}
[NadekoCommand, Usage, Description, Aliases]
[RequireBotPermission(GuildPermission.ManageRoles)]
[RequireUserPermission(GuildPermission.ManageRoles)]
[RequireContext(ContextType.Guild)]
public async Task StreamRoleBlacklist(AddRemove action, [Remainder] IGuildUser user)
{
var success = await this._service.ApplyListAction(StreamRoleListType.Blacklist, Context.Guild, action, user.Id, user.ToString())
2017-07-19 08:38:14 +00:00
.ConfigureAwait(false);
if(action == AddRemove.Add)
if(success)
await ReplyConfirmLocalized("stream_role_bl_add", Format.Bold(user.ToString())).ConfigureAwait(false);
else
await ReplyConfirmLocalized("stream_role_bl_add_fail", Format.Bold(user.ToString())).ConfigureAwait(false);
else
if (success)
await ReplyConfirmLocalized("stream_role_bl_rem", Format.Bold(user.ToString())).ConfigureAwait(false);
else
await ReplyErrorLocalized("stream_role_bl_rem_fail", Format.Bold(user.ToString())).ConfigureAwait(false);
}
[NadekoCommand, Usage, Description, Aliases]
[RequireBotPermission(GuildPermission.ManageRoles)]
[RequireUserPermission(GuildPermission.ManageRoles)]
[RequireContext(ContextType.Guild)]
public async Task StreamRoleWhitelist(AddRemove action, [Remainder] IGuildUser user)
{
var success = await this._service.ApplyListAction(StreamRoleListType.Whitelist, Context.Guild, action, user.Id, user.ToString())
2017-07-19 08:38:14 +00:00
.ConfigureAwait(false);
if (action == AddRemove.Add)
if(success)
await ReplyConfirmLocalized("stream_role_wl_add", Format.Bold(user.ToString())).ConfigureAwait(false);
else
await ReplyConfirmLocalized("stream_role_wl_add_fail", Format.Bold(user.ToString())).ConfigureAwait(false);
else
if (success)
await ReplyConfirmLocalized("stream_role_wl_rem", Format.Bold(user.ToString())).ConfigureAwait(false);
else
await ReplyErrorLocalized("stream_role_wl_rem_fail", Format.Bold(user.ToString())).ConfigureAwait(false);
}
2017-07-14 03:00:30 +00:00
}
}
2017-07-14 15:09:06 +00:00
}