!7 !include once #1025344 // Discord Audio cmodule DiscordAudioSpike > DynTalkBot2 { S myName = "Discord Audio Spike"; S radioURL = "http://s3.free-shoutcast.com:18162/;?type=http&nocache="; start { makeByServer = () -> new ByServer; useAGIBlueForDropPunctuation = false; preprocessAtSelfToMyName = false; } class ByServer extends DynTalkBot2.ByServer { transient AudioPlayer player; synchronized S processSimplifiedLine(S s, O... _) { try answer super.processSimplifiedLine(s, _); // adding authorized users etc. new Matches m; if null (s = dropMyPrefixOrNull(s)) null; optPar Message msg; Guild guild = msg == null ? null : msg.getGuild(); if "voice channels" ret str(guild.getVoiceChannels()); if "start radio" ret joinVoiceChannel(first(guild.getVoiceChannels()); if "stop radio" { if (player != null) { player.stopTrack(); ret "Yo"; } ret "I am stopped, I think. No?"; } if (eqic(s, "help")) ret ltrim([[ I'm a Discord Audio Test [Bot made by https://BotCompany.de] ]]).replace("@me", atSelf()); null; } S joinVoiceChannel(VoiceChannel vc) { if (vc == null) ret "No channel"; Guild guild = vc.getGuild(); AudioManager am = guild.getAudioManager(); AudioPlayerManager playerManager = lavaPlayer_playerManager(); player = playerManager.createPlayer(); lavaPlayer_printPlayerEvents(player); am.setSendingHandler(new JDA_AudioPlayerSendHandler(player)); am.openAudioConnection(vc); lavaPlayer_loadItem(module(), playerManager, player, radioURL.replace("", str(randomInt()))); ret "Playing radio in " + vc.getName(); } } }