use of tk.ardentbot.commands.music.GuildMusicManager in project Ardent by adamint.
the class Join method onJoin.
@SubscribeEvent
public void onJoin(GuildJoinEvent event) {
Guild guild = event.getGuild();
Shard shard = GuildUtils.getShard(guild);
Cursor<GuildModel> guilds = r.db("data").table("guilds").filter(r.hashMap("guild_id", guild.getId())).run(connection);
if (!guilds.hasNext()) {
TextChannel channel = guild.getPublicChannel();
channel.sendMessage(welcomeText).queue();
r.db("data").table("guilds").insert(r.hashMap("guild_id", guild.getId()).with("language", "english").with("prefix", "/").with("role_permissions", new ArrayList<>())).run(connection);
String prefix = "/";
shard.botPrefixData.set(guild, prefix);
botJoinEvents.add(Instant.now());
Status.commandsByGuild.put(guild.getId(), 0);
shard.musicManagers.put(Long.parseLong(guild.getId()), new GuildMusicManager(shard.playerManager, null));
Ardent.cleverbots.put(guild.getId(), shard.cleverBot.createSession());
Ardent.sentAnnouncement.put(guild.getId(), false);
Status.commandsByGuild.put(guild.getId(), 0);
shard.executorService.schedule(() -> {
guild.getOwner().getUser().openPrivateChannel().queue(privateChannel -> privateChannel.sendMessage("Thanks for adding Ardent. If you have questions or something isn't working, join over 300 people on our" + " support server @ https://discordapp.com/invite/rfGSxNA").queue());
}, 3, TimeUnit.SECONDS);
}
}
use of tk.ardentbot.commands.music.GuildMusicManager in project Ardent by adamint.
the class Admin method update.
public static void update(Command command, MessageChannel channel) throws Exception {
channel.sendMessage("Updating now!").queue();
for (Shard shard : getShards()) {
for (Guild g : shard.jda.getGuilds()) {
if (g.getAudioManager().isConnected()) {
GuildMusicManager manager = Music.getGuildAudioPlayer(g, null);
TextChannel ch = manager.scheduler.manager.getChannel();
if (ch == null) {
g.getPublicChannel().sendMessage("I'm restarting in **5** minutes for updates!").queue();
} else {
ch.sendMessage("I'm restarting in **5** minutes for updates!").queue();
}
}
}
shard.executorService.schedule(() -> {
shard.jda.getGuilds().stream().filter(g -> g.getAudioManager().isConnected()).forEach(g -> {
GuildMusicManager manager = Music.getGuildAudioPlayer(g, null);
TextChannel ch = manager.scheduler.manager.getChannel();
if (ch == null) {
g.getPublicChannel().sendMessage("Updating, I'll be online in a minute!").queue();
} else {
ch.sendMessage("Updating, I'll be online in a minute!").queue();
}
});
shutdown();
}, 4, TimeUnit.MINUTES);
}
}
Aggregations