Ejemplo n.º 1
0
        public async Task On()
        {
            var guild = ((IGuildUser)Context.Message.Author).Guild;

            var user = ((IGuildUser)Context.Message.Author);

            if (!user.GuildPermissions.ManageGuild)
            {
                return;
            }

            var file   = Constants.ConfigRootDirectory + Constants.GuildDirectory + guild.Id + ".json";
            var server = new DiscordServer();

            if (File.Exists(file))
            {
                server = JsonConvert.DeserializeObject <DiscordServer>(File.ReadAllText(file));
            }

            server.Goodbyes = true;
            if (string.IsNullOrEmpty(server.GoodbyeMessage))
            {
                server.GoodbyeMessage = "Good bye, %USER%, thanks for hanging out!";
            }

            await BotFiles.SaveDiscordServer(server, Context.Guild);

            await Context.Channel.SendMessageAsync("Goodbyes have been turned on.");
        }
Ejemplo n.º 2
0
        public async Task TextAnnouncements(string trueFalse)
        {
            var guild = ((IGuildUser)Context.Message.Author).Guild;
            var user  = ((IGuildUser)Context.Message.Author);

            if (!user.GuildPermissions.ManageGuild)
            {
                return;
            }

            trueFalse = trueFalse.ToLower();
            if (!trueFalse.Equals("true") && !trueFalse.Equals("false"))
            {
                await Context.Channel.SendMessageAsync("Pass true or false when configuring Text Announcements. (ie: !cb config textannouncements true)");

                return;
            }

            var file   = Constants.ConfigRootDirectory + Constants.GuildDirectory + guild.Id + ".json";
            var server = new DiscordServer();

            if (File.Exists(file))
            {
                server = JsonConvert.DeserializeObject <DiscordServer>(File.ReadAllText(file));
            }

            server.UseTextAnnouncements = bool.Parse(trueFalse);
            await BotFiles.SaveDiscordServer(server, Context.Guild);

            await Context.Channel.SendMessageAsync("Text announcements has been set to: " + trueFalse);
        }
Ejemplo n.º 3
0
        public async Task MentionRole(IRole role)
        {
            var guild = ((IGuildUser)Context.Message.Author).Guild;
            var user  = ((IGuildUser)Context.Message.Author);

            if (!user.GuildPermissions.ManageGuild)
            {
                return;
            }

            var file   = Constants.ConfigRootDirectory + Constants.GuildDirectory + guild.Id + ".json";
            var server = new DiscordServer();

            if (File.Exists(file))
            {
                server = JsonConvert.DeserializeObject <DiscordServer>(File.ReadAllText(file));
            }

            if (role.Name.ToLower().Contains("everyone"))
            {
                server.MentionRole = 0;
            }
            else
            {
                server.MentionRole = role.Id;
            }

            await BotFiles.SaveDiscordServer(server, Context.Guild);

            await Context.Channel.SendMessageAsync("Mention Role has been set to: " + role.Name);
        }
Ejemplo n.º 4
0
        public async Task Remove(string name)
        {
            if (!IsApprovedAdmin)
            {
                return;
            }

            var id = await _vidMeManager.GetIdByName(name);

            var file   = Constants.ConfigRootDirectory + Constants.GuildDirectory + Context.Guild.Id + ".json";
            var server = new DiscordServer();

            if (File.Exists(file))
            {
                server = JsonConvert.DeserializeObject <DiscordServer>(File.ReadAllText(file));
            }

            if (server.ServerVidMeChannels == null)
            {
                return;
            }

            if (server.ServerVidMeChannels.Contains(name.ToLower()))
            {
                server.ServerVidMeChannels.Remove(name.ToLower());
                server.ServerVidMeChannelIds.Remove(id);
                await BotFiles.SaveDiscordServer(server, Context.Guild);

                await Context.Channel.SendMessageAsync("Removed " + name + " from the server Vid.me list.");
            }
            else
            {
                await Context.Channel.SendMessageAsync(name + " wasn't on the server Vid.me list.");
            }
        }
