finished .streamrole

This commit is contained in:
Master Kwoth 2017-07-14 17:09:06 +02:00
parent b8573f11b5
commit 17719dd8e2
3 changed files with 34 additions and 25 deletions

View File

@ -2,14 +2,12 @@
using Discord.Commands; using Discord.Commands;
using NadekoBot.Attributes; using NadekoBot.Attributes;
using NadekoBot.Services.Utility; using NadekoBot.Services.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace NadekoBot.Modules.Utility.Commands namespace NadekoBot.Modules.Utility
{ {
public partial class Utility
{
public class StreamRoleCommands : NadekoSubmodule public class StreamRoleCommands : NadekoSubmodule
{ {
private readonly StreamRoleService service; private readonly StreamRoleService service;
@ -20,6 +18,8 @@ namespace NadekoBot.Modules.Utility.Commands
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
[RequireBotPermission(GuildPermission.ManageRoles)]
[RequireUserPermission(GuildPermission.ManageRoles)]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task StreamRole(IRole fromRole, IRole addRole) public async Task StreamRole(IRole fromRole, IRole addRole)
{ {
@ -29,6 +29,8 @@ namespace NadekoBot.Modules.Utility.Commands
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
[RequireBotPermission(GuildPermission.ManageRoles)]
[RequireUserPermission(GuildPermission.ManageRoles)]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task StreamRole() public async Task StreamRole()
{ {
@ -36,4 +38,5 @@ namespace NadekoBot.Modules.Utility.Commands
await ReplyConfirmLocalized("stream_role_disabled").ConfigureAwait(false); await ReplyConfirmLocalized("stream_role_disabled").ConfigureAwait(false);
} }
} }
}
} }

View File

@ -167,6 +167,7 @@ namespace NadekoBot
var patreonRewardsService = new PatreonRewardsService(Credentials, Db, Currency, Client); var patreonRewardsService = new PatreonRewardsService(Credentials, Db, Currency, Client);
var verboseErrorsService = new VerboseErrorsService(AllGuildConfigs, Db, CommandHandler, helpService); var verboseErrorsService = new VerboseErrorsService(AllGuildConfigs, Db, CommandHandler, helpService);
var pruneService = new PruneService(); var pruneService = new PruneService();
var streamRoleService = new StreamRoleService(Client, Db, AllGuildConfigs);
#endregion #endregion
#region permissions #region permissions
@ -236,6 +237,7 @@ namespace NadekoBot
.Add(verboseErrorsService) .Add(verboseErrorsService)
.Add(patreonRewardsService) .Add(patreonRewardsService)
.Add(pruneService) .Add(pruneService)
.Add(streamRoleService)
.Add<SearchesService>(searchesService) .Add<SearchesService>(searchesService)
.Add(streamNotificationService) .Add(streamNotificationService)
.Add(animeSearchService) .Add(animeSearchService)

View File

@ -50,7 +50,11 @@ namespace NadekoBot.Services.Utility
{ {
//get needed roles //get needed roles
fromRole = after.Guild.GetRole(setting.FromRoleId); fromRole = after.Guild.GetRole(setting.FromRoleId);
if (fromRole == null)
throw new InvalidOperationException();
addRole = after.Guild.GetRole(setting.AddRoleId); addRole = after.Guild.GetRole(setting.AddRoleId);
if (addRole == null)
throw new InvalidOperationException();
} }
catch (Exception ex) catch (Exception ex)
{ {