Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

67
LINES

< > BotCompany Repo | #1025341 - Gazelle Radio (Discord Radio Spike)

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 34242K of libraries. Click here for Pure Java version (14047L/75K).

!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=<RNDINT>";
  
  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("<RNDINT>", str(randomInt())));
      
      ret "Playing radio in " + vc.getName();
    }
  }
}

Author comment

Began life as a copy of #1025322

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1025341
Snippet name: Gazelle Radio (Discord Radio Spike)
Eternal ID of this version: #1025341/14
Text MD5: 0898c22217e9ea64616611f5a927a61c
Transpilation MD5: 9292b8eeef2df1ddc88e429b95d1fd96
Author: stefan
Category: javax
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-10-17 12:07:12
Source code size: 1925 bytes / 67 lines
Pitched / IR pitched: No / No
Views / Downloads: 135 / 3368
Version history: 13 change(s)
Referenced in: [show references]