Ejemplo n.º 5
0
        public async Task Offline(string message)
        {
            var guild = ((IGuildUser)Context.Message.Author).Guild;

            var user = ((IGuildUser)Context.Message.Author);

            if (!user.GuildPermissions.ManageGuild)
            {
                return;
            }

            var file   = Constants.ConfigRootDirectory + Constants.GuildDirectory + guild.Id + ".json";
            var server = new DiscordServer();

            if (File.Exists(file))
            {
                server = JsonConvert.DeserializeObject <DiscordServer>(File.ReadAllText(file));
            }

            if (message.ToLower().Equals("clear"))
            {
                server.StreamOfflineMessage = "This stream is now offline.";
                await Context.Channel.SendMessageAsync("Stream Offline Message has been reset to the default message.");
            }
            else
            {
                server.StreamOfflineMessage = message;
                await Context.Channel.SendMessageAsync("Stream Offline Message has been set.");
            }

            await BotFiles.SaveDiscordServer(server, Context.Guild);
        }
Ejemplo n.º 6
0
        public async Task Remove(IGuildUser user)
        {
            var guild = ((IGuildUser)Context.Message.Author).Guild;

            var authorUser = ((IGuildUser)Context.Message.Author);

            if (!authorUser.GuildPermissions.ManageGuild)
            {
                return;
            }

            var file   = Constants.ConfigRootDirectory + Constants.GuildDirectory + guild.Id + ".json";
            var server = new DiscordServer();

            if (File.Exists(file))
            {
                server = JsonConvert.DeserializeObject <DiscordServer>(File.ReadAllText(file));
            }

            if (server.ApprovedAdmins == null || !server.ApprovedAdmins.Contains(user.Id))
            {
                await Context.Channel.SendMessageAsync(user.Username + " is not on the approved admins list for this server.");

                return;
            }

            server.ApprovedAdmins.Remove(user.Id);
            await BotFiles.SaveDiscordServer(server, Context.Guild);

            await Context.Channel.SendMessageAsync(user.Username + " has been removed from the approved admin list for this server.");
        }
Ejemplo n.º 7
0
        public async Task Remove(IUser user)
        {
            var guild      = ((IGuildUser)Context.Message.Author).Guild;
            var authorUser = ((IGuildUser)Context.Message.Author);

            if (!authorUser.GuildPermissions.ManageGuild)
            {
                return;
            }

            var server = BotFiles.GetDiscordServer(guild.Id.ToString());

            if (server.BroadcasterWhitelist == null)
            {
                server.BroadcasterWhitelist = new List <string>();
            }

            if (server.BroadcasterWhitelist.Contains(user.Id.ToString()))
            {
                server.BroadcasterWhitelist.Remove(user.Id.ToString());
                BotFiles.SaveDiscordServer(server);
                await Context.Channel.SendMessageAsync(user.Username + " has been removed from the whitelist.");
            }
            else
            {
                await Context.Channel.SendMessageAsync(user.Username + " was not on the whitelist.");
            }
        }
Ejemplo n.º 8
0
        public async Task RemoveGame(string gameName)
        {
            if (!IsApprovedAdmin)
            {
                return;
            }

            var file   = Constants.ConfigRootDirectory + Constants.GuildDirectory + Context.Guild.Id + ".json";
            var server = new DiscordServer();

            if (File.Exists(file))
            {
                server = JsonConvert.DeserializeObject <DiscordServer>(File.ReadAllText(file));
            }

            if (server.ServerGameList == null)
            {
                return;
            }

            if (server.ServerGameList.Contains(gameName, StringComparer.CurrentCultureIgnoreCase))
            {
                server.ServerGameList.Remove(gameName);
                await BotFiles.SaveDiscordServer(server, Context.Guild);

                await Context.Channel.SendMessageAsync("Removed " + gameName + " from the server Twitch game list.");
            }
            else
            {
                await Context.Channel.SendMessageAsync(gameName + " isn't on the server Twitch game list.");
            }
        }
Ejemplo n.º 9
0
        public async Task RemoveTeam(string teamName)
        {
            if (!IsApprovedAdmin)
            {
                return;
            }

            var file   = Constants.ConfigRootDirectory + Constants.GuildDirectory + Context.Guild.Id + ".json";
            var server = new DiscordServer();

            if (File.Exists(file))
            {
                server = JsonConvert.DeserializeObject <DiscordServer>(File.ReadAllText(file));
            }

            if (server.TwitchTeams == null)
            {
                return;
            }

            if (server.TwitchTeams.Contains(teamName, StringComparer.CurrentCultureIgnoreCase))
            {
                var team = await _twitchManager.GetTwitchTeamByName(teamName);

                server.TwitchTeams.Remove(teamName);
                await BotFiles.SaveDiscordServer(server, Context.Guild);

                await Context.Channel.SendMessageAsync("Removed " + team.DisplayName + " (" + teamName + ") from the server Twitch team list.");
            }
            else
            {
                await Context.Channel.SendMessageAsync("Token " + teamName + " isn't on the server Twitch team list.");
            }
        }
