TemmieWebhook - A simple, straightforward, Discord Webhook API for Java

TemmieWebhook


A simple, straightforward, Discord Webhook API for Java
So simple, that we don't even need a huge tutorial for it.​

Messages
Code:
Code:
TemmieWebhook temmie = new TemmieWebhook("Your Webhook URL here (Get it by going to your server configurations -> Webhook");
// Username, Content, Avatar URL
DiscordMessage dm = new DiscordMessage("Temmie", "hOI, im TEMMIE!", "https://media.tenor.co/images/d205ef37ba5aad7b84fc21f6ffb36c6b/raw");
temmie.sendMessage(dm);
Output:

Embeds
Because all the fancy programmers are using embeds in Discord, so why shouldn't we?

Code:
Code:
TemmieWebhook temmie = new TemmieWebhook("Your Webhook URL here (Get it by going to your server configurations -> Webhook");
DiscordEmbed de = new DiscordEmbed("Temmie", "Temmie (/ˈtɛ.miː/) is a species of monster in the Underground. They appear as a unique enemy in Waterfall, residents of Temmie Village, and the vendor of Tem Shop. ");
ThumbnailEmbed te = new ThumbnailEmbed();
te.setUrl("http://vignette3.wikia.nocookie.net/undertale/images/9/9c/Temmie.gif/revision/latest?cb=20151206115948");
te.setHeight(96);
te.setWidth(96);
de.setThumbnail(te);
DiscordMessage dm = new DiscordMessage("Temmie", "", "https://img04.deviantart.net/360e/i/2015/300/9/d/temmie_by_ilovegir64-d9elpal.png");
dm.getEmbeds().add(de);
temmie.sendMessage(dm);

Output:


Builders
Do you prefer using builders? No problem!

Messages Builder
Code:
Code:
TemmieWebhook temmie = new TemmieWebhook("Your Webhook URL here (Get it by going to your server configurations -> Webhook");
DiscordMessage dm = DiscordMessage.builder()
  .username("Temmie") // We are creating a message with the username "Temmie"...
  .content("RATED TEM OUTTA TEM.") // with this content...
  .avatarUrl("http://img14.deviantart.net/de17/i/2015/364/0/4/undertale_temmie_by_silvishinystar-d9lpf55.png") // with this avatar...
  .build(); // and now we build the message!

temmie.sendMessage(dm);

Output:


Embed Builder
Code:
Code:
TemmieWebhook temmie = new TemmieWebhook("Your Webhook URL here (Get it by going to your server configurations -> Webhook");
DiscordEmbed de = DiscordEmbed.builder()
  .title("RATED TEM OUTTA TEM.") // We are creating a embed with this title...
  .description("fhsdhjfdsfjsddshjfsd ") // with this description...
  .url("https://github.com/MrPowerGamerBR/TemmieWebhook") // that, when clicked, goes to the TemmieWebhook repo...
  .footer(FooterEmbed.builder() // with a fancy footer...
  .text("TemmieWebhook!") // this footer will have the text "TemmieWebhook!"...
  .icon_url("http://vignette2.wikia.nocookie.net/undertale-brasil/images/4/4f/Temmie.jpg/revision/latest?cb=20160221005012&path-prefix=pt-br") // with this icon on the footer
  .build()) // and now we build the footer...
  .thumbnail(ThumbnailEmbed.builder() // with a fancy thumbnail...
  .url("http://i.imgur.com/7kznsnS.png") // with this thumbnail...
  .height(128) // not too big because we don't want to flood the user chats with a huge image, right?
  .build()) // and now we build the thumbnail...
  .fields(Arrays.asList( // with fields...
  FieldEmbed.builder()
  .name("hOI!!!!!! i'm tEMMIE!!")
  .value("awwAwa cute!! (pets u)")
  .build(),
  FieldEmbed.builder()
  .name("OMG!! humans TOO CUTE (dies)")
  .value("NO!!!!! muscles r... NOT CUTE | NO!!!!!")
  .build(),
  FieldEmbed.builder()
  .name("NO!!! so hungr... (dies) ")
  .value("FOOB!!! ")
  .build()
  ))
  .build(); // and finally, we build the embed

