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).

1  
!7
2  
3  
!include once #1025344 // Discord Audio
4  
5  
cmodule DiscordAudioSpike > DynTalkBot2 {
6  
  S myName = "Discord Audio Spike";
7  
  S radioURL = "http://s3.free-shoutcast.com:18162/;?type=http&nocache=<RNDINT>";
8  
  
9  
  start {
10  
    makeByServer = () -> new ByServer;
11  
    useAGIBlueForDropPunctuation = false;
12  
    preprocessAtSelfToMyName = false;
13  
  }
14  
15  
  class ByServer extends DynTalkBot2.ByServer {
16  
    transient AudioPlayer player;
17  
    
18  
    synchronized S processSimplifiedLine(S s, O... _) {
19  
      try answer super.processSimplifiedLine(s, _); // adding authorized users etc.
20  
      new Matches m;
21  
      if null (s = dropMyPrefixOrNull(s)) null;
22  
      optPar Message msg;
23  
      Guild guild = msg == null ? null : msg.getGuild();
24  
      
25  
      if "voice channels"
26  
        ret str(guild.getVoiceChannels());
27  
        
28  
      if "start radio"
29  
        ret joinVoiceChannel(first(guild.getVoiceChannels());
30  
        
31  
      if "stop radio" {
32  
        if (player != null) {
33  
          player.stopTrack();
34  
          ret "Yo";
35  
        }
36  
        ret "I am stopped, I think. No?";
37  
      }
38  
39  
      if (eqic(s, "help"))
40  
        ret ltrim([[
41  
I'm a Discord Audio Test
42  
43  
[Bot made by https://BotCompany.de]
44  
  ]]).replace("@me", atSelf());
45  
  
46  
      null;
47  
    }
48  
    
49  
    S joinVoiceChannel(VoiceChannel vc) {
50  
      if (vc == null) ret "No channel";
51  
      
52  
      Guild guild = vc.getGuild();
53  
      AudioManager am = guild.getAudioManager();
54  
      
55  
      AudioPlayerManager playerManager = lavaPlayer_playerManager();
56  
      player = playerManager.createPlayer();
57  
      lavaPlayer_printPlayerEvents(player);
58  
      
59  
      am.setSendingHandler(new JDA_AudioPlayerSendHandler(player));
60  
      am.openAudioConnection(vc);
61  
      
62  
      lavaPlayer_loadItem(module(), playerManager, player, radioURL.replace("<RNDINT>", str(randomInt())));
63  
      
64  
      ret "Playing radio in " + vc.getName();
65  
    }
66  
  }
67  
}

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: 294 / 3783
Version history: 13 change(s)
Referenced in: [show references]