Ejemplo n.º 10
0
        public async Task Remove(string channel)
        {
            if (!IsApprovedAdmin)
            {
                return;
            }

            var file   = Constants.ConfigRootDirectory + Constants.GuildDirectory + Context.Guild.Id + ".json";
            var server = new DiscordServer();

            if (File.Exists(file))
            {
                server = JsonConvert.DeserializeObject <DiscordServer>(File.ReadAllText(file));
            }

            if (server.ServerTwitchChannels == null)
            {
                return;
            }

            if (server.ServerTwitchChannels.Contains(channel.ToLower()))
            {
                var twitchId = await _twitchManager.GetTwitchIdByLogin(channel);

                server.ServerTwitchChannels.Remove(channel.ToLower());
                server.ServerTwitchChannelIds.Remove(twitchId);
                await BotFiles.SaveDiscordServer(server, Context.Guild);

                await Context.Channel.SendMessageAsync("Removed " + channel + " from the server Twitch streamer list.");
            }
            else
            {
                await Context.Channel.SendMessageAsync(channel + " wasn't on the server Twitch streamer list.");
            }
        }
Ejemplo n.º 11
0
        public async Task Add(string channelId)
        {
            if (!IsApprovedAdmin)
            {
                return;
            }

            if (!channelId.ToLower().StartsWith("uc") || channelId.Length != 24)
            {
                await Context.Channel.SendMessageAsync("Incorrect YouTube Channel ID Provided. Channel ID's start with UC and have 24 characters.");

                return;
            }

            var channel = await _youTubeManager.GetYouTubeChannelSnippetById(channelId);

            if (channel == null || channel.items == null || channel.items.Count == 0)
            {
                await Context.Channel.SendMessageAsync("No channel exists with the ID " + channelId + ". You can use the command '!cb ytidlookup <QUERY>' to find the correct ID.");

                return;
            }

            var file   = Constants.ConfigRootDirectory + Constants.GuildDirectory + Context.Guild.Id + ".json";
            var server = new DiscordServer();

            if (File.Exists(file))
            {
                server = JsonConvert.DeserializeObject <DiscordServer>(File.ReadAllText(file));
            }

            if (server.ServerYouTubeChannelIds == null)
            {
                server.ServerYouTubeChannelIds = new List <string>();
            }

            if (!string.IsNullOrEmpty(server.OwnerYouTubeChannelId) && server.OwnerYouTubeChannelId.Equals(channelId))
            {
                await Context.Channel.SendMessageAsync("The channel " + channelId + " is configured as the Owner YouTube channel. " +
                                                       "Please remove it with the '!cb youtube resetowner' command and then try re-adding it.");

                return;
            }

            if (!server.ServerYouTubeChannelIds.Contains(channelId))
            {
                server.ServerYouTubeChannelIds.Add(channelId);
                await BotFiles.SaveDiscordServer(server, Context.Guild);

                await Context.Channel.SendMessageAsync("Added " + channelId + " to the server YouTube streamer list.");
            }
            else
            {
                await Context.Channel.SendMessageAsync(channelId + " is already on the server YouTube streamer list.");
            }
        }
