-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
205 lines (186 loc) · 6.54 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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
const Discord = require('discord.js');
const client = new Discord.Client();
const prefix = "-";
client.once('ready', () =>
{
console.log('Ready!')
});
client.on('guildMemberAdd', member => // On addition of a new memeber....
{
const sysChannel = member.guild.channels.find(ch => ch.name === 'general'); // find the member log channel
if (!sysChannel) return; // do nothing if not found
const serverName = message.guild.name;
const welcomeChannel = message.guild.channels.find(ch => ch.name === 'welcome');
const introChannel = message.guild.channels.find(ch => ch.name === 'introduction'); // find the intro, roles and welcome chanlles
const rolesChannel = message.guild.channels.find(ch => ch.name === 'roles');
if(!welcomeChannel || !introChannel || !rolesChannel) return; // do nothing if they arent
else
{
//sysChannel.send(` \n Welcome to ${serverName}, ${user.displayName} ! \n Please read: ${welcome} \n leave an intro in: ${intro} \n Get your Role from: ${roles} \n `); // return welcome messgae to member log channel
var dt = new Date();
const year = dt.getFullYear();
const WelcomeEmbed = {
color: 0x0099ff,
title: ` Welcome ${member.displayName}, To The ${serverName} Discord Server`,
author:
{
name: `${serverName}`,
icon_url: 'https://avatars3.githubusercontent.com/u/52018753?s=200&v=4',
url: 'https://primotechorg.wordpress.com/',
},
description: 'Primo Tech is an Open Source technology initiative which seeks to develop solutions and build communities of solvers',
fields:
[
{
name: 'Please read the Welcome Channel',
value: `${welcomeChannel}`,
},
{
name: 'leave an intro in the Introduction Channel',
value: `${introChannel}`,
},
{
name: 'Get your role from the Roles Channel',
value: `${rolesChannel}`,
},
],
timestamp: new Date(),
footer:
{
text: `Trademark ${year}`,
icon_url: 'https://avatars3.githubusercontent.com/u/52018753?s=200&v=4',
},
}
sysChannel.send({ embed: WelcomeEmbed });
}
});
client.on('message', message => // on messgae recieved......
{
//console.log(message.guild.memberCount);
if(message.content.startsWith(`${prefix}cmd`))
{
message.channel.send(" ``` -cmd \n -hello \n -troll \n -welcome ``` ");
}
else if(message.content.startsWith(`${prefix}hello`))
{
message.channel.send(" ```Greetings Ningen!``` ");
}
else if(message.content.startsWith(`${prefix}troll`))
{
let user = message.mentions.members.first();
if (!user)
{
message.channel.send("```\n Silly Ningen! \n```");
}
else
{
message.channel.send("```\n Silly Ningen! " +user.displayName+"\n```");
}
}
else if(message.content.startsWith(`${prefix}welcome`)) // test welcome message
{
let user = message.mentions.members.first();
const noUser = " ";
if (!user)
{
user = noUser;
}
const sysChannel = message.guild.channels.find(ch => ch.name === 'general'); // find the member log channel
if (!sysChannel)
{
return; // do nothing if not found
}
const serverName = message.guild.name;
const welcomeChannel = message.guild.channels.find(ch => ch.name === 'welcome');
const introChannel = message.guild.channels.find(ch => ch.name === 'introduction'); // find the intro, roles and welcome chanlles
const rolesChannel = message.guild.channels.find(ch => ch.name === 'roles');
if(!welcomeChannel || !introChannel || !rolesChannel) return; // do nothing if they arent
else
{
//sysChannel.send(` \n Welcome to ${serverName}, ${user.displayName} ! \n Please read: ${welcome} \n leave an intro in: ${intro} \n Get your Role from: ${roles} \n `); // return welcome messgae to member log channel
var dt = new Date();
const year = dt.getFullYear();
const WelcomeEmbed = {
color: 0x0099ff,
title: ` Welcome ${user.displayName}, To The ${serverName} Discord Server`,
author:
{
name: `${serverName}`,
icon_url: 'https://avatars3.githubusercontent.com/u/52018753?s=200&v=4',
url: 'https://primotechorg.wordpress.com/',
},
description: 'Primo Tech is an Open Source technology initiative which seeks to develop solutions and build communities of solvers',
fields:
[
{
name: 'Please read the Welcome Channel',
value: `${welcomeChannel}`,
},
{
name: 'leave an intro in the Introduction Channel',
value: `${introChannel}`,
},
{
name: 'Get your role from the Roles Channel',
value: `${rolesChannel}`,
},
],
timestamp: new Date(),
footer:
{
text: `Trademark ${year}`,
icon_url: 'https://avatars3.githubusercontent.com/u/52018753?s=200&v=4',
},
};
sysChannel.send({ embed: WelcomeEmbed });
}
}
else if(message.content.startsWith(`${prefix}roles`))
{
const serverName = message.guild.name;
const rolesChannel = message.guild.channels.find(ch => ch.name === 'roles');
var rolesRaw = message.guild.roles.array();
var Roles = rolesRaw.filter(r => r != '@everyone');
//const Bots = message.guild.members.filter(member => member.user.bot).array();
var dt = new Date();
const year = dt.getFullYear();
const rolesEmbed = {
color: 0x0099ff,
title: 'Roles',
author:
{
name: `${serverName}`,
icon_url: 'https://avatars3.githubusercontent.com/u/52018753?s=200&v=4',
url: 'https://primotechorg.wordpress.com/',
},
description: 'Please select an available role from below',
fields:
[
{
name: 'Roles Available:',
value: `${Roles}`,
},
{
name: 'Command:',
value: '-addrole @name-of-role',
},
],
timestamp: new Date(),
footer:
{
text: `Trademark ${year}`,
icon_url: 'https://avatars3.githubusercontent.com/u/52018753?s=200&v=4',
},
};
message.channel.send({ embed: rolesEmbed });
message.channel.send(`${message.member}`);
rolesChannel.send({ embed: rolesEmbed });
rolesChannel.send(`${message.member}`);
}
else if(message.content.startsWith(`${prefix}addrole`))
{
const newRoles = message.mentions.roles.array();
message.member.addRoles(newRoles);
}
});
client.login(process.env.BOT_TOKEN); // invoke bot token from Heroku variables