Beispiel #1
0
        public async Task ShowAsync()
        {
            var guild    = ((SocketGuildChannel)Context.Channel).Guild;
            var settings = await _guildSettingsRepoistory.GetAsync(guild.Id);

            if (!await CheckPermission.CheckModPermission(
                    guild.OwnerId,
                    Context.User.Id,
                    settings.ModRoles,
                    ((SocketGuildUser)Context.User).Roles.Select(x => x.Id).ToList()
                    ))
            {
                await ReplyAsync("You don't have permission to do this!");

                return;
            }

            var team = await _twitchTeamMemberRepository.GetTeamAsync(guild.Id);

            if (team.Count == 0)
            {
                await ReplyAsync("No team members yet");

                return;
            }

            var embed = new EmbedBuilder()
                        .WithTitle("Twitch Team Members")
                        .AddField("Id", string.Join("\r\n", team.Select(x => x.TwitchId)), true)
                        .AddField("Display Name", string.Join("\r\n", team.Select(x => x.TwitchDisplayName)), true)
                        .Build();


            await ReplyAsync(embed : embed);
        }
Beispiel #2
0
        public async Task SetTeamAsync(string teamName)
        {
            var guild    = ((SocketGuildChannel)Context.Channel).Guild;
            var settings = await _guildSettingsRepoistory.GetAsync(guild.Id);

            if (!await CheckPermission.CheckModPermission(
                    guild.OwnerId,
                    Context.User.Id,
                    settings.ModRoles,
                    ((SocketGuildUser)Context.User).Roles.Select(x => x.Id).ToList()
                    ))
            {
                await ReplyAsync("You don't have permission to do this!");

                return;
            }
            var current = await _twitchTeamSettingsRepository.GetAsync(guild.Id);

            if (current == null)
            {
                current = new Bot.Core.TwitchTeamSettings
                {
                    GuildId   = guild.Id.ToString(),
                    ChannelId = ""
                };
            }
            current.TeamName = teamName;

            await _twitchTeamSettingsRepository.SaveAsync(current);

            await ReplyAsync("Team Name Set");
        }
        public async Task SetChannelAsync(IChannel channel)
        {
            var guild    = ((SocketGuildChannel)Context.Channel).Guild;
            var settings = await _guildSettingsRepoistory.GetAsync(guild.Id);

            if (!await CheckPermission.CheckModPermission(
                    guild.OwnerId,
                    Context.User.Id,
                    settings.ModRoles,
                    ((SocketGuildUser)Context.User).Roles.Select(x => x.Id).ToList()
                    ))
            {
                await ReplyAsync("You don't have permission to do this!");

                return;
            }

            var current = await _singleStreamerSettingsRepository.GetAsync(guild.Id);

            if (current == null)
            {
                current = new Bot.Core.SingleStreamerSettings
                {
                    GuildId = guild.Id.ToString()
                };
            }
            current.ChannelId = channel.Id.ToString();

            await _singleStreamerSettingsRepository.SaveAsync(current);

            await ReplyAsync("Channel Set");
        }