Ejemplo n.º 12
0
        public async Task Add(string channelName)
        {
            if (!IsApprovedAdmin)
            {
                return;
            }

            var twitchChannelId = await _twitchManager.GetTwitchIdByLogin(channelName);

            if (string.IsNullOrEmpty(twitchChannelId))
            {
                await Context.Channel.SendMessageAsync("Twitch Channel " + channelName + " does not exist.");

                return;
            }

            var file   = Constants.ConfigRootDirectory + Constants.GuildDirectory + Context.Guild.Id + ".json";
            var server = new DiscordServer();

            if (File.Exists(file))
            {
                server = JsonConvert.DeserializeObject <DiscordServer>(File.ReadAllText(file));
            }

            if (server.ServerTwitchChannels == null)
            {
                server.ServerTwitchChannels = new List <string>();
            }

            if (server.ServerTwitchChannelIds == null)
            {
                server.ServerTwitchChannelIds = new List <string>();
            }

            if (!string.IsNullOrEmpty(server.OwnerTwitchChannel) && server.OwnerTwitchChannel.ToLower().Equals(channelName.ToLower()))
            {
                await Context.Channel.SendMessageAsync("The channel " + channelName + " is configured as the Owner Twitch channel. " +
                                                       "Please remove it with the '!cb twitch resetowner' command and then try re-adding it.");

                return;
            }

            if (!server.ServerTwitchChannels.Contains(channelName.ToLower()))
            {
                server.ServerTwitchChannels.Add(channelName.ToLower());
                server.ServerTwitchChannelIds.Add(await _twitchManager.GetTwitchIdByLogin(channelName));
                await BotFiles.SaveDiscordServer(server, Context.Guild);

                await Context.Channel.SendMessageAsync("Added " + channelName + " to the server Twitch streamer list.");
            }
            else
            {
                await Context.Channel.SendMessageAsync(channelName + " is already on the server Twitch streamer list.");
            }
        }
Ejemplo n.º 13
0
        public async Task AddGame(string gameName)
        {
            if (!IsApprovedAdmin)
            {
                return;
            }

            var file   = Constants.ConfigRootDirectory + Constants.GuildDirectory + Context.Guild.Id + ".json";
            var server = new DiscordServer();

            if (File.Exists(file))
            {
                server = JsonConvert.DeserializeObject <DiscordServer>(File.ReadAllText(file));
            }

            if (server.ServerGameList == null)
            {
                server.ServerGameList = new List <string>();
            }

            var games = await _twitchManager.SearchForGameByName(gameName);

            if (games.games == null)
            {
                await Context.Channel.SendMessageAsync(gameName + " is not a valid game. Please check the name, and try again.");

                return;
            }

            var gameDASfasdf = games.games.FirstOrDefault(x => x.name.Equals(gameName, StringComparison.CurrentCultureIgnoreCase));

            if (games.games.FirstOrDefault(x => x.name.Equals(gameName, StringComparison.CurrentCultureIgnoreCase)) == null)
            {
                var suggestedGameList = "That is not a valid game name. Is the game you want on the list below?\r\n\r\n" +
                                        String.Join(", ", games.games.Select(x => x.name));

                await Context.Channel.SendMessageAsync(suggestedGameList);

                return;
            }

            if (!server.ServerGameList.Contains(gameName, StringComparer.CurrentCultureIgnoreCase))
            {
                server.ServerGameList.Add(gameName);
                await BotFiles.SaveDiscordServer(server, Context.Guild);

                await Context.Channel.SendMessageAsync("Added " + gameName + " to the server Twitch game list.");
            }
            else
            {
                await Context.Channel.SendMessageAsync(gameName + " is already on the server Twitch game list.");
            }
        }
Ejemplo n.º 14
0
        public async Task Add(string name)
        {
            if (!IsApprovedAdmin)
            {
                return;
            }

            var id = await _vidMeManager.GetIdByName(name);

            if (id == 0)
            {
                await Context.Channel.SendFileAsync("No channel exists with the name " + name + ".");
            }

            var file   = Constants.ConfigRootDirectory + Constants.GuildDirectory + Context.Guild.Id + ".json";
            var server = new DiscordServer();

            if (File.Exists(file))
            {
                server = JsonConvert.DeserializeObject <DiscordServer>(File.ReadAllText(file));
            }

            if (server.ServerVidMeChannels == null)
            {
                server.ServerVidMeChannels = new List <string>();
            }

            if (server.ServerVidMeChannelIds == null)
            {
                server.ServerVidMeChannelIds = new List <int>();
            }

            if (!string.IsNullOrEmpty(server.OwnerVidMeChannel) && server.OwnerVidMeChannel.ToLower().Equals(name.ToLower()))
            {
                await Context.Channel.SendMessageAsync("The channel " + name + " is configured as the Owner Vid.me channel. " +
                                                       "Please remove it with the '!cb vidme resetowner' command and then try re-adding it.");

                return;
            }

            if (!server.ServerVidMeChannels.Contains(name.ToLower()))
            {
                server.ServerVidMeChannels.Add(name.ToLower());
                server.ServerVidMeChannelIds.Add(id);
                await BotFiles.SaveDiscordServer(server, Context.Guild);

                await Context.Channel.SendMessageAsync("Added " + name + " to the server Vid.me list.");
            }
            else
            {
                await Context.Channel.SendMessageAsync(name + " is already on the server Vid.me list.");
            }
        }
