Example #1
0
        public async Task KickCommand([RequireHierarchy] IUser user, string reason = "")
        {
            // Create reason
            string _reason;

            if (reason == "")
            {
                _reason = $"{Context.User.Username}#{Context.User.Discriminator} kicked this user. No reason provided.";
            }
            else
            {
                _reason = $"{Context.User.Username}#{Context.User.Discriminator} kicked this user for: {reason}";
            }

            await(user as IGuildUser).KickAsync(_reason);

            if (reason == "")
            {
                await Respond.SendResponse(Context, $"Kicked user **{user.Username}#{user.Discriminator}**.");
            }
            else
            {
                await Respond.SendResponse(Context, $"Kicked user **{user.Username}#{user.Discriminator}** for `{reason}`.");
            }
        }
Example #2
0
            public async Task ChangeStatusCommand(int status)
            {
                if (status < 1 || status > 4)
                {
                    await Respond.SendResponse(Context, "Status can only be between **1-4**!");

                    return;
                }

                BotConfigService.SetDefaultStatus(status);

                switch (status)
                {
                case 1:
                    await Context.Client.SetStatusAsync(UserStatus.Online);

                    break;

                case 2:
                    await Context.Client.SetStatusAsync(UserStatus.Idle);

                    break;

                case 3:
                    await Context.Client.SetStatusAsync(UserStatus.DoNotDisturb);

                    break;

                case 4:
                    await Context.Client.SetStatusAsync(UserStatus.Offline);

                    break;
                }
            }
Example #3
0
        public static async Task PardonUser(SocketCommandContext Context, ulong id)
        {
            bool _didPardon = false;

            // Do native unban
            var _bans = await Context.Guild.GetBansAsync();
            if (_bans.Any(s => s.User.Id == id))
            {
                await Context.Guild.RemoveBanAsync(_bans.First(s => s.User.Id == id).User);
                _didPardon = true;
            }

            // Pardon forceban, if one exists
            var _config = Database.GetRecord<GuildConfig>(s => s.ID == Context.Guild.Id);

            if (_config.Forcebans.Any(s => s == id))
            {
                _config.Forcebans.Remove(id);

                Database.UpsertRecord(_config);
                _didPardon = true;
            }

            if (_didPardon)
            {
                await Respond.SendResponse(Context, $"User with ID `{id}` has been pardoned.");
            }
            else
            {
                await Respond.SendResponse(Context, $"User with ID `{id}` has not been banned or forcebanned.");
            }
        }
Example #4
0
        public static async Task EditTag(SocketCommandContext Context, string tag, string newMessage)
        {
            var _tag = Database.GetRecord <Tag>(s => s.Stats.Alias == tag);

            if (_tag == null)
            {
                await Respond.SendResponse(Context, "That tag does not exist.");

                return;
            }

            if (_tag.CreatedBy != $"{Context.User.Username}#{Context.User.Discriminator}" ||
                !(Context.User as IGuildUser).GuildPermissions.Administrator)
            {
                await Respond.SendResponse(Context, "You do not have the required permissions to edit this tag.");

                return;
            }

            _tag.Message = newMessage;

            Database.UpsertRecord(_tag);

            await Respond.SendResponse(Context, "Tag changed successfully.");
        }
Example #5
0
        public async Task BanCommand([RequireHierarchy] IUser user, string reason = "")
        {
            // Create reason
            string _reason;

            if (reason == "")
            {
                _reason = $"{Context.User.Username}#{Context.User.Discriminator} banned this user. No reason provided.";
            }
            else
            {
                _reason = $"{Context.User.Username}#{Context.User.Discriminator} banned this user for: {reason}";
            }

            await Context.Guild.AddBanAsync(user, reason : _reason);

            if (reason == "")
            {
                await Respond.SendResponse(Context, $"Banned user **{user.Username}#{user.Discriminator}**.");
            }
            else
            {
                await Respond.SendResponse(Context, $"Banned user **{user.Username}#{user.Discriminator}** for reason: `{reason}`.");
            }
        }
Example #6
0
        public static async Task Play(SocketCommandContext Context, string song)
        {
            if ((Context.User as IVoiceState).VoiceChannel == null)
            {
                await Respond.SendResponse(Context, "You are not in a voice channel!");
                return;
            }

            var _client = Clients.FirstOrDefault(s => s.GuildId == Context.Guild.Id);

            if (_client == null)
            {
                var _new = new AudioClientWrapper(Context);

                await _new.AddToQueue(Context, song);

                Clients.Add(_new);
            }
            else
            {
                await _client.AddToQueue(Context, song);
            }

            await Context.Message.DeleteAsync();
        }
