Search in sources :

Example 1 with MusicSettingsModel

use of tk.ardentbot.rethink.models.MusicSettingsModel in project Ardent by adamint.

the class Music method getOutputChannel.

static TextChannel getOutputChannel(Guild guild) throws SQLException {
    String id;
    MusicSettingsModel guildMusicSettings = BaseCommand.asPojo(r.db("data").table("music_settings").get(guild.getId()).run(connection), MusicSettingsModel.class);
    if (guildMusicSettings != null) {
        String setId = guildMusicSettings.getChannel_id();
        if (setId.equalsIgnoreCase("none"))
            id = null;
        else
            id = setId;
    } else {
        id = null;
        r.db("data").table("music_settings").insert(r.json(getStaticGson().toJson(new MusicSettingsModel(guild.getId(), false, "none")))).run(connection);
    }
    if (id == null || id.length() < 5)
        return null;
    else
        return guild.getTextChannelById(id);
}
Also used : MusicSettingsModel(tk.ardentbot.rethink.models.MusicSettingsModel)

Example 2 with MusicSettingsModel

use of tk.ardentbot.rethink.models.MusicSettingsModel in project Ardent by adamint.

the class ArdentMusicManager method setChannel.

public void setChannel(MessageChannel channel) {
    assert channel != null;
    this.channel = channel.getId();
    MusicSettingsModel guildMusicSettings = BaseCommand.asPojo(r.db("data").table("music_settings").get(((TextChannel) channel).getGuild().getId()).run(connection), MusicSettingsModel.class);
    shouldAnnounce = !(guildMusicSettings == null || !guildMusicSettings.announce_music);
}
Also used : TextChannel(net.dv8tion.jda.core.entities.TextChannel) MusicSettingsModel(tk.ardentbot.rethink.models.MusicSettingsModel)

Example 3 with MusicSettingsModel

use of tk.ardentbot.rethink.models.MusicSettingsModel in project Ardent by adamint.

the class Music method shouldDeleteMessages.

static boolean shouldDeleteMessages(Guild guild) throws SQLException {
    boolean returnValue = false;
    MusicSettingsModel musicSettingsModel = asPojo(r.db("data").table("music_settings").get(guild.getId()).run(connection), MusicSettingsModel.class);
    if (musicSettingsModel != null) {
        if (musicSettingsModel.isRemove_addition_messages())
            returnValue = true;
    }
    return returnValue;
}
Also used : MusicSettingsModel(tk.ardentbot.rethink.models.MusicSettingsModel)

Example 4 with MusicSettingsModel

use of tk.ardentbot.rethink.models.MusicSettingsModel in project Ardent by adamint.

the class MusicConfig method noArgs.

@Override
public void noArgs(Guild guild, MessageChannel channel, User user, Message message, String[] args) throws Exception {
    Cursor<HashMap> settings = r.db("data").table("music_settings").filter(row -> row.g("guild_id").eq(guild.getId())).run(connection);
    if (settings.hasNext()) {
        MusicSettingsModel musicSettingsModel = asPojo(settings.next(), MusicSettingsModel.class);
        sendTranslatedMessage("**music Settings**\n" + "Delete music play messages: " + musicSettingsModel.isRemove_addition_messages(), channel, user);
    } else
        sendTranslatedMessage("Your guild has no set music settings! Type **/manage** to find your portal" + " link", channel, user);
}
Also used : Guild(net.dv8tion.jda.core.entities.Guild) Cursor(com.rethinkdb.net.Cursor) User(net.dv8tion.jda.core.entities.User) Command(tk.ardentbot.core.executor.Command) MusicSettingsModel(tk.ardentbot.rethink.models.MusicSettingsModel) Database.connection(tk.ardentbot.rethink.Database.connection) Database.r(tk.ardentbot.rethink.Database.r) HashMap(java.util.HashMap) MessageChannel(net.dv8tion.jda.core.entities.MessageChannel) Message(net.dv8tion.jda.core.entities.Message) HashMap(java.util.HashMap) MusicSettingsModel(tk.ardentbot.rethink.models.MusicSettingsModel)

Aggregations

MusicSettingsModel (tk.ardentbot.rethink.models.MusicSettingsModel)4 Cursor (com.rethinkdb.net.Cursor)1 HashMap (java.util.HashMap)1 Guild (net.dv8tion.jda.core.entities.Guild)1 Message (net.dv8tion.jda.core.entities.Message)1 MessageChannel (net.dv8tion.jda.core.entities.MessageChannel)1 TextChannel (net.dv8tion.jda.core.entities.TextChannel)1 User (net.dv8tion.jda.core.entities.User)1 Command (tk.ardentbot.core.executor.Command)1 Database.connection (tk.ardentbot.rethink.Database.connection)1 Database.r (tk.ardentbot.rethink.Database.r)1