DiscordMessage dm = DiscordMessage.builder()
  .username("Temmie") // We are creating a message with the username "Temmie"...
  .content("") // with no content because we are going to use the embed...
  .avatarUrl("http://img06.deviantart.net/a35d/i/2016/056/c/3/temmie___undertale_by_tartifondue-d9t3h1h.png") // with this avatar...
  .embeds(Arrays.asList(de)) // with the our embed...
  .build(); // and now we build the message!

temmie.sendMessage(dm);
Output:

Simple as that, have fun!

Maven
You can use TemmieWebhook with Maven by using Jitpack. (sorry, I don't have a maven repo yet )

Code:
<repositories>
  <repository>
  <id>jitpack.io</id>
  <url>https://jitpack.io</url>
  </repository>
</repositories>

<dependency>
  <groupId>com.github.MrPowerGamerBR</groupId>
  <artifactId>TemmieWebhook</artifactId>
  <version>-SNAPSHOT</version>
</dependency>

Dependencies
Gson
HttpRequest by @kevinsawicki
lombok

Why Temmie?
Why not Temmie?

GitHub Repo:
https://github.com/MrPowerGamerBR/TemmieWebhook

Example Project:
RelayItToDiscord - Relay your chat to Discord! https://www.spigotmc.org/resources/relayittodiscord.34615/

I created this because the only Java Webhook API I used had some issues, so I created my own API.
 
I just got memed. Looks really cool, but the builder for the embeds looks a bit .extreme(). Would be nice to use something in this for FreeSO lots and content some time in the future.
 
I just got memed. Looks really cool, but the builder for the embeds looks a bit .extreme(). Would be nice to use something in this for FreeSO lots and content some time in the future.
Those builders (and the getters/setters) are all auto generated by lombok (because I'm way too lazy to make every getter/setter/builder) myself. :p

Actually, a API shouldn't even be needed to do that, to interact with a webhook you just need to send a JSON (that's why I use Gson in the API) to a Discord webhook URL and boom, done.

Code:
{"username":"Temmie","content":"RATED TEM OUTTA TEM","avatar_url":"http://img06.deviantart.net/a35d/i/2016/056/c/3/temmie___undertale_by_tartifondue-d9t3h1h.png","tts":false}

And I created this API because there is only two APIs related to Discord's Webhook in Java, this one https://github.com/momothereal/java-canary-webhooks (which I was using before I created TemmieWebhook, it has a very bad memory leak it seems, because my Discord bot was always crashing after using that Webhook and it had issues with messages failing to send without any reason...) and there is this one https://github.com/d0p1s4m4/Hookscord (which I only found out after I created TemmieWebhook... but it seems that one doesn't have Discord Embed support). And I was creating a Skype to Discord relay and then I said "fuck it, I will create my own API".

Anyway, using Webhooks is very nice and the only limit is your imagination (and Discord's limits of course), you could even interact a bit with the global server by relaying server infos to Discord (like those global broadcast in TSO) and... (well, I don't have more ideas because I never played TSO)

Also, thanks for your comment. ;)
 
Yo look likes a very nice API. Also very useful and would save me tons of times.
But when I try to add to my project I always get an error.
Code:
<repository>
            <id>jitpack.io</id>
            <url>https://jitpack.io</url>
</repository>


<dependency>
           <groupId>com.github.MrPowerGamerBR</groupId>
            <artifactId>TemmieWebhook</artifactId>
            <version>-SNAPSHOT</version
</dependency>
Error
Dependency 'com.github.MrPowerGamerBR:TemmieWebhook:-SNAPSHOT' not found.


nvm solved myself^^
 
Last edited:
Yo look likes a very nice API. Also very useful and would save me tons of times.
But when I try to add to my project I always get an error.
Code:
<repository>
            <id>jitpack.io</id>
            <url>https://jitpack.io</url>
</repository>


<dependency>
           <groupId>com.github.MrPowerGamerBR</groupId>
            <artifactId>TemmieWebhook</artifactId>
            <version>-SNAPSHOT</version
</dependency>
Error



nvm solved myself^^
Hi, how did you solve this problem? :)
 
Back
Top