Example #7
0
        public static async Task DeleteTag(SocketCommandContext Context, string tag)
        {
            tag = tag.ToLower();

            var _tag = Database.GetRecord <Tag>(s => s.Stats.Alias == tag);

            if (_tag == null)
            {
                await Respond.SendResponse(Context, "That tag does not exist.");

                return;
            }

            if (_tag.CreatedBy != $"{Context.User.Username}#{Context.User.Discriminator}" ||
                !(Context.User as IGuildUser).GuildPermissions.Administrator)
            {
                await Respond.SendResponse(Context, "You do not have the required permissions to edit this tag.");

                return;
            }

            Database.DeleteRecord <Tag>(s => s.Stats.Alias == tag && s.Stats.GuildId == Context.Guild.Id);

            await Respond.SendResponse(Context, "Tag deleted successfully.");
        }
Example #8
0
        public static async Task Unmute(SocketCommandContext Context, ulong id)
        {
            var _role = await GetOrCreateMutedRoleAsync(Context.Guild);

            var _user = Context.Guild.GetUser(id);

            if (_user == null)
            {
                await Respond.SendResponse(Context, $"I could not find a user with the ID: `{id}`");

                return;
            }

            if (!_user.Roles.Any(s => s.Id == _role.Id))
            {
                await Respond.SendResponse(Context, $"{_user.Username}#{_user.Discriminator} is already unmuted!");

                return;
            }

            await _user.RemoveRoleAsync(_role);

            await Respond.SendResponse(Context, $"Unmuted {_user.Username}#{_user.Discriminator}.");

            RemoveMute(_user);
        }
Example #9
0
        public static async Task Magic8Service(SocketCommandContext Context)
        {
            var _answers = Get8BallAnswers();
            var _r       = new Random().Next(0, _answers.Length);

            await Respond.SendResponse(Context, _answers[_r]);
        }
Example #10
0
            public async Task RestardCommand()
            {
                await Respond.SendResponse(Context, ":thumbsup:");

                Process.Start(Assembly.GetExecutingAssembly().Location);

                Environment.Exit(1);
            }
Example #11
0
        public static async Task Mute(SocketCommandContext Context, IGuildUser user)
        {
            await user.AddRoleAsync(await GetOrCreateMutedRoleAsync(Context.Guild));

            await Respond.SendResponse(Context, $"Muted user **{user.Username}#{user.Discriminator}**.");

            AddMute(user);
        }
Example #12
0
        public static async Task Remove(SocketCommandContext Context, int index)
        {
            if (!Clients.Any(s => s.GuildId == Context.Guild.Id))
            {
                await Respond.SendResponse(Context, "No player is connected to this guild.");
                return;
            }

            await Clients.FirstOrDefault(s => s.GuildId == Context.Guild.Id).Remove(Context, index);
        }
Example #13
0
        public static async Task ForcebanUser(SocketCommandContext Context, ulong id)
        {
            var _config = Database.GetRecord<GuildConfig>(s => s.ID == Context.Guild.Id);

            _config.Forcebans.Add(id);

            Database.UpsertRecord(_config);

            await Respond.SendResponse(Context, $"User with ID `{id}` has been forcebanned from this guild.");
        }
Example #14
0
                public async Task ResetGuildConfigCommand()
                {
                    foreach (var guild in Context.Client.Guilds)
                    {
                        Database.DeleteRecord <GuildConfig>(s => s.ID == guild.Id);

                        Database.CreateDefaultGuildConfig(Context.Guild, out _);
                    }

                    await Respond.SendResponse(Context, "Restored all guild configurations to default.");
                }
Example #15
0
        public static async Task Skip(SocketCommandContext Context)
        {
            var _client = Clients.FirstOrDefault(s => s.GuildId == Context.Guild.Id);

            if (_client == null)
            {
                await Respond.SendResponse(Context, "No player is connected to this guild.");
                return;
            }

            _client.Skip();
        }