Ejemplo n.º 15
0
        public async Task Off()
        {
            var guild = ((IGuildUser)Context.Message.Author).Guild;

            var user = ((IGuildUser)Context.Message.Author);

            if (!user.GuildPermissions.ManageGuild)
            {
                return;
            }

            var server = BotFiles.GetDiscordServer(guild.Id.ToString());

            server.UseWhitelist = false;
            BotFiles.SaveDiscordServer(server);
            await Context.Channel.SendMessageAsync("Use whitelist has been turned off.");
        }
Ejemplo n.º 16
0
        public async Task Owner(string channelId)
        {
            if (!IsAdmin)
            {
                return;
            }

            if (!channelId.ToLower().StartsWith("uc") || channelId.Length != 24)
            {
                await Context.Channel.SendMessageAsync("Incorrect YouTube Channel ID Provided. Channel ID's start with UC and have 24 characters.");

                return;
            }

            var channel = await _youTubeManager.GetYouTubeChannelSnippetById(channelId);

            if (channel == null || channel.items == null || channel.items.Count == 0)
            {
                await Context.Channel.SendMessageAsync("No channel exists with the ID " + channelId + ". You can use the command '!cb ytidlookup <QUERY>' to find the correct ID.");

                return;
            }

            var file   = Constants.ConfigRootDirectory + Constants.GuildDirectory + Context.Guild.Id + ".json";
            var server = new DiscordServer();

            if (File.Exists(file))
            {
                server = JsonConvert.DeserializeObject <DiscordServer>(File.ReadAllText(file));
            }

            if (server.ServerYouTubeChannelIds != null && server.ServerYouTubeChannelIds.Contains(channelId.ToLower()))
            {
                await Context.Channel.SendMessageAsync("The channel " + channel + " is in the list of server YouTube Channels. " +
                                                       "Please remove it with '!cb youtube remove " + channel + "' and then retry setting your owner channel.");

                return;
            }

            server.OwnerYouTubeChannelId = channelId;
            await BotFiles.SaveDiscordServer(server, Context.Guild);

            await Context.Channel.SendMessageAsync("Owner YouTube Channel ID has been set to " + channelId + ".");
        }
Ejemplo n.º 17
0
        public async Task Owner(string name)
        {
            if (!IsAdmin)
            {
                return;
            }

            var id = await _vidMeManager.GetIdByName(name);

            if (id == 0)
            {
                await Context.Channel.SendMessageAsync("No channel exists with the name " + name + ".");

                return;
            }

            var file   = Constants.ConfigRootDirectory + Constants.GuildDirectory + Context.Guild.Id + ".json";
            var server = new DiscordServer();

            if (File.Exists(file))
            {
                server = JsonConvert.DeserializeObject <DiscordServer>(File.ReadAllText(file));
            }

            if (server.Id == 0)
            {
                return;
            }

            if (server.ServerVidMeChannels != null && server.ServerVidMeChannels.Contains(name.ToLower()))
            {
                await Context.Channel.SendMessageAsync("The channel " + name + " is in the list of server Vid.me Channels. " +
                                                       "Please remove it with '!cb vidme remove " + name + "' and then retry setting your owner channel.");

                return;
            }

            server.OwnerVidMeChannel   = name;
            server.OwnerVidMeChannelId = id;
            await BotFiles.SaveDiscordServer(server, Context.Guild);

            await Context.Channel.SendMessageAsync("Owner Vid.me channel has been set to " + name + ".");
        }
Ejemplo n.º 18
0
        public async Task ResetOwner()
        {
            if (!IsAdmin)
            {
                return;
            }

            var file   = Constants.ConfigRootDirectory + Constants.GuildDirectory + Context.Guild.Id + ".json";
            var server = new DiscordServer();

            if (File.Exists(file))
            {
                server = JsonConvert.DeserializeObject <DiscordServer>(File.ReadAllText(file));
            }

            server.OwnerPicartoChannel = null;
            await BotFiles.SaveDiscordServer(server, Context.Guild);

            await Context.Channel.SendMessageAsync("Owner Picarto Channel has been reset.");
        }
