-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
82 lines (71 loc) · 2.25 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
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
const { channel } = require("diagnostics_channel");
const { Client, Intents, MessageEmbed } = require("discord.js");
require("dotenv").config();
const client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILD_PRESENCES,
],
});
const prefix = ".";
client.once("ready", () => {
console.log("Logged...");
client.user.setPresence({
activities: [{
name: ".help",
type: 'WATCHING'}],
status: "online",
});
});
client.on("messageCreate", async (msg) => {
if(!msg.content.startsWith(prefix))
return
const rawMsg = msg.content.slice(prefix.length);
const command = rawMsg.includes(' ')
? rawMsg.substr(0, rawMsg.indexOf(" ")) // format command
: rawMsg // help command
if (command === "format") {
if (rawMsg.includes("-d") && rawMsg.includes("-u")) {
let args = rawMsg.substr(rawMsg.indexOf(" ") + 1).split(" -d ");
const tittle = args[0];
const [desc, url] = args[1].trim().split(" -u ");
if (tittle && url) {
const embed = new MessageEmbed()
.setColor("#000000")
.setTitle(`🌀️ ${tittle}.`)
.setDescription(desc ?? "")
.addField("Source:", url === " " ? "empty url" : url, true)
.setFooter(
msg.author.username,
`https://cdn.discordapp.com/avatars/${msg.author.id}/${msg.author.avatar}.png`
);
msg.channel.send({ embeds: [embed] });
msg.delete();
} else {
msg.react("😡");
msg.channel.send("`title` nor `url` **musn't be blank.**")
.then(msg => {
setTimeout(() => msg.delete(), 10000)
})
.catch("Error handling setTimeout");
}
} else {
msg.react("😡");
msg.channel.send("**Please provide a proper format as** `.format title -d description -u url`")
.then(msg => {
setTimeout(() => msg.delete(), 10000)
})
.catch("Error handling setTimeout");
}
}
if(command === 'help') {
msg.channel.send("🔹️**Command** `.format title -d description -u url`")
.then(msg => {
setTimeout(() => msg.delete(), 15000)
})
.catch("Error handling the help message...");
msg.delete()
}
});
client.login(process.env.TOKEN);