Example #16
0
        public async Task GameHoursCommand([Remainder] string game)
        {
            var _hours = LeaderboardService.GetGameHours(Context.Guild.Id, Context.User.Id, game);

            if (_hours == null)
            {
                await Respond.SendResponse(Context, $"You have no recorded hours for: `{game}`.");

                return;
            }

            await Respond.SendResponse(Context, $"You have `{Math.Round(_hours.Time.TotalHours, 2)}` hours on *{game}*.");
        }
Example #17
0
        public static async Task ClearCommandService(SocketCommandContext Context, int count, ulong userId)
        {
            if (count > 100)
            {
                await Respond.SendResponse(Context, $"Use a number less than 100.");

                return;
            }

            AddToTimedList(Context.Channel.Id);

            var _msgs = Context.Channel.GetCachedMessages(100).Where(s => s.Author.Id == userId);

            await(Context.Channel as ITextChannel).DeleteMessagesAsync(_msgs);
        }
Example #18
0
        public static async Task Mute(SocketCommandContext Context, IGuildUser user, string time)
        {
            await user.AddRoleAsync(await GetOrCreateMutedRoleAsync(Context.Guild))
            .ConfigureAwait(false);

            var _time = Parse.Time(time);

            if (_time.TotalDays == 0)
            {
                _time = TimeSpan.FromMinutes(30);
            }

            AddMute(user, _time);

            await Respond.SendResponse(Context, $"Muted user **{user.Username}#{user.Discriminator}** for {time}.");
        }
Example #19
0
        public static async Task Mute(SocketCommandContext Context, ulong id)
        {
            if (Context.Guild.GetUser(id) == null)
            {
                await Respond.SendResponse(Context, $"I could not find a user with the ID: `{id}`.");

                return;
            }

            await Context.Guild.GetUser(id).AddRoleAsync(await GetOrCreateMutedRoleAsync(Context.Guild)).
            ConfigureAwait(false);

            await Respond.SendResponse(Context, $"Muted user **{Context.Guild.GetUser(id).Username}#{Context.Guild.GetUser(id).Discriminator}**.");

            AddMute(Context.Guild.GetUser(id));
        }
Example #20
0
        public async Task LogCommand()
        {
            var _config = Database.GetRecord <GuildConfig>(s => s.ID == Context.Guild.Id);

            if (_config == null)
            {
                Database.CreateDefaultGuildConfig(Context.Guild, out _config);
            }

            _config.LogChannelID = Context.Channel.Id;
            _config.Log          = !_config.Log;

            Database.UpsertRecord(_config);

            await Respond.SendResponse(Context, $"Logging has been **{(_config.Log ? "Enabled" : "Disabled")}** for this channel.");
        }
Example #21
0
        public static async Task JoinAudio(SocketCommandContext Context)
        {
            // Already in voice channel
            if (Clients.Any(s => s.GuildId == Context.Guild.Id))
            {
                return;
            }

            // Not in a voice channel
            if ((Context.User as IVoiceState).VoiceChannel == null)
            {
                await Respond.SendResponse(Context, "You are not in a voice channel!");
                return;
            }

            Clients.Add(new AudioClientWrapper(Context));
        }
Example #22
0
        public static async Task Unmute(SocketCommandContext Context, IGuildUser user)
        {
            var _role = await GetOrCreateMutedRoleAsync(Context.Guild);

            if (!user.RoleIds.Contains(_role.Id))
            {
                await Respond.SendResponse(Context, $"{user.Username}#{user.Discriminator} is already unmuted!");

                return;
            }

            await user.RemoveRoleAsync(_role);

            await Respond.SendResponse(Context, $"Unmuted {user.Username}#{user.Discriminator}.");

            RemoveMute(user);
        }
Example #23
0
        public static async Task ChangeName(SocketCommandContext Context, string name)
        {
            await Respond.SendResponse(Context, $"I am about to change my name to **{name}**. Are you sure you want to continue? (yes/no)");

            var _answer = ConfirmationService.instance.AwaitSimpleReply(Context);

            if (_answer)
            {
                await Context.Client.CurrentUser.ModifyAsync(s => s.Username = name);

                await Respond.SendResponse(Context, $"Changed name to **{name}**.");
            }
            else
            {
                await Respond.SendResponse(Context, $"Cancelled.");
            }
        }
