-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
55 lines (47 loc) · 2.17 KB
/
index.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
const express = require("express");
const app = express();
const Discord = require("discord.js");
const client = new Discord.Client();
app.get("/", (req, res, next) => {
let message = "DND!!! Working at Thermal Discord Server.";
console.log(message);
res.send(message);
});
client.on("ready", () => {
console.log(`Logged in as ${client.user.tag}!`);
});
client.on("guildMemberAdd", member => {
let isBot = member.user.bot;
if (!isBot) {
// Send the message to a designated channel on a server:
const channel = member.guild.channels.find(ch => ch.name === "general");
// Do nothing if the channel wasn't found on this server
if (!channel) console.log(`Unble to find "general" channel.`);
// Send the message, mentioning the member
let welcomeMessage = `Welcome to Thermal Discord Server, ${member}`;
channel.send(welcomeMessage).then(console.log(`Send message: ${welcomeMessage}`));
}
});
client.on("message", message => {
// Valid command
let isBot = message.author.bot;
if (!isBot && message.content.charAt(0) === "!") {
// Custom referral url for analytics
let referralUrl = "?utm_source=discord&utm_medium=thermalbot"
switch (message.content.slice(1, message.content.length)) {
case "about":
message.channel.send(`Thermal is a free, open-source and cross-platform desktop application allows you to manage your Git repositories at one place by providing a simple to use graphic interface with built-in features like commits, history, repository settings and more.\n\nhttps://thermal.codecarrot.net/${referralUrl}`)
break;
case "contribute":
message.channel.send(`Glad! You are interested in contributing to Thermal project, to know about contribution guidelines, please read our docs https://thermal.codecarrot.net/docs/how-to-contribute/${referralUrl}`)
break;
default:
message.channel.send(`Here's the list of the following commands you can use in Thermal Discord Server https://github.com/gitthermal/discord-bot/blob/master/README.md/${referralUrl}`)
break;
}
}
});
client.login(process.env.DISCORD_BOT_TOKEN);
app.listen(8000, () => {
console.log(process.env.PORT)
})