-
Notifications
You must be signed in to change notification settings - Fork 0
/
discord.js
107 lines (90 loc) · 4.57 KB
/
discord.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// Load up the discord.js library
const Discord = require("discord.js");
// This is your client. Some people call it `bot`, some people call it `self`,
// some might call it `cootchie`. Either way, when you see `client.something`, or `bot.something`,
// this is what we're refering to. Your client.
const client = new Discord.Client();
// Load config and settings
// config.token contains the bot's token
// config.prefix contains the message prefix.
const config = require("./config.json");
// const settings = require("./settings.json");
client.on("ready", () => {
// This event will run if the bot starts, and logs in, successfully.
console.log(`Bot has started, with ${client.users.size} users, in ${client.channels.size} channels of ${client.guilds.size} guilds.`);
// Example of changing the bot's playing game to something useful. `client.user` is what the
// docs refer to as the "ClientUser".
client.user.setGame(`FUD management v1.0.0`);
});
client.on("guildCreate", guild => {
// This event triggers when the bot joins a guild.
console.log(`New guild joined: ${guild.name} (id: ${guild.id}). This guild has ${guild.memberCount} members!`);
let channels = guild.channels.array();
for (let channel of channels) {
if (channel.name === 'general') {
channel.send('fud-dud -- Glad to be around everyone! I am here to actively monitor the FUD :-)');
}
}
client.user.setGame(`FUD management v1.0.0`);
});
client.on("guildDelete", guild => {
// this event triggers when the bot is removed from a guild.
console.log(`I have been removed from: ${guild.name} (id: ${guild.id})`);
client.user.setGame(`on ${client.guilds.size} servers`);
});
// Create an event listener for new guild members
client.on('guildMemberAdd', member => {
// Send the message to a designated channel on a server:
const channel = member.guild.channels.find('name', 'member-log');
// Do nothing if the channel wasn't found on this server
if (!channel) return;
// Send the message, mentioning the member
channel.send(`Welcome to the server, ${member}! We have an Obsidian Tipbot available here, type \`!help\` for usage!`);
});
client.on("message", async message => {
// This event will run on every single message received, from any channel or DM.
// It's good practice to ignore other bots. This also makes your bot ignore itself
// and not get into a spam loop (we call that "botception").
if(message.author.bot) return;
// Also good practice to ignore any message that does not start with our prefix,
// which is set in the configuration file.
// if(message.content.indexOf(config.prefix) !== 0) return;
let randomFudReply = [
'Fud on /biz/? No way! /s',
'Yes there is fud on biz. Please ignore it and think for yourself.',
'Buy the FUD! Sell the FOMO! *(this is not real trading advice)*'
];
let randomScamReply = [
'Fake news',
'Don\'t believe everything you read on the internet',
'Pravik Pajeet has been thoroughly vetted by the Securities and Exchange Board of India and has been granted a legitimacy rating of 10/10',
'http://a.co/fwMoKhL',
];
if ( /fud/ig.test(message.content) === true &&
(/biz/ig.test(message.content) === true || /4chan/ig.test(message.content) === true) ) {
let randomReply = randomFudReply[Math.floor(Math.random() * randomFudReply.length)];
message.channel.send(`${randomReply} -- This FUD has been controlled by the FUDBot`);
}
else if ( /sage/ig.test(message.content) === true &&
/leaving/ig.test(message.content) === true) {
message.channel.send(`Sagemark is not leaving. -- This FUD has been controlled by the FUDBot`);
}
else if ( /dev/ig.test(message.content) === true &&
/dump/ig.test(message.content) === true) {
message.channel.send(`The only dumping going on are the unfortunate oil spills occurring every day that are not discussed in the news. It's really sad... -- This FUD has been controlled by the FUDBot`);
setTimeout(() => {
message.channel.send(`Seriously guys... think of the poor animals... :'('`);
}, Math.floor(Math.random() * 10000) + 1000);
}
else if ( /scam/ig.test(message.content) === true &&
(/team/ig.test(message.content) === true ||
/obsidian/ig.test(message.content) === true ||
/odn/ig.test(message.content) === true ) ) {
let randomReply = randomScamReply[Math.floor(Math.random() * randomScamReply.length)];
message.channel.send(`${randomReply} -- This FUD has been controlled by the FUDBot`).then((Message) => {
Message.react("😂");
Message.react("👌");
});
}
});
client.login(config.token);