-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
181 lines (150 loc) · 6.24 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
173
174
175
176
177
178
179
180
181
//Client
const Discord = require("discord.js")
const { Client, Intents } = require('discord.js');
const client = new Client({
presence: {
status: 'dnd',
activity: {
name: 'Welcome',
type: 'WATCHING',
},
},
}, { intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
//Modules
const db = require(`quick.db`)
require('dotenv').config()
//Variables
const token = process.env.TOKEN
const prefix = process.env.PREFIX
//Commands
client.on("message", (msg) => {
channelwelc = db.get(`channel.${msg.guild.id}`)
if (msg.author.bot) {
return
} else if (msg.content === `${prefix}test`) {
if (channelwelc === null) return
msg.react(`✅`)
client.emit ('guildMemberAdd', msg.member);
} else if (msg.content === `${prefix}help`){
msg.channel.bulkDelete(1)
let helpembed = new Discord.MessageEmbed()
.setTitle(`Owecome Setup`)
.setDescription(`In order for the bot to work you need to set up a channel which the welcome messages will be posted in.`)
.addField(`Set it up:`, "`?setup <channel ID>`/`?setup <channel mention>`")
.addField(`Need help?`,`[How to set up Owecome Bot](https://i.imgur.com/OazezIS.png)`)
.addField(`Test`, "To test if everything is working you can do `?test`")
.setColor(`#0351`)
.setThumbnail(`${client.user.avatarURL()}`)
msg.channel.send(helpembed)
} else if (msg.content === `${prefix}invite`) {
msg.channel.send({ embed: {
"description": `You liked the bot? [Invite ${client.user.username}](https://discord.com/api/oauth2/authorize?client_id=${client.user.id}&permissions=8&scope=bot%20applications.commands)`,
"color": 0351,
}});
} else if (msg.content.startsWith(`${prefix}setup`)) {
const args = msg.content.trim().split(/ +/);
const cmd = args.shift()
var channelid = (args[0].replace('<#','').replace('>',''))
db.set(`channel.${msg.guild.id}`, channelid)
//Embed
let successembed = new Discord.MessageEmbed()
.setTitle(`Success`)
.setDescription(`Thank you for choosing **Owecome**! Your new members will be now warmly welcomed by the bot in <#${channelid}>`)
.addField(`Not Working?`,`[Join the support server](https://discord.gg/m9fJVPtKTM)`)
.addField(`Test`, "To test if everything is working you can do `?test`")
.setColor(`GREEN`)
.setThumbnail(`${client.user.avatarURL()}`)
msg.reply(successembed)
} else if (msg.content == `${prefix}ping`)
msg.channel.send({ embed: {
"description": `Bot Response Time: 🏓**${client.ws.ping}ms**!`,
"color": 0351,
}});
});
//Welcomer
var Canvas = require('canvacord');
client.on('guildMemberAdd', member => {
channelwelc2 = db.get(`channel.${member.guild.id}`)
let welcome = member.guild.channels.cache.get(db.get(`channel.${member.guild.id}`))
var wellcome = new Canvas.Welcomer()
.setUsername(member.user.username)
.setDiscriminator(member.user.discriminator)
.setMemberCount(member.guild.memberCount.toLocaleString())
.setGuildName(member.guild.name)
.setAvatar(member.user.displayAvatarURL({ format: "png" }))
.setColor("border", "transparent")
.setColor("username-box", "#d33a0f") //
.setColor("discriminator-box", "#d33a0f")
.setColor("title", "#d33a0f")
.setColor("avatar", "#d33a0f")
.setText("member-count", "Member {count}`th")
.setText("title", "welcome")
.setText("message", "Enjoy your stay!")
.setBackground(`https://images.contentstack.io/v3/assets/bltb6530b271fddd0b1/blt8029e429cd82567d/6129ab436768907ea97679aa/090121_Ep3ActIIFractureTease_Banner_v3.jpg?auto=webp&disable=upscale&height=504`)
/*
"https://cdn-images.win.gg/resize/w/1000/format/webp/type/progressive/fit/cover/path/wp/uploads/2021/08/Canyon-scaled.jpg"
`https://images.contentstack.io/v3/assets/bltb6530b271fddd0b1/blt8029e429cd82567d/6129ab436768907ea97679aa/090121_Ep3ActIIFractureTease_Banner_v3.jpg?auto=webp&disable=upscale&height=504`
`https://staticg.sportskeeda.com/editor/2021/09/484ec-16306917668507-800.jpg`
*/
try {
if (channelwelc2 === null) return
wellcome.build()
.then(buffer => welcome.send(`Welcome to the server,${member}!`, new Discord.MessageAttachment(buffer, "welcome.png")));
}
catch (e) {
console.log(e);
}
});
//Slash CMDS
client.on('ready', () => {
/* client.api.applications(client.user.id).commands.post({
data: {
name: "ping",
description: "Check Bot`s response time!"
}
})
client.api.applications(client.user.id).commands.post({
data: {
name: "invite",
description: "Add the bot to your server!"
}
});
*/
client.ws.on('INTERACTION_CREATE', async interaction => {
const command = interaction.data.name.toLowerCase();
const args = interaction.data.options;
if (command === 'ping'){
client.api.interactions(interaction.id, interaction.token).callback.post({
data: {
type: 4,
data: {
embeds: [{
"description": `Bot Response Time: 🏓**${client.ws.ping}ms**!`,
"color": 0351
}]
}
}
})
}
if (command === 'invite'){
client.api.interactions(interaction.id, interaction.token).callback.post({
data: {
type: 4,
data: {
embeds: [{
"description": `You liked the bot? [Invite ${client.user.username}](https://discord.com/api/oauth2/authorize?client_id=${client.user.id}&permissions=8&scope=bot%20applications.commands)`,
"color": 0351
}]
}
}
})
}
});
});
//Login
client.login(token)
client.on("ready", () => {
client.user.setUsername(`Owecome`)
client.user.setAvatar(`https://images-ext-2.discordapp.net/external/OKgA4zGcH_ilzwqv9VBbs1NO-thUbj9hTCf0UvGR5GI/%3Fsize%3D128/https/cdn.discordapp.com/app-icons/879360738060292096/fc2356059549d0dfc8d4ab1bd0b4caac.webp`)
console.log("Bot is ready!")
});