Example #24
0
        public static async Task SendTag(SocketCommandContext Context, string tag)
        {
            tag = tag.ToLower();

            var _tag = Database.GetRecord <Tag>(s => s.Stats.Alias == tag && s.Stats.GuildId == Context.Guild.Id);

            if (_tag == null)
            {
                await Respond.SendResponse(Context, $"Tag not found.");

                return;
            }

            _tag.TimesUsed++;
            Database.UpsertRecord(_tag);

            await Context.Channel.SendMessageAsync(_tag.Message);
        }
Example #25
0
        public static async Task CreateTag(SocketCommandContext Context, string tag, string message)
        {
            tag = tag.ToLower();

            // Check for keywords
            List <string> _keywords = new List <string>()
            {
                "create",
                "add",
                "delete",
                "edit",
            };

            if (_keywords.Any(s => s.ToLower() == tag))
            {
                await Respond.SendResponse(Context, "That alias is not available, as it's a keyword.");

                return;
            }

            // Check if tag already exists
            if (Database.GetRecord <Tag>(s => s.Stats.Alias == tag && s.Stats.GuildId == Context.Guild.Id) != null)
            {
                await Respond.SendResponse(Context, "A tag already exists for that alias.");

                return;
            }

            var _newTag = new Tag()
            {
                Stats = new Tag.TagStats()
                {
                    GuildId = Context.Guild.Id,
                    Alias   = tag
                },
                Message   = message,
                CreatedBy = $"{Context.User.Username}#{Context.User.Discriminator}",
                CreatedAt = DateTime.UtcNow
            };

            Database.UpsertRecord(_newTag);

            await Respond.SendResponse(Context, "Tag created.");
        }
Example #26
0
                public async Task GetMuteRecordCommand(ulong userId, ulong guildId = 0)
                {
                    // Get corresponding guild
                    if (guildId == 0)
                    {
                        guildId = Context.Guild.Id;
                    }
                    else
                    {
                        var __guild = Context.Client.GetGuild(guildId);
                        if (__guild == null)
                        {
                            await Respond.SendResponse(Context, $"Could not find guild with ID: `{guildId}`");

                            return;
                        }
                    }

                    var _record = Database.GetRecord <MuteRecord>(s => s.UserId == userId && s.GuildId == guildId);
                    await Respond.SendResponse(Context, (!(_record == null)).ToString());
                }
Example #27
0
            public async Task ChangeGameCommand(int status, [Remainder] string game)
            {
                if (status < 1 || status > 4)
                {
                    await Respond.SendResponse(Context, "Status can only be between **1-4**!");

                    return;
                }

                BotConfigService.SetDefaultActivity(status, game);

                switch (status)
                {
                case 1:
                    await Context.Client.SetGameAsync(game, type : ActivityType.Playing);

                    break;

                case 2:
                    await Context.Client.SetGameAsync(game, type : ActivityType.Listening);

                    break;

                case 3:
                    await Context.Client.SetGameAsync(game, type : ActivityType.Watching);

                    break;

                case 4:
                    await Context.Client.SetGameAsync(game, "https://www.twitch.tv/", ActivityType.Streaming);

                    break;

                default:
                    await Respond.SendResponse(Context, "Please limit activity `1-4`.");

                    break;
                }
            }
Example #28
0
        public static async Task TagStats(SocketCommandContext Context, string tag)
        {
            tag = tag.ToLower();

            var _tag = Database.GetRecord <Tag>(s => s.Stats.Alias == tag);

            if (_tag == null)
            {
                await Respond.SendResponse(Context, "That tag does not exist.");

                return;
            }

            var _embed = new EmbedBuilder()
                         .WithColor(Color.Blue)
                         .WithTitle(tag)
                         .AddField("Created by:", _tag.CreatedBy, true)
                         .AddField("Created on:", _tag.CreatedAt.ToLongDateString(), true)
                         .AddField("Times used:", _tag.TimesUsed)
                         .WithDescription($"**Returns**:\n{_tag.Message}");

            await Context.Channel.SendMessageAsync(embed : _embed.Build());
        }
Example #29
0
            public async Task ShutdownCommand()
            {
                await Respond.SendResponse(Context, ":thumbsup:");

                Environment.Exit(1);
            }
Example #30
0
            public async Task ChangePrefixCommand(string newPrefix)
            {
                BotConfigService.SetPrefix(newPrefix);

                await Respond.SendResponse(Context, $"My new prefix is now: `{newPrefix}`!");
            }