-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
172 lines (124 loc) · 4 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
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
const Discord = require("discord.js")
const fetch = require("node-fetch")
const keepalive = require("./server")
const client = new Discord.Client()
const sadwords = ["fuck","gay","mf","motherfucker","ass"]
const encourage = [
"These Words are not allowed here ",
"No Foul Words here "
]
function getQuote(){
return fetch("https://zenquotes.io/api/random")
.then(res => {
return res.json()
})
.then(data => {
return data[0]["q"] + " - " + data[0]["a"]
})
}
client.on("ready",() => {
console.log(`Logged in as ${client.user.tag}`)
client.user.setActivity("!help", {
type: "LISTENING",
})
})
client.on("message", msg => {
if (msg.author.bot) return
if (!msg.guild) return;
if (msg.content === "!quote"){
getQuote().then(quote => msg.channel.send(quote))
}
if (sadwords.some(word => msg.content.includes(word))) {
const encouragement = encourage[Math.floor(Math.random() * encourage.length)]
msg.reply(encouragement)
}
// To kick a member
if (msg.content.startsWith('!kick')) {
const user = msg.mentions.users.first();
if (msg.member.hasPermission('KICK_MEMBERS')){
if (user) {
const member = msg.guild.member(user);
if (member) {
member
.kick('Optional reason that will display in the audit logs')
.then(() => {
msg.reply(`Successfully kicked ${user.tag}`);
})
.catch(err => {
message.reply('I was unable to kick the member');
console.error(err);
});
} else {
msg.reply("That user isn't in this guild!");
}
} else {
msg.reply("You didn't mention the user to kick!");
}
}
}
// To Ban a member
if (msg.content.startsWith('!ban')) {
const user = msg.mentions.users.first();
if (msg.member.hasPermission('BAN_MEMBERS')){
if (user) {
const member = msg.guild.member(user);
if (member) {
member
.ban({
reason: 'They were bad!',
})
.then(() => {
msg.reply(`Successfully banned ${user.tag}`);
})
.catch(err => {
msg.reply('I was unable to ban the member');
console.error(err);
});
} else {
msg.reply("That user isn't in this guild!");
}
} else {
msg.reply("You didn't mention the user to ban!");
}
}
}
if (msg.content.startsWith('!clear')) {
if (msg.member.hasPermission('ADMINISTRATOR')) {
msg.channel.messages.fetch().then((results) => {
msg.channel.bulkDelete(results)
})
}
}
const customcommands = new Discord.MessageEmbed()
.setColor('#D62AD0')
.setTitle(' Duo Bot (Custom Commands)')
.addFields(
{ name: '!quote', value: 'Random Quote', inline: true },
{ name: '!canva', value: 'Canva Invitation', inline: true },
{ name: '!movie', value: 'Stream Movie', inline: true },
{ name: '!linkedinlearn', value: 'linkedinlearning account', inline: true }
)
if (msg.content.startsWith('!help')){
msg.channel.send(customcommands);
}
if (msg.content.startsWith('!canva')){
msg.reply(`Canva Pro LifeTime Subscription Invitation https://duocodies.cyou/canva`);
}
if (msg.content.startsWith('!movie')){
msg.reply(`Stream Movie https://duocodies.cyou/Movie`);
}
if (msg.content.startsWith('!linkedinlearn')){
msg.reply(`Process to create linkedin account https://duocodies.cyou/linkedinlearn`);
}
})
const channelId = '857813800257978404' // welcome channel
const targetChannelId = '857813800257978403' // rules and info
client.on('guildMemberAdd', (member) => {
const msg = `Please welcome <@${member.id}> to the server! Please check out ${member.guild.channels.cache
.get(targetChannelId)
.toString()}`
const channel = member.guild.channels.cache.get(channelId)
channel.send(msg)
})
keepalive()
client.login(process.env.Token)