Exemplo n.º 1
0
 public async Task Local([Remainder] string song)
 {
     if (!Program.Guilds.GetValueOrDefault(Context.Guild.Id).Music || Context.Message.Author.Id != Program.OwnerID)
     {
         await Context.Channel.SendMessageAsync("", false, Embed.GetEmbed("Music", "This guild is not authorised to use music")); return;
     }
     if (File.Exists(song))
     {
         var    fa = File.GetAttributes(song);
         string name;
         var    tmp2 = GetSong(song);
         if (tmp2 != null)
         {
             name = tmp2;
         }
         else
         {
             name = Path.GetFileNameWithoutExtension(song);
         }
         await service.AddToQueue(Context.Guild, Context.Channel, song, name);
     }
     else
     {
         await ReplyAsync("", false, Embed.GetEmbed("Music", "Couldn't find local file"));
     }
 }
Exemplo n.º 2
0
        public async Task OutputLegacyGlobalAudio(
            ICommandContext Context,
            IGuild guild,
            IMessageChannel channel,
            IUserMessage display,
            string url)
        {
            if (CurrentChannels.TryGetValue(guild.Id, out IAudioClient client))
            {
                var audioInfo = RetrieveAudioInformation(url);
                if (!File.Exists($"{songPath}{audioInfo.Item4}"))
                {
                    DownloadRequestedAudio(guild, url);
                }

                var previousEmbed = new EmbedBuilder();
                foreach (var embed in display.Embeds)
                {
                    previousEmbed = embed.ToEmbedBuilder(); break;
                }
                previousEmbed.WithColor(129, 243, 193);
                previousEmbed.WithTitle($"Song downloaded.");
                previousEmbed.WithDescription($"`{audioInfo.Item1}`");

                var songInfo = new AudioService.QueueStructure
                {
                    Title      = audioInfo.Item1,
                    Id         = audioInfo.Item2,
                    Duration   = audioInfo.Item3,
                    Requestant = Context.User.Username
                };
                data.AddToQueue(guild, audioInfo.Item4, songInfo);

                if (Queue(guild).Count > 0)
                {
                    previousEmbed.WithDescription($"`{audioInfo.Item1}`\nhas been placed in slot {data.GetQueue(guild).Count - 1}.");
                    await display.ModifyAsync(x => { x.Embed = previousEmbed.Build(); });

                    return;
                }

                await display.ModifyAsync(x => { x.Embed = previousEmbed.Build(); });
                await CheckQueue(guild, channel, display);
            }
            else
            {
                await channel.SendMessageAsync("`I need to connect to an audio channel to be able to play music.`");
            }
        }
Exemplo n.º 3
0
        public async Task Queue(
            [Summary("Link of the youtube song!")] string link,
            [Summary("should this song be looped in queue")] bool saveToplayList = false
            )
        {
            var addedItem = _audioService.AddToQueue(link, Context.User, saveToplayList);

            if (addedItem != null)
            {
                Replay($"{ addedItem.Name } - Added to queue!");
            }
            else
            {
                Replay($"{ link } - was not able to be processed!");
            }
        }