@armeetjatyani
2021
JDA
discord-bot
A discord bot that tweets Kanye's tweets every 6 hours!
- by this point I had made some basic discord bots with discord.js (JavaScript) and discordpy (Python)
- I wanted to try out JDA (Java Discord API)
- Made a simple meme bot, that responds to the
!ye
command with a random Kanye tweet!
Full Demo: https://youtu.be/7V1mJanghhc
/**
* https://api.kanye.rest
* @return
*/
@SneakyThrows
public static String get()
{
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.kanye.rest?format=text")
.build(); // defaults to GET
Response response = client.newCall(request).execute();
return response.body().string();
}
public class YeBot
{
public static String yeToken;
@SneakyThrows
public static void main(String[] args)
{
// get discord bot token
yeToken = System.getenv("YEBOT_TOKEN");
System.out.println("TOKEN: " + yeToken);
if(yeToken.length() == 0) System.exit(1);
JDABuilder builder = JDABuilder.createDefault(yeToken)
.addEventListeners(
new MainListener()
);
builder.build();
}
}