예제 #1
0
        /// <inheritdoc/>
        protected override async Task Execute(IMessage message, string parameter)
        {
            var guild = SSIP.Guild;
            var match = Regex.Match(parameter, @"^<@&(\d+)>\s(\S+)\s*$");

            try
            {
                if (match.Success)
                {
                    Permissions.AddRolePermission(guild.GetRole(ulong.Parse(match.Result("$1"))), match.Result("$2"));
                }
                else
                {
                    match = Regex.Match(parameter, @"^<@!?(\d+)>\s(\S+)\s*$");
                    Permissions.AddUserPermission(guild.GetUser(ulong.Parse(match.Result("$1"))), match.Result("$2"));
                }

                await message.Channel.SendMessageAsync($"{message.Author.Mention} разрешение добавлено.");
            }
            catch (PermissionAlreadyExistsException)
            {
                await message.Channel.SendMessageAsync($"{message.Author.Mention} разрешение уже существует!");
            }
            catch (ArgumentException)
            {
                await message.Channel.SendMessageAsync($"{message.Author.Mention} неправильные аргументы!");
            }
        }
 private async Task OnGuildAvailable(SocketGuild arg)
 {
     if (this.Config.GuildId == 0)
     {
         this.Config.GuildId = arg.Id;
         Permissions.AddUserPermission(arg.Owner, "*");
     }
     else if (this.Config.GuildId != arg.Id)
     {
         await arg.LeaveAsync();
     }
 }