This repository has been archived by the owner on Dec 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwelcome.js
64 lines (60 loc) · 2.3 KB
/
welcome.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
const utl = require('./utilities');
const date = new Date();
const sqlite = require('sqlite3').verbose();
module.exports = (client, channel, targetChannels = []) => {
// Runs whenever a user joins
client.on('guildMemberAdd', (member) => {
let newMember = member.guild.roles.cache.find(
(role) => role.name === 'NEW-MEMBER'
);
// Add the role NEWMEMBER(or any other role you need to add) to any user who joins
member.roles.add(newMember);
// Generates a random number that will be added to the data-base later
let accessCode = utl.random(1, 1000);
// Database stuff
let db = new sqlite.Database('./users.db', sqlite.OPEN_READWRITE);
let query = 'SELECT * FROM user WHERE id = ?';
db.get(query, [member.id], (err, row) => {
if (err) console.log(err);
if (row === undefined) {
// Insert data if the user don't have any data
let insertData = db.prepare('INSERT INTO user VALUES(?, ?)');
insertData.run(member.id, accessCode);
return;
}
});
// The welcome message, it's sepcific to our server, you can change that part as you please
const messageContent = `Hey <@${member.id}>, welcome to **${
member.guild.name
}** 🎉🤗 ! Please read the ${utl
.getChannel(member, targetChannels[0])
.toString()} please note by you being here you accept the rules.
***__How to gain access:__***
**1.** If you are willing complete ${utl
.getChannel(member, targetChannels[1])
.toString()} once you are granted access this can not be filled out so do it first (again if you are willing it is not a requirement).
**2.** Type: "My Access Code is: ${accessCode} and I agree to the rules"
__Hint/Help: The rules are in: ${member.guild.channels.cache
.get(targetChannels[0])
.toString()}__
**3.** If you have More than five errors, run the sci!code command and use that code. \n
If that doesn't work ping the <@&ROLE ID>`;
const message = {
color: 'RANDOM',
title: 'Science and Math Association Entry Procedure',
author: {
name: 'Government of SAMA Bot',
},
description: messageContent,
footer: {
text: `${date.getDate()}/${
date.getMonth() + 1
}/${date.getFullYear()}`,
},
};
utl.getChannel(member ,channel).send(
`<@&ROLE ID> Please Assist them in entry if they need it \n
<@${member.id}> Please Read this embed:`,
{ embed: message });
});
};