Пример #1
0
        public static async void PostVetRequestToDJChannel(SongData songData)
        {
            RequestPosting = true;
            string messageContent = $"**Request from {songData.Requestor}:**\n{songData.URL}";
            ulong  messageID      = await DJVettingChannelWebhook.SendMessageAsync(text : messageContent);

            RequestMap[messageID] = songData;
            RequestPosting        = false;
        }
Пример #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();
                }
            }
        }