Advertisement
notjacob

java vs javascript

Mar 21st, 2020
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.99 KB | None | 0 0
  1. // java
  2. public class Bot extends ListenerAdapter {
  3.     private JDA bot;
  4.     public void start() {
  5.         JDA jda = new JDABuilder("token").build();
  6.         jda.addEventListener(this);
  7.         bot = jda;
  8.     }
  9.     @Override
  10.     public void onReady(ReadyEvent event) {
  11.         System.out.println("logged in on" + bot.getBot().getSelfUser().getAsTag() + "");
  12.     }
  13.     @Override
  14.     public void onMessageReceived(@Nonnull MessageReceivedEvent event) {
  15.         if (event.getMessage().getContentRaw().contains("ping")) {
  16.             event.getChannel().sendMessage("@" + event.getAuthor().getAsTag() + ", Pong!").queue();
  17.         }
  18.     }
  19. }
  20. public class Main {
  21.     public static void main(String[] args) {
  22.         Bot bot = new Bot();
  23.         bot.start();
  24.     }
  25. }
  26. // JavaScript
  27. const Discord = require('discord.js');
  28. const client = new Discord.Client();
  29. client.on('ready', () => {
  30.     console.log(`Logged in as ${client.user.tag}!`);
  31. });
  32. client.on('message', msg => {
  33.     if (msg.content.includes('ping')) {
  34.         msg.reply('Pong!');
  35.     }
  36. });
  37. client.login('token');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement