-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathapp.js
90 lines (75 loc) · 3.02 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
const Discord = require('discord.js');
const superagent = require("superagent");
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 => {
const welcomeChannel = member.guild.channels.find('name', 'welcome');
if (!welcomeChannel === null) return;
client.channels.get(welcomeChannel.id).send("Welcome to: " + member.guild.name + " Hope you enjoy it here")
});
Client.on("guildMemberRemove", member => {
const welcomeChannel = member.guild.channels.find('name', 'welcome');
if (!welcomeChannel === null) return;
client.channels.get(welcomeChannel.id).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 === "cat") {
const { body } = await superagent
.get('aws.random.cat/meow');
const embed = new Discord.RichEmbed()
.setColor(0x954D23)
.setTitle("Meow :cat:")
.setImage(body.file)
message.channel.send({embed})
} else
if (command === "announcement") {
if (message.member.hasPermission("ADMINISTRATOR")) {
const color = args[0]
const text = args.slice(1).join(" ");
if (text.length < 1) return message.channel.send("Can not announce nothing");
//const colour = args.slice(2).join("");
const embed = new Discord.RichEmbed()
.setColor("0x" + color)
.setTitle("Important Announcement:")
.setDescription(text);
message.channel.send("@everyone")
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("Your token"); //replace with your token dont share yours.