Search in sources :

Example 1 with GuildMusicManager

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);
    }
}
Also used : GuildModel(tk.ardentbot.rethink.models.GuildModel) GuildMusicManager(tk.ardentbot.commands.music.GuildMusicManager) Shard(tk.ardentbot.main.Shard) SubscribeEvent(net.dv8tion.jda.core.hooks.SubscribeEvent)

Example 2 with GuildMusicManager

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);
    }
}
Also used : GuildMusicManager(tk.ardentbot.commands.music.GuildMusicManager) Command(tk.ardentbot.core.executor.Command) net.dv8tion.jda.core.entities(net.dv8tion.jda.core.entities) Staff(tk.ardentbot.rethink.models.Staff) Database.r(tk.ardentbot.rethink.Database.r) Profile(tk.ardentbot.utils.rpg.profiles.Profile) BotException(tk.ardentbot.core.misc.logging.BotException) Shard(tk.ardentbot.main.Shard) Executors(java.util.concurrent.Executors) UsageUtils(tk.ardentbot.utils.discord.UsageUtils) TimeUnit(java.util.concurrent.TimeUnit) GuildUtils(tk.ardentbot.utils.discord.GuildUtils) List(java.util.List) ShardManager.getShards(tk.ardentbot.main.ShardManager.getShards) Music(tk.ardentbot.commands.music.Music) Database.connection(tk.ardentbot.rethink.Database.connection) Map(java.util.Map) InternalStats(tk.ardentbot.utils.discord.InternalStats) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Ardent(tk.ardentbot.main.Ardent) GuildMusicManager(tk.ardentbot.commands.music.GuildMusicManager) Shard(tk.ardentbot.main.Shard)

Aggregations

GuildMusicManager (tk.ardentbot.commands.music.GuildMusicManager)2 Shard (tk.ardentbot.main.Shard)2 List (java.util.List)1 Map (java.util.Map)1 Executors (java.util.concurrent.Executors)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 TimeUnit (java.util.concurrent.TimeUnit)1 net.dv8tion.jda.core.entities (net.dv8tion.jda.core.entities)1 SubscribeEvent (net.dv8tion.jda.core.hooks.SubscribeEvent)1 Music (tk.ardentbot.commands.music.Music)1 Command (tk.ardentbot.core.executor.Command)1 BotException (tk.ardentbot.core.misc.logging.BotException)1 Ardent (tk.ardentbot.main.Ardent)1 ShardManager.getShards (tk.ardentbot.main.ShardManager.getShards)1 Database.connection (tk.ardentbot.rethink.Database.connection)1 Database.r (tk.ardentbot.rethink.Database.r)1 GuildModel (tk.ardentbot.rethink.models.GuildModel)1 Staff (tk.ardentbot.rethink.models.Staff)1 GuildUtils (tk.ardentbot.utils.discord.GuildUtils)1 InternalStats (tk.ardentbot.utils.discord.InternalStats)1