Example #1
0
        public static string FillSongRequest(string requestBody, string songRequestor = "RazBot", bool bypassVet = false)
        {
            SongData songData = YTE.GetSongData(requestBody, requestor: songRequestor);

            if (songData.Duration <= TimeSpan.FromMinutes(10))
            {
                if (BotTools.Settings["vet_requests"] && !bypassVet)
                {
                    DiscordBot.PostVetRequestToDJChannel(songData);
                    return($"@{songData.Requestor}, Your request has been submitted for review! razBot");
                }
                else
                {
                    try
                    {
                        Music.GetPlaylist("request").AddSong(songData);
                        var placement = Music.GetPlaylist("request").Songs.Count;
                        if (DownloadedSong != null && placement == 1)
                        {
                            if (DownloadedSong.IsRequest)
                            {
                                placement++;
                            }
                            else
                            {
                                DownloadedSong = null;
                                GetPlaylist(LoadedPlaylist).CycleBack();
                            }
                        }
                        var placementWord = BotTools.GetPlacementWord(placement);

                        Music.SavePlaylists();
                        return($"@{songData.Requestor}, Your request is {placementWord} in the queue! razCool");
                    }
                    catch (ArgumentException)
                    {
                        BotTools.LogLine($"{songRequestor}'s request rejected: Already in queue");
                        return($"Sorry @{songRequestor}, that request is already queued!");
                    }
                    catch (FormatException e)
                    {
                        BotTools.LogToSessionLogFile(e.ToString());
                        BotTools.LogLine($"{songRequestor}'s request rejected: Bad url");
                        return($"Sorry @{songRequestor}, I can't access a YouTube video from that link! It may not be available in my region, or the url may not be properly formatted.");
                    }
                }
            }
            else
            {
                return($"{songData.Requestor}'s request was rejected: The audio was over 10 minutes long! razS");
            }
        }
Example #2
0
        private static async Task Client_OnReactionAdded(Cacheable <IUserMessage, ulong> cache, ISocketMessageChannel channel, SocketReaction reaction)
        {
            var message = await cache.GetOrDownloadAsync();

            if (!reaction.User.Value.IsBot && RequestMap.ContainsKey(message.Id))
            {
                SongData songData = RequestMap[message.Id];
                if (reaction.Emote.Name == "👍")
                {
                    BotTools.LogLine($"{songData.Requestor}'s request was approved by {reaction.User.Value.Username}");
                    await DJVettingChannelWebhook.SendMessageAsync($"*{songData.Requestor}'s request was approved by {reaction.User.Value.Username}*");

                    RequestMap.Remove(message.Id);
                    try
                    {
                        Music.GetPlaylist("request").AddSong(songData);
                        var placement     = Music.GetPlaylist("request").Songs.Count;
                        var placementWord = BotTools.GetPlacementWord(placement);
                        TwitchBot.SendMessage($"@{songData.Requestor}, Your request is {placementWord} in the queue! razCool");
                        Music.QueuedSong = Music.DownloadedSong = null;
                        Music.SavePlaylists();
                        await message.RemoveAllReactionsAsync();
                    }
                    catch (ArgumentException)
                    {
                        BotTools.LogLine($"{songData.Requestor}'s request rejected: Already in queue");
                        TwitchBot.SendMessage($"Sorry @{songData.Requestor}, that request is already queued!");
                    }
                    catch (FormatException)
                    {
                        BotTools.LogLine($"{songData.Requestor}'s request rejected: Bad url");
                        TwitchBot.SendMessage($"Sorry @{songData.Requestor}, I can't access any video with that url!");
                    }
                }
                else if (reaction.Emote.Name == "👎")
                {
                    BotTools.LogLine($"{RequestMap[message.Id].Requestor}'s request was declined by {reaction.User.Value.Username}");
                    await DJVettingChannelWebhook.SendMessageAsync($"*{RequestMap[message.Id].Requestor}'s request was declined by {reaction.User.Value.Username}*");

                    TwitchBot.SendMessage($"@{songData.Requestor}, Your request was declined! razHands");
                    RequestMap.Remove(message.Id);
                    await message.RemoveAllReactionsAsync();
                }
            }
        }