Skip to content

Commit

Permalink
Added political compass meme command
Browse files Browse the repository at this point in the history
  • Loading branch information
TrackRunny committed Apr 5, 2021
1 parent fd3fadc commit ba0770e
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {

mainClassName = 'me.trackrunny.jdalearning.Bot'

version '1.41.10'
version '1.42.10'

sourceCompatibility = JavaVersion.VERSION_1_8

Expand Down
4 changes: 1 addition & 3 deletions src/main/java/me/trackrunny/jdalearning/Bot.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@

package me.trackrunny.jdalearning;

import jdk.nashorn.internal.scripts.JD;
import me.duncte123.botcommons.web.WebUtils;
import me.trackrunny.jdalearning.database.SQLiteDataSource;
import net.dv8tion.jda.api.AccountType;
import net.dv8tion.jda.api.JDABuilder;
import net.dv8tion.jda.api.OnlineStatus;
import net.dv8tion.jda.api.entities.Activity;
Expand All @@ -43,7 +41,7 @@ public static void main(String[] args) throws LoginException, SQLException {

SQLiteDataSource.getConnection();

JDABuilder.createDefault(Config.get("token"))
JDABuilder.createDefault(Config.get("TOKEN"))
.addEventListeners(new Listener())
.setActivity(Activity.watching("Gradle 6.4 — \uD83D\uDC18"))
.setStatus(OnlineStatus.ONLINE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public CommandManager() {
addCommand(new MinecraftMemeCommand());
addCommand(new BlackTwitterMeme());
addCommand(new WooshMemeCommand());
addCommand(new PoliticalCompassMemeCommand());
}

private void addCommand(ICommand cmd) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/trackrunny/jdalearning/Listener.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,6 @@ private String getPrefix(long guildId) {
e.printStackTrace();
}

return Config.get("prefix");
return Config.get("PREFIX");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@

package me.trackrunny.jdalearning.command.commands.meme;

import me.trackrunny.jdalearning.Config;
import me.trackrunny.jdalearning.Bot;
import me.trackrunny.jdalearning.command.CommandContext;
import me.trackrunny.jdalearning.command.ICommand;
import me.trackrunny.jdalearning.variables.Variables;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.MessageEmbed;
import net.dv8tion.jda.api.entities.TextChannel;
import net.explodingbush.ksoftapi.KSoftAPI;
import net.explodingbush.ksoftapi.entities.Reddit;
import net.explodingbush.ksoftapi.enums.ImageType;

Expand All @@ -38,8 +37,7 @@ public void handle(CommandContext ctx) {

final EmbedBuilder embedBuilder = new EmbedBuilder();

final KSoftAPI kSoftAPI = new KSoftAPI(Config.get("KSOFT_TOKEN"));
final Reddit reddit = kSoftAPI.getRedditImage(ImageType.RANDOM_REDDIT).setSubreddit("MinecraftMemes").execute();
final Reddit reddit = Bot.kSoftAPI.getRedditImage(ImageType.RANDOM_REDDIT).setSubreddit("MinecraftMemes").execute();

embedBuilder.setTitle("→ " + reddit.getTitle());
embedBuilder.setImage(reddit.getImageUrl());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* JDALearningBot - Discord bot to learn JDA 4 library *
* Copyright (C) 2019-2020 TrackRunny *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

package me.trackrunny.jdalearning.command.commands.meme;

import me.trackrunny.jdalearning.Bot;
import me.trackrunny.jdalearning.command.CommandContext;
import me.trackrunny.jdalearning.command.ICommand;
import me.trackrunny.jdalearning.variables.Variables;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.MessageEmbed;
import net.dv8tion.jda.api.entities.TextChannel;
import net.explodingbush.ksoftapi.entities.Reddit;
import net.explodingbush.ksoftapi.enums.ImageType;

import java.awt.*;

public class PoliticalCompassMemeCommand implements ICommand {
@Override
public void handle(CommandContext ctx) {
final TextChannel channel = ctx.getChannel();

final EmbedBuilder embedBuilder = new EmbedBuilder();

final Reddit reddit = Bot.kSoftAPI.getRedditImage(ImageType.RANDOM_REDDIT).setSubreddit("PoliticalCompassMemes").execute();

embedBuilder.setTitle("→ " + reddit.getTitle());
embedBuilder.setImage(reddit.getImageUrl());
embedBuilder.setFooter(Variables.embedFooter);
embedBuilder.setColor(new Color(Variables.embedColor));

channel.sendMessage(embedBuilder.build()).queue();
}

@Override
public String getName() {
return "compassmeme";
}

@Override
public MessageEmbed getHelp() {
final EmbedBuilder embedBuilder = new EmbedBuilder();
embedBuilder.setTitle("→ Command Usage");
embedBuilder.setDescription("• Sends out a political compass meme!");
embedBuilder.setFooter(Variables.embedFooter);
embedBuilder.setColor(new Color(Variables.embedColor));

return embedBuilder.build();
}
}

0 comments on commit ba0770e

Please sign in to comment.