Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // java
- public class Bot extends ListenerAdapter {
- private JDA bot;
- public void start() {
- JDA jda = new JDABuilder("token").build();
- jda.addEventListener(this);
- bot = jda;
- }
- @Override
- public void onReady(ReadyEvent event) {
- System.out.println("logged in on" + bot.getBot().getSelfUser().getAsTag() + "");
- }
- @Override
- public void onMessageReceived(@Nonnull MessageReceivedEvent event) {
- if (event.getMessage().getContentRaw().contains("ping")) {
- event.getChannel().sendMessage("@" + event.getAuthor().getAsTag() + ", Pong!").queue();
- }
- }
- }
- public class Main {
- public static void main(String[] args) {
- Bot bot = new Bot();
- bot.start();
- }
- }
- // JavaScript
- const Discord = require('discord.js');
- const client = new Discord.Client();
- client.on('ready', () => {
- console.log(`Logged in as ${client.user.tag}!`);
- });
- client.on('message', msg => {
- if (msg.content.includes('ping')) {
- msg.reply('Pong!');
- }
- });
- client.login('token');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement