Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Discord = require('discord.js');
- const client = new Discord.Client();
- const prefix = "!";
- client.on("ready", () => {
- console.log(`Bot has started, with ${client.users.size} users, in ${client.channels.size} channels.`);
- });
- client.on("message", async message => {
- console.log(`${message.content}, -${message.author.username}`);
- //Don't do anything if the message is sent by a bot
- if(message.author.bot) return;
- /* Global messages */
- if (message.content.toLowerCase().includes('hello bot')) {
- message.channel.send(`Hekke ${message.author}`);
- }
- /* Commands */
- if(message.content.indexOf(prefix) !== 0) return;
- const arguments = message.content.slice(prefix.length).trim().split(/ +/g);
- const command = arguments.shift().toLowerCase();
- console.log('arguments:', arguments);
- console.log('command:', command);
- if(command === "ping") {
- const m = await message.channel.send("Ping?");
- m.edit(`Pong! Latency is ${m.createdTimestamp - message.createdTimestamp}ms. API Latency is ${Math.round(client.ping)}ms`);
- }
- if(command === "say") {
- const sayMessage = arguments.join(" ");
- message.delete().catch(O_o=>{});
- message.channel.send(sayMessage);
- }
- });
- client.login("ADD_YOUR_BOT_TOKEN_HERE");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement