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 OwnerID = "130515926117253122";
- const prefix = "!"
- Client.on("ready", () => {
- console.log("online");
- Client.user.setPresence({ game: { name: `Hello world`, type: 0} });
- });
- // welcome message
- Client.on("guildMemberAdd", member => {
- member.guild.defaultChannel.send("Welcome to: " + member.guild.name + " Hope you enjoy it here")
- });
- Client.on("guildMemberRemove", member => {
- member.guild.defaultChannel.send("Goodbye: " + member.user.username + " from " + member.guild.name)
- });
- Client.on("guildCreate", guild => {
- console.log("Some one added the test bot to a server created by: " + guild.owner.user.username)
- });
- Client.on("message", async (message) => {
- if (message.author.bot) return;
- if (!message.content.startsWith(prefix)) return;
- let command = message.content.split(" ")[0];
- command = command.slice(prefix.length);
- let args = message.content.split(" ").slice(1);
- if (command === "ping") {
- message.channel.send(`Pong! Time took: ${Date.now() - message.createdTimestamp} ms`);
- } else
- if (command === "say") {
- message.delete()
- const embed = new Discord.RichEmbed()
- .setColor(0x954D23)
- .setDescription(message.author.username + " says: " + args.join(" "));
- message.channel.send({embed})
- } else
- if (command == "help") {
- const embed = new Discord.RichEmbed()
- .setColor(0x954D23)
- .setTitle("Command List:")
- .addField("!help", "Will give the current command list")
- .addField("!ping", "WIll show the ping time for the bot")
- .addField("!say [text]", "Will make the bot say something")
- .addField("!announcement [text]", "Will make the bot say an announcement and tag everyone")
- .addField("!cat", "Will send a random cat image");
- message.channel.send({embed})
- }
- });
- Client.login("Redacted");
- Error
- (node:38708) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Incorrect login details were provided.
- (node:38708) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement