Exemple #1
0
        public async Task Play(CommandContext commandContext,
                               [Description("THe Sound Group to play audio from")] string group = DefaultStringValue,
                               [Description("The Sound Bite to play")] string bite = DefaultStringValue)
        {
            DiscordChannel discordChannel = commandContext.Member.VoiceState.Channel;
            bool           nsfw           = discordChannel.Name.Contains("NSFW", StringComparison.OrdinalIgnoreCase);

            group = HandleDefaultStringValue(group);
            string biteFileMini = null;

            if (group == null)
            {
                biteFileMini = Instance.GetRandomSoundBite(nsfw);
            }
            else if (Instance.GetSoundGroup(group) is SoundGroup soundGroup)
            {
                if (soundGroup.NSFW && !nsfw)
                {
                    await commandContext.RespondAsync("Unable to play from this Sound Group, you must be in a NSFW voice channel");
                }
                else
                {
                    bite = HandleDefaultStringValue(bite);
                    if (bite == null)
                    {
                        biteFileMini = soundGroup.Random();
                    }
                    else
                    {
                        biteFileMini = soundGroup.GetBite(bite);
                        if (biteFileMini == null)
                        {
                            await commandContext.RespondAsync($"Unable to find Sound Bite '{bite}'");
                        }
                    }
                }
            }
            else
            {
                DiscordEmbedBuilder discordEmbedBuilder = Instance.GetDiscordEmbedBuilder()
                                                          .WithTitle("Current Sound Groups")
                                                          .WithDescription(string.Join(Environment.NewLine, Instance.SoundGroups.Keys));

                await commandContext.RespondAsync("Unable to find Sound Group", embed : discordEmbedBuilder.Build());
            }

            if (biteFileMini != null)
            {
                GuildAudioManager guildAudioManager = AudioManager.GetOrCreateGuildAudioManager(commandContext.Guild);
                guildAudioManager.Enqueue(new AudioInfo(biteFileMini, commandContext));
                await guildAudioManager.CreatePlayerAsync(discordChannel);

                await guildAudioManager.PlayAsync();
            }
        }
Exemple #2
0
        public async Task PlayAll(CommandContext commandContext)
        {
            DiscordChannel    discordChannel    = commandContext.Member.VoiceState.Channel;
            GuildAudioManager guildAudioManager = AudioManager.GetOrCreateGuildAudioManager(commandContext.Guild);
            await guildAudioManager.CreatePlayerAsync(discordChannel);

            foreach (SoundGroup soundGroup in Instance.SoundGroups.Values)
            {
                foreach (string item in soundGroup.SoundBites)
                {
                    guildAudioManager.Enqueue(new AudioInfo($"{soundGroup.FolderName}\\{item}", commandContext));
                }
            }
            await guildAudioManager.PlayAsync();
        }