本文整理汇总了Java中sx.blah.discord.api.events.EventDispatcher类的典型用法代码示例。如果您正苦于以下问题:Java EventDispatcher类的具体用法?Java EventDispatcher怎么用?Java EventDispatcher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EventDispatcher类属于sx.blah.discord.api.events包,在下文中一共展示了EventDispatcher类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import sx.blah.discord.api.events.EventDispatcher; //导入依赖的package包/类
@Override
public void run(String... arg0) throws Exception
{
IDiscordClient client;
ClientBuilder clientBuilder = new ClientBuilder();
clientBuilder.withToken(token);
try
{
client = clientBuilder.login();
EventDispatcher dispatcher = client.getDispatcher();
dispatcher.registerListener(new LeaderboardDiscordActions(client, prefix, leaderboardDao, leaderboardColumnDao));
}
catch (DiscordException e)
{
e.printStackTrace();
System.exit(0);
}
}
示例2: start
import sx.blah.discord.api.events.EventDispatcher; //导入依赖的package包/类
void start(String[] args) {
if(!loadProperties()) {
logger.error("Error loading properties. Make sure Bot.properties exists");
System.exit(0);
}
bot = getClient(secret);
// This makes the prune command a bit better on startup, but might mess with memory usage
// when server count gets high
MessageList.setEfficiency(bot, EfficiencyLevel.NONE);
EventDispatcher dispatcher = bot.getDispatcher();
dispatcher.registerListener(new AudioListeners());
dispatcher.registerListener(new VoiceChannelListeners());
dispatcher.registerListener(new ModLogListeners());
dispatcher.registerListener(new Listeners());
dispatcher.registerListener(new AdvancedLogListeners());
JobScheduler.initializeScheduler();
}
示例3: main
import sx.blah.discord.api.events.EventDispatcher; //导入依赖的package包/类
public static void main(String[] args) throws OAuthException {
IDiscordClient client = Discord.createClient(Keys.DiscordBotToken, true);
EventDispatcher dispatcher = client.getDispatcher(); // Gets the EventDispatcher instance for this client instance
dispatcher.registerListener(new InterfaceListener()); // Registers the IListener example class from above
CommandHandler handler = new Discord4JHandler(client);
handler.setDefaultPrefix("~");
handler.registerCommand(new PastaCommand());
handler.registerCommand(new JokeCommand());
handler.registerCommand(new KahootCommand());
handler.registerCommand(new HelpCommand(handler));
}
示例4: start0
import sx.blah.discord.api.events.EventDispatcher; //导入依赖的package包/类
private void start0() {
EventDispatcher dispatcher = getClient().getDispatcher();
Set<Listener> listeners = library.getListeners();
if(listeners == null || listeners.isEmpty()) {
LOGGER.info("No listeners found.. This bot will not do anything");
}
for(Listener l : listeners) {
dispatcher.registerListener(l);
LOGGER.info("Registered Listener --> {}", l.getName());
}
}
示例5: IListenerAdaptor
import sx.blah.discord.api.events.EventDispatcher; //导入依赖的package包/类
IListenerAdaptor(EventDispatcher dispatcher) {
this.dispatcher = dispatcher;
dispatcher.registerListener(new IListener() {
@Override
public void handle(Event event) {
emitters.forEach(emitter -> emitter.onNext(event));
}
});
}
示例6: IListenerAdaptor
import sx.blah.discord.api.events.EventDispatcher; //导入依赖的package包/类
IListenerAdaptor(EventDispatcher dispatcher) {
this.dispatcher = dispatcher;
dispatcher.registerListener(new IListener() {
@Override
public void handle(Event event) {
sinks.forEach(sink -> sink.next(event));
}
});
}
示例7: initDiscord
import sx.blah.discord.api.events.EventDispatcher; //导入依赖的package包/类
public void initDiscord(){
//Init lavaplayer
Karren.log.info("Starting up Lavaplayer...");
gms = new HashMap<>();
AudioSourceManagers.registerRemoteSources(pm);
AudioSourceManagers.registerLocalSource(pm);
//Continue connecting to discord
if(Karren.conf.getConnectToDiscord()) {
EventDispatcher ed = client.getDispatcher();
ed.registerListener(new ConnectCommand());
try {
client.login();
} catch (DiscordException | RateLimitException e) {
e.printStackTrace();
}
ed.registerListener(new HelpCommand());
ed.registerListener(interactionListener);
ed.registerListener(new KillCommand());
ed.registerListener(new GuildCreateListener());
ed.registerListener(new ShutdownListener());
ed.registerListener(new ReconnectListener());
ed.registerListener(new StatCommand());
initExtras();
} else {
Karren.log.info("Running in test mode, not connected to Discord.");
initExtras();
//Init interaction processor
}
}
示例8: main
import sx.blah.discord.api.events.EventDispatcher; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
//Get bot settings
Properties p = new Properties();
p.load(new FileReader(new File("settings.properties")));
BotSettings.init(p);
client = createClient(BotSettings.TOKEN.get());
if (client == null)
throw new NullPointerException("Failed to log in! Client cannot be null!");
UpdateListData.init();
Authorization.getAuth().init();
//Connect to MySQL
DatabaseManager.getManager().connectToMySQL();
DatabaseManager.getManager().createTables();
//Start spark (catch any issues from it so only the site goes down without affecting bot....
try {
SparkUtils.initSpark();
} catch (Exception e) {
ExceptionHandler.sendException(null, "'Spark ERROR' by 'PANIC! AT THE WEBSITE'", e, Main.class);
}
//Register events
EventDispatcher dispatcher = client.getDispatcher();
dispatcher.registerListener(new ReadyEventListener());
//Register modules
CommandExecutor executor = CommandExecutor.getExecutor().enable();
executor.registerCommand(new HelpCommand());
executor.registerCommand(new DisCalCommand());
executor.registerCommand(new CalendarCommand());
executor.registerCommand(new AddCalendarCommand());
executor.registerCommand(new LinkCalendarCommand());
executor.registerCommand(new TimeCommand());
executor.registerCommand(new EventListCommand());
executor.registerCommand(new EventCommand());
executor.registerCommand(new RsvpCommand());
executor.registerCommand(new AnnouncementCommand());
executor.registerCommand(new DevCommand());
//Load language files.
MessageManager.loadLangs();
//Accept commands
ConsoleCommandExecutor.init();
}
示例9: enable
import sx.blah.discord.api.events.EventDispatcher; //导入依赖的package包/类
/**
* Enables the CommandExecutor and sets up the Listener.
* @return The CommandExecutor's instance.
*/
public CommandExecutor enable() {
EventDispatcher dispatcher = Main.client.getDispatcher();
dispatcher.registerListener(new CommandListener(this));
return instance;
}
示例10: DefaultEventAdapter
import sx.blah.discord.api.events.EventDispatcher; //导入依赖的package包/类
DefaultEventAdapter(EventDispatcher dispatcher) {
this.dispatcher = dispatcher;
}
示例11: PublisherListener
import sx.blah.discord.api.events.EventDispatcher; //导入依赖的package包/类
PublisherListener(EventDispatcher dispatcher, Class<E> clazz) {this.dispatcher = dispatcher;
this.clazz = clazz;
}
示例12: RxJavaEventAdapter
import sx.blah.discord.api.events.EventDispatcher; //导入依赖的package包/类
public RxJavaEventAdapter(EventDispatcher dispatcher) {
this.dispatcher = dispatcher;
eventFlowable = Flowable.create(new IListenerAdaptor(dispatcher), BackpressureStrategy.BUFFER);
}
示例13: ReactorEventAdapter
import sx.blah.discord.api.events.EventDispatcher; //导入依赖的package包/类
public ReactorEventAdapter(EventDispatcher dispatcher) {
this.dispatcher = dispatcher;
flux = Flux.create(new IListenerAdaptor(dispatcher), FluxSink.OverflowStrategy.BUFFER);
}
示例14: newDefaultAdapter
import sx.blah.discord.api.events.EventDispatcher; //导入依赖的package包/类
/**
* This generates an implementation of {@link IEventAdapter} using only default Reactive Streams interfaces.
* This is not recommended! Use a proper implementation like for RxJava or Reactor.
*
* @param dispatcher The dispatcher to wrap.
* @return The new adapter.
*/
static IEventAdapter newDefaultAdapter(EventDispatcher dispatcher) {
return new DefaultEventAdapter(dispatcher);
}