Exemple #1
0
        public async Task Execute(DiscordMessage message, Command command)
        {
            await message.IsDirectMessageSupported();

            if (!command.HasArgs)
            {
                return;
            }
            if (command.Args.Count != 2)
            {
                return;
            }

            var userMention = command.Args[0];
            var roleMention = command.Args[1];
            var userId      = DiscordHelpers.ConvertMentionToUserId(userMention);
            var roleId      = DiscordHelpers.ConvertMentionToUserId(roleMention);
            var result      = await AssignGuildMemberToRole(message, userId, roleId);

            if (result)
            {
                await message.RespondAsync($"{message.Author.Mention} has added {userMention} to the {roleMention} role.");

                return;
            }

            await message.RespondAsync($"{message.Author.Mention} failed to add {userMention} to the {roleMention} role.");
        }
Exemple #2
0
        public async Task Execute(DiscordMessage message, Command command)
        {
            //await message.IsDirectMessageSupported();

            if (command.HasArgs && command.Args.Count == 1)
            {
                if (!message.Author.Id.IsModeratorOrHigher(_config))
                {
                    await message.RespondAsync($"{message.Author.Mention} is not a moderator or higher thus you may not see other's subscription settings.");

                    return;
                }

                var mention = command.Args[0];
                var userId  = DiscordHelpers.ConvertMentionToUserId(mention);
                if (userId <= 0)
                {
                    await message.RespondAsync($"{message.Author.Mention} failed to retrieve user with mention tag {mention}.");

                    return;
                }

                await SendUserSubscriptionSettings(message.Author, userId);

                return;
            }

            await SendUserSubscriptionSettings(message.Author, message.Author.Id);
        }
Exemple #3
0
        public async Task Execute(DiscordMessage message, Command command)
        {
            if (!command.HasArgs)
            {
                return;
            }
            if (command.Args.Count != 3)
            {
                return;
            }

            var mention = command.Args[0];
            var date    = command.Args[1];
            var days    = command.Args[2];

            var userId = DiscordHelpers.ConvertMentionToUserId(mention);

            if (userId == 0)
            {
                await message.RespondAsync($"{message.Author.Mention}, I failed to lookup discord user {mention}.");

                return;
            }

            if (!DateTime.TryParse(date, out DateTime dateDonated))
            {
                await message.RespondAsync($"{message.Author.Mention} {date} is not a valid value for date.");

                return;
            }

            if (!int.TryParse(days, out int daysAvailable))
            {
                await message.RespondAsync($"{message.Author.Mention} {days} is not a valid value for days.");

                return;
            }

            if (!_config.Supporters.ContainsKey(userId))
            {
                _config.Supporters.Add(userId, new Data.Models.Donator {
                    UserId = userId, Email = mention, DateDonated = dateDonated, DaysAvailable = daysAvailable
                });
            }
            else
            {
                var donator = _config.Supporters[userId];
                donator.DateDonated   = dateDonated;
                donator.DaysAvailable = daysAvailable;
            }

            _config.Save();

            await message.RespondAsync($"{message.Author.Mention} {userId} has been added to the supporters list with {daysAvailable} days available.");
        }
Exemple #4
0
        public async Task Execute(DiscordMessage message, Command command)
        {
            if (command.Args.Count != 1)
            {
                return;
            }

            var mention = command.Args[0];
            var userId  = DiscordHelpers.ConvertMentionToUserId(mention);

            if (userId == 0)
            {
                await message.RespondAsync($"{message.Author.Mention}, failed to find user {mention}.");

                return;
            }

            var member = await _client.GetMemberFromUserId(userId);

            if (member == null)
            {
                _logger.Error($"Failed to find member with user id {userId}.");
                return;
            }

            if (!await _client.AssignRole(member, TeamEliteRole))
            {
                await message.RespondAsync($"{message.Author.Mention} failed to assign {mention} the {TeamEliteRole} role. Please check my permissions and that the role exists.");
            }

            if (!await _client.AssignRole(member, EastLA))
            {
                await message.RespondAsync($"{message.Author.Mention} failed to assign {mention} the {EastLA} role. Please check my permissions and that the role exists.");
            }

            await message.RespondAsync($"{message.Author.Mention} assigned {mention} the {TeamEliteRole} and {EastLA} roles.");
        }