Beispiel #4
0
        public async Task End()
        {
            var guild    = ((SocketGuildChannel)Context.Channel).Guild;
            var settings = await _guildSettingsRepoistory.GetAsync(guild.Id);

            if (!await CheckPermission.CheckModPermission(
                    guild.OwnerId,
                    Context.User.Id,
                    settings.ModRoles,
                    ((SocketGuildUser)Context.User).Roles.Select(x => x.Id).ToList()
                    ))
            {
                await ReplyAsync("You don't have permission to do this!");

                return;
            }

            var current = await _transcriberRepository.GetAsync(guild.Id, Context.Channel.Id);

            if (current == null || current.Ended != DateTime.MinValue)
            {
                await ReplyAsync("Transcriber not currently running on this channel");

                return;
            }

            //Process Log
            current.Ended = DateTime.Now;

            var             messageCount = 0;
            List <IMessage> messages     = (await Context.Channel.GetMessagesAsync(ulong.Parse(current.MessageId), Direction.After).FlattenAsync()).ToList();

            messageCount = messages.Count();
            while (messageCount == 100)
            {
                var top     = messages.OrderByDescending(x => x.CreatedAt).FirstOrDefault();
                var nextSet = await Context.Channel.GetMessagesAsync(top.Id, Direction.After).FlattenAsync();

                messages.AddRange(nextSet);
                messageCount = nextSet.Count();
            }

            await _transcriberRepository.SaveAsync(current);

            byte[] buffer;

            using (var ms = new MemoryStream())
            {
                HtmlConverter.ConvertToPdf(@$ "<html>
											<style>
												body {{
													font-family: Arial, Helvetica, sans-serif;
												}}
Beispiel #5
0
        public async Task Start()
        {
            var guild    = ((SocketGuildChannel)Context.Channel).Guild;
            var settings = await _guildSettingsRepoistory.GetAsync(guild.Id);

            if (!await CheckPermission.CheckModPermission(
                    guild.OwnerId,
                    Context.User.Id,
                    settings.ModRoles,
                    ((SocketGuildUser)Context.User).Roles.Select(x => x.Id).ToList()
                    ))
            {
                await ReplyAsync("You don't have permission to do this!");

                return;
            }
            var current = await _transcriberRepository.GetAsync(guild.Id, Context.Channel.Id);

            if (current == null)
            {
                current = new Bot.Core.Transcriber
                {
                    GuildId   = guild.Id.ToString(),
                    ChannelId = Context.Channel.Id.ToString(),
                    Started   = DateTime.Now,
                    Ended     = DateTime.MinValue,
                    MessageId = Context.Message.Id.ToString()
                };
            }
            else if (current.Ended != DateTime.MinValue)
            {
                current.Started   = DateTime.Now;
                current.Ended     = DateTime.MinValue;
                current.MessageId = Context.Message.Id.ToString();
            }
            else
            {
                await ReplyAsync("Transcriber already running on this channel");

                return;
            }

            await _transcriberRepository.SaveAsync(current);

            await ReplyAsync("Started transcriber on this channel");
        }
Beispiel #6
0
        public async Task AddAsync(string twitchUsername)
        {
            var guild    = ((SocketGuildChannel)Context.Channel).Guild;
            var settings = await _guildSettingsRepoistory.GetAsync(guild.Id);

            if (!await CheckPermission.CheckModPermission(
                    guild.OwnerId,
                    Context.User.Id,
                    settings.ModRoles,
                    ((SocketGuildUser)Context.User).Roles.Select(x => x.Id).ToList()
                    ))
            {
                await ReplyAsync("You don't have permission to do this!");

                return;
            }

            var team = await _twitchTeamMemberRepository.GetTeamAsync(guild.Id);

            var user = await _twitchService.GetUserByLoginAsync(twitchUsername);

            if (user == null)
            {
                return;
            }

            if (!team.Any(x => x.TwitchId == user.Id))
            {
                await _twitchTeamMemberRepository.SaveAsync(new Bot.Core.TwitchTeamMember
                {
                    GuildId           = guild.Id.ToString(),
                    TwitchId          = user.Id,
                    TwitchDisplayName = user.DisplayName
                });
                await ReplyAsync("Team member added");
            }
            else
            {
                await ReplyAsync("Team member already exists");
            }
        }
        public async Task AddAsync(string twitchUsername)
        {
            var guild    = ((SocketGuildChannel)Context.Channel).Guild;
            var settings = await _guildSettingsRepoistory.GetAsync(guild.Id);

            if (!await CheckPermission.CheckModPermission(
                    guild.OwnerId,
                    Context.User.Id,
                    settings.ModRoles,
                    ((SocketGuildUser)Context.User).Roles.Select(x => x.Id).ToList()
                    ))
            {
                await ReplyAsync("You don't have permission to do this!");

                return;
            }

            var current = await _singleStreamerSettingsRepository.GetAsync(guild.Id);

            if (current == null)
            {
                current = new Bot.Core.SingleStreamerSettings
                {
                    GuildId = guild.Id.ToString()
                };
            }
            var user = await _twitchService.GetUserByLoginAsync(twitchUsername);

            if (user == null)
            {
                return;
            }

            current.UserId      = user.Id;
            current.DisplayName = user.DisplayName;
            await _singleStreamerSettingsRepository.SaveAsync(current);

            await ReplyAsync("Single streamer set");
        }
Beispiel #8
0
        public async Task RemoveAsync(string twitchUsername)
        {
            var guild    = ((SocketGuildChannel)Context.Channel).Guild;
            var settings = await _guildSettingsRepoistory.GetAsync(guild.Id);

            if (!await CheckPermission.CheckModPermission(
                    guild.OwnerId,
                    Context.User.Id,
                    settings.ModRoles,
                    ((SocketGuildUser)Context.User).Roles.Select(x => x.Id).ToList()
                    ))
            {
                await ReplyAsync("You don't have permission to do this!");

                return;
            }

            var team = await _twitchTeamMemberRepository.GetTeamAsync(guild.Id);

            var user = await _twitchService.GetUserByLoginAsync(twitchUsername);

            if (user == null)
            {
                return;
            }

            if (team.Any(x => x.TwitchId == user.Id))
            {
                await _twitchTeamMemberRepository.DeleteAsync(guild.Id, user.Id);
                await ReplyAsync("Team member removed");
            }
            else
            {
                await ReplyAsync("Team member doesn't exist");
            }
        }
Beispiel #9
0
        public async Task InformationAsyc(int amount)
        {
            var guild    = ((SocketGuildChannel)Context.Channel).Guild;
            var settings = await _guildSettingsRepoistory.GetAsync(guild.Id);

            if (!await CheckPermission.CheckModPermission(
                    guild.OwnerId,
                    Context.User.Id,
                    settings.ModRoles,
                    ((SocketGuildUser)Context.User).Roles.Select(x => x.Id).ToList()
                    ))
            {
                await ReplyAsync("You don't have permission to do this!");

                return;
            }

            var messagesToPurge = await Context.Channel.GetMessagesAsync(amount).FlattenAsync();

            foreach (var message in messagesToPurge)
            {
                await Context.Channel.DeleteMessageAsync(message);
            }
        }