Ejemplo n.º 19
0
        public async Task AddTeam(string teamName)
        {
            if (!IsApprovedAdmin)
            {
                return;
            }

            var team = await _twitchManager.GetTwitchTeamByName(teamName);

            if (team == null)
            {
                await Context.Channel.SendMessageAsync(teamName + " is not a valid Twitch team token. The team token is on the end of the Team URL, ie: (http://twitch.tv/teams/ths .. use !cb twitch addteam ths).");

                return;
            }

            var file   = Constants.ConfigRootDirectory + Constants.GuildDirectory + Context.Guild.Id + ".json";
            var server = new DiscordServer();

            if (File.Exists(file))
            {
                server = JsonConvert.DeserializeObject <DiscordServer>(File.ReadAllText(file));
            }

            if (server.TwitchTeams == null)
            {
                server.TwitchTeams = new List <string>();
            }

            if (!server.TwitchTeams.Contains(teamName, StringComparer.CurrentCultureIgnoreCase))
            {
                server.TwitchTeams.Add(teamName);
                await BotFiles.SaveDiscordServer(server, Context.Guild);

                await Context.Channel.SendMessageAsync("Added " + team.DisplayName + " (" + teamName + ") to the server Twitch team list.");
            }
            else
            {
                await Context.Channel.SendMessageAsync(team.DisplayName + " (" + teamName + ") is already on the server Twitch team list.");
            }
        }
Ejemplo n.º 20
0
        public async Task Owner(string channel)
        {
            if (!IsAdmin)
            {
                return;
            }

            var beamChannel = await _mixerManager.GetChannelByName(channel);

            if (beamChannel == null)
            {
                await Context.Channel.SendMessageAsync("Mixer Channel " + channel + " does not exist.");

                return;
            }

            var file   = Constants.ConfigRootDirectory + Constants.GuildDirectory + Context.Guild.Id + ".json";
            var server = new DiscordServer();

            if (File.Exists(file))
            {
                server = JsonConvert.DeserializeObject <DiscordServer>(File.ReadAllText(file));
            }

            if (server.ServerBeamChannels != null && server.ServerBeamChannels.Contains(channel.ToLower()))
            {
                await Context.Channel.SendMessageAsync("The channel " + channel + " is in the list of server Mixer Channels. " +
                                                       "Please remove it with '!cb mixer remove " + channel + "' and then retry setting your owner channel.");

                return;
            }

            server.OwnerBeamChannel   = channel;
            server.OwnerBeamChannelId = beamChannel.id.Value.ToString();
            await Program.beamClient.SubscribeToLiveAnnouncements(beamChannel.id.Value.ToString());

            await BotFiles.SaveDiscordServer(server, Context.Guild);

            await Context.Channel.SendMessageAsync("Owner Mixer Channel has been set to " + channel + ".");
        }
Ejemplo n.º 21
0
        public async Task Greetings(IGuildChannel guildChannel)
        {
            var user = ((IGuildUser)Context.Message.Author);

            if (!user.GuildPermissions.ManageGuild)
            {
                return;
            }

            var file   = Constants.ConfigRootDirectory + Constants.GuildDirectory + guildChannel.Guild.Id + ".json";
            var server = new DiscordServer();

            if (File.Exists(file))
            {
                server = JsonConvert.DeserializeObject <DiscordServer>(File.ReadAllText(file));
            }

            server.GreetingsChannel = guildChannel.Id;
            await BotFiles.SaveDiscordServer(server, Context.Guild);

            await Context.Channel.SendMessageAsync("The Greetings Channel has been set.");
        }
Ejemplo n.º 22
0
        public async Task Owner(string channel)
        {
            if (!IsAdmin)
            {
                return;
            }

            var twitchChannelId = await _twitchManager.GetTwitchIdByLogin(channel);

            if (string.IsNullOrEmpty(twitchChannelId))
            {
                await Context.Channel.SendMessageAsync("Twitch Channel " + channel + " does not exist.");

                return;
            }

            var file   = Constants.ConfigRootDirectory + Constants.GuildDirectory + Context.Guild.Id + ".json";
            var server = new DiscordServer();

            if (File.Exists(file))
            {
                server = JsonConvert.DeserializeObject <DiscordServer>(File.ReadAllText(file));
            }

            if (server.ServerTwitchChannels != null && server.ServerTwitchChannels.Contains(channel.ToLower()))
            {
                await Context.Channel.SendMessageAsync("The channel " + channel + " is in the list of server Twitch Channels. " +
                                                       "Please remove it with '!cb twitch remove " + channel + "' and then retry setting your owner channel.");

                return;
            }

            server.OwnerTwitchChannel   = channel;
            server.OwnerTwitchChannelId = twitchChannelId;
            await BotFiles.SaveDiscordServer(server, Context.Guild);

            await Context.Channel.SendMessageAsync("Owner Twitch Channel has been set to " + channel + ".");
        }
Ejemplo n.º 23
0
        public async Task TimeZoneOffset(float offset)
        {
            var guild = ((IGuildUser)Context.Message.Author).Guild;
            var user  = ((IGuildUser)Context.Message.Author);

            if (!user.GuildPermissions.ManageGuild)
            {
                return;
            }

            var file   = Constants.ConfigRootDirectory + Constants.GuildDirectory + guild.Id + ".json";
            var server = new DiscordServer();

            if (File.Exists(file))
            {
                server = JsonConvert.DeserializeObject <DiscordServer>(File.ReadAllText(file));
            }

            server.TimeZoneOffset = offset;
            await BotFiles.SaveDiscordServer(server, Context.Guild);

            await Context.Channel.SendMessageAsync("Your Server Time Zone Offset has been set.");
        }
Ejemplo n.º 24
0
        public async Task Remove(string channel)
        {
            if (!IsApprovedAdmin)
            {
                return;
            }

            var           file   = Constants.ConfigRootDirectory + Constants.GuildDirectory + Context.Guild.Id + ".json";
            DiscordServer server = null;

            if (File.Exists(file))
            {
                server = JsonConvert.DeserializeObject <DiscordServer>(File.ReadAllText(file));
            }

            if (server == null)
            {
                return;
            }

            if (server.ServerHitboxChannels == null)
            {
                return;
            }

            if (server.ServerHitboxChannels.Contains(channel.ToLower()))
            {
                server.ServerHitboxChannels.Remove(channel.ToLower());
                await BotFiles.SaveDiscordServer(server, Context.Guild);

                await Context.Channel.SendMessageAsync("Removed " + channel + " from the server Smashcast streamer list.");
            }
            else
            {
                await Context.Channel.SendMessageAsync(channel + " wasn't on the server Smashcast streamer list.");
            }
        }
Ejemplo n.º 25
0
        public async Task Owner(string channelName)
        {
            if (!IsAdmin)
            {
                return;
            }

            var channel = await _picartoManager.GetChannelByName(channelName);

            if (channel == null)
            {
                await Context.Channel.SendMessageAsync("The Picarto channel, " + channelName + ", does not exist.");

                return;
            }

            var file   = Constants.ConfigRootDirectory + Constants.GuildDirectory + Context.Guild.Id + ".json";
            var server = new DiscordServer();

            if (File.Exists(file))
            {
                server = JsonConvert.DeserializeObject <DiscordServer>(File.ReadAllText(file));
            }

            if (server.PicartoChannels != null && server.PicartoChannels.Contains(channelName.ToLower()))
            {
                await Context.Channel.SendMessageAsync("The channel " + channelName + " is in the list of server Picarto Channels. " +
                                                       "Please remove it with '!cb picarto remove " + channelName + "' and then retry setting your owner channel.");

                return;
            }

            server.OwnerPicartoChannel = channelName;
            await BotFiles.SaveDiscordServer(server, Context.Guild);

            await Context.Channel.SendMessageAsync("Owner Picarto Channel has been set to " + channelName + ".");
        }
Ejemplo n.º 26
0
        public async Task Off()
        {
            var guild = ((IGuildUser)Context.Message.Author).Guild;

            var user = ((IGuildUser)Context.Message.Author);

            if (!user.GuildPermissions.ManageGuild)
            {
                return;
            }

            var file   = Constants.ConfigRootDirectory + Constants.GuildDirectory + guild.Id + ".json";
            var server = new DiscordServer();

            if (File.Exists(file))
            {
                server = JsonConvert.DeserializeObject <DiscordServer>(File.ReadAllText(file));
            }

            server.Goodbyes = false;
            await BotFiles.SaveDiscordServer(server, Context.Guild);

            await Context.Channel.SendMessageAsync("Goodbyes have been turned off.");
        }
Ejemplo n.º 27
0
        public async Task Clear(string option)
        {
            var guild = ((IGuildUser)Context.Message.Author).Guild;
            var user  = ((IGuildUser)Context.Message.Author);

            if (!user.GuildPermissions.ManageGuild)
            {
                return;
            }

            var file   = Constants.ConfigRootDirectory + Constants.GuildDirectory + guild.Id + ".json";
            var server = new DiscordServer();

            if (File.Exists(file))
            {
                server = JsonConvert.DeserializeObject <DiscordServer>(File.ReadAllText(file));
            }

            if (File.Exists(file))
            {
                option = option.ToLower();
                string label = "";

                switch (option)
                {
                case "live":
                    server.GoLiveChannel = 0;
                    label = "Live Channel";
                    break;

                case "ownerlive":
                    server.OwnerLiveChannel = 0;
                    label = "Owner Live Channel";
                    break;

                case "announce":
                    server.AnnouncementsChannel = 0;
                    label = "Announcements";
                    break;

                case "greetings":
                    server.GreetingsChannel = 0;
                    label = "Greetings";
                    break;

                case "ownerpublished":
                    server.OwnerPublishedChannel = 0;
                    label = "Owner Published";
                    break;

                case "published":
                    server.PublishedChannel = 0;
                    label = "Published";
                    break;

                case "ownertwitchfeed":
                    server.OwnerTwitchFeedChannel = 0;
                    label = "Owner Twitch Feed";
                    break;

                case "twitchfeed":
                    server.TwitchFeedChannel = 0;
                    label = "Twitch Feed";
                    break;

                case "all":
                    server.AnnouncementsChannel   = 0;
                    server.GoLiveChannel          = 0;
                    server.GreetingsChannel       = 0;
                    server.PublishedChannel       = 0;
                    server.OwnerPublishedChannel  = 0;
                    server.OwnerLiveChannel       = 0;
                    server.OwnerTwitchFeedChannel = 0;
                    server.TwitchFeedChannel      = 0;
                    label = "All";
                    break;

                default:
                    break;
                }

                if (!string.IsNullOrEmpty(label))
                {
                    await BotFiles.SaveDiscordServer(server, Context.Guild);

                    await Context.Channel.SendMessageAsync(label + " settings have been reset.");
                }
            }
        }
Ejemplo n.º 28
0
        public async Task Add(string channelName)
        {
            if (!IsApprovedAdmin)
            {
                return;
            }

            var channel = await _mixerManager.GetChannelByName(channelName);

            if (channel == null)
            {
                await Context.Channel.SendMessageAsync("The Mixer channel, " + channelName + ", does not exist.");

                return;
            }

            var           file   = Constants.ConfigRootDirectory + Constants.GuildDirectory + Context.Guild.Id + ".json";
            DiscordServer server = null;

            if (File.Exists(file))
            {
                server = JsonConvert.DeserializeObject <DiscordServer>(File.ReadAllText(file));
            }

            if (server == null)
            {
                return;
            }

            if (server.ServerBeamChannels == null)
            {
                server.ServerBeamChannels = new List <string>();
            }

            if (server.ServerBeamChannelIds == null)
            {
                server.ServerBeamChannelIds = new List <string>();
            }

            if (!string.IsNullOrEmpty(server.OwnerBeamChannel) && server.OwnerBeamChannel.ToLower().Equals(channelName.ToLower()))
            {
                await Context.Channel.SendMessageAsync("The channel " + channelName + " is configured as the Owner Mixer channel. " +
                                                       "Please remove it with the '!cb mixer resetowner' command and then try re-adding it.");

                return;
            }

            if (!server.ServerBeamChannels.Contains(channelName.ToLower()))
            {
                server.ServerBeamChannels.Add(channelName.ToLower());
                server.ServerBeamChannelIds.Add(channel.id.Value.ToString());

                if (Constants.EnableMixer)
                {
                    await Program.beamClient.SubscribeToLiveAnnouncements(channel.id.Value.ToString());

                    if (channel.online)
                    {
                        await Announce(channel.token);
                    }
                }

                await BotFiles.SaveDiscordServer(server, Context.Guild);

                await Context.Channel.SendMessageAsync("Added " + channelName + " to the server Mixer streamer list.");
            }
            else
            {
                await Context.Channel.SendMessageAsync(channelName + " is already on the server Mixer streamer list.");
            }
        }