Commit 306d129f authored by Neoony's avatar Neoony
Browse files

-Added ability to use !cpjoin / !cpleave in empireschat channel -Added mention...

-Added ability to use !cpjoin / !cpleave in empireschat channel -Added mention user in !cpjoin / !cpleave reply message
parent ca18aa82
......@@ -105,12 +105,33 @@ client.login(auth.token);
client.on('message', message => {
const user = message.author.username;
console.log(user);
if (message.channel.name != 'botspam' && !message.channel.recipient) {
console.log('Channel: ' + message.channel.name);
if (message.channel.name != 'botspam' && message.channel.name != 'empireschat' && !message.channel.recipient) {
return;
}
if (message.author.username != 'EmpiresLobby' && message.author.username != 'EmpiresLobbyTest') {
console.log(message.author.username + ': ' + message.content);
}
switch(message.content.toLowerCase()) {
case '!comeplayjoin':
case '!cpjoin':
case '!cpj':
ComePlayJoin(user, message);
break;
case '!comeplayleave':
case '!cpleave':
case '!cpl':
ComePlayLeave(user, message);
break;
}
if (message.channel.name != 'botspam' && !message.channel.recipient) {
return;
}
switch(message.content.toLowerCase()) {
case '!servers':
case '!srv':
......@@ -123,16 +144,6 @@ client.on('message', message => {
message.channel.send(messageQuickPlay);
console.log('messageQuickPlay sent');
break;
case '!comeplayjoin':
case '!cpjoin':
case '!cpj':
ComePlayJoin(user, message);
break;
case '!comeplayleave':
case '!cpleave':
case '!cpl':
ComePlayLeave(user, message);
break;
}
});
......@@ -153,6 +164,7 @@ function ComePlayJoin(user, message) {
// console.log(`User: `, user);
const userx = server.member(message.author);
// const username = message.author.username;
// console.log(`Userx: `, userx);
if (server) {
......@@ -160,18 +172,18 @@ function ComePlayJoin(user, message) {
const rolecheckx = server.member(userx).roles.cache.find(rolecheck => rolecheck.name === RoleName);
// console.log('Rolecheckx: ', rolecheckx);
if (rolecheckx) {
message.channel.send('You are already part of come-play channel\n' + 'Link to the channel: https://discordapp.com/channels/' + DiscordChannelID + '/' + channelx.id + '\nType **!cpleave** to leave the come-play channel');
console.log('You are already part of come-play channel\n' + 'Link to the channel: https://discordapp.com/channels/' + DiscordChannelID + '/' + channelx.id + '\nType **!cpleave** to leave the come-play channel');
message.channel.send('<@!' + userx + '>\nYou are already part of come-play channel\n' + 'Link to the channel: https://discordapp.com/channels/' + DiscordChannelID + '/' + channelx.id + '\nType **!cpleave** to leave the come-play channel');
console.log('<@!' + userx + '>\nYou are already part of come-play channel\n' + 'Link to the channel: https://discordapp.com/channels/' + DiscordChannelID + '/' + channelx.id + '\nType **!cpleave** to leave the come-play channel');
}
else {
server.member(userx).roles.add(rolex).catch(console.error);
if (console.error) {
message.channel.send('You have been added to come-play channel\n' + 'Link to the channel: https://discordapp.com/channels/' + DiscordChannelID + '/' + channelx.id + '\nType **!cpleave** to leave the come-play channel');
console.log('You have been added to come-play channel\n' + 'Link to the channel: https://discordapp.com/channels/' + DiscordChannelID + '/' + channelx.id + '\nType **!cpleave** to leave the come-play channel');
message.channel.send('<@!' + userx + '>\nYou have been added to come-play channel\n' + 'Link to the channel: https://discordapp.com/channels/' + DiscordChannelID + '/' + channelx.id + '\nType **!cpleave** to leave the come-play channel');
console.log('<@!' + userx + '>\nYou have been added to come-play channel\n' + 'Link to the channel: https://discordapp.com/channels/' + DiscordChannelID + '/' + channelx.id + '\nType **!cpleave** to leave the come-play channel');
}
else {
message.channel.send('Bot does not have permission to add you to come-play channel\nContact administrator.');
console.log('Bot does not have permission to add you to come-play channel\nContact administrator.');
message.channel.send('<@!' + userx + '>\nBot does not have permission to add you to come-play channel\nContact administrator.');
console.log('<@!' + userx + '>\nBot does not have permission to add you to come-play channel\nContact administrator.');
}
}
}
......@@ -202,6 +214,7 @@ function ComePlayLeave(user, message) {
// console.log(`User: `, user);
const userx = server.member(message.author);
// const username = message.author.username;
// console.log(`Userx: `, userx);
if (server) {
......@@ -211,17 +224,17 @@ function ComePlayLeave(user, message) {
if (rolecheckx) {
server.member(userx).roles.remove(rolex).catch(console.error);
if (console.error) {
message.channel.send('You have been removed from come-play channel\nType **!cpjoin** to join again.');
console.log('You have been removed from come-play channel\nType **!cpjoin** to join again.');
message.channel.send('<@!' + userx + '>\nYou have been removed from come-play channel\nType **!cpjoin** to join again.');
console.log('<@!' + userx + '>\nYou have been removed from come-play channel\nType **!cpjoin** to join again.');
}
else {
message.channel.send('Bot does not have permission to add you to come-play channel\nContact administrator.');
console.log('Bot does not have permission to add you to come-play channel\nContact administrator.');
message.channel.send('<@!' + userx + '>\nBot does not have permission to add you to come-play channel\nContact administrator.');
console.log('<@!' + userx + '>\nBot does not have permission to add you to come-play channel\nContact administrator.');
}
}
else {
message.channel.send('You are not part of come-play channel\nType **!cpjoin** to join the come-play channel');
console.log('You are not part of come-play channel\nType **!cpjoin** to join the come-play channel');
message.channel.send('<@!' + userx + '>\nYou are not part of come-play channel\nType **!cpjoin** to join the come-play channel');
console.log('<@!' + userx + '>\nYou are not part of come-play channel\nType **!cpjoin** to join the come-play channel');
}
}
}
......
......@@ -19,11 +19,11 @@ DirectMessage the bot !srv to get info about servers
**!cpjoin / !cpleave**
If bot has permission MANAGE_ROLES on the Discord server, users can DirectMessage the bot !cpjoin or !cpleave
Bot will assign or unassign role Come-Play notifier to the user on the Discord server
![!srv](https://i.imgur.com/uCEFwwl.png)
![!cpjoin / !cpleave](https://i.imgur.com/uCEFwwl.png)
**Come-Play Notifier**
If bot has permission SEND_MESSAGES in come-play channel then he will send notification message in come-play channel
If bot has permission MENTION_EVERYONE in come-play channel then he will also mention @here
This message can only happen once in 12 hours
Only if Lobby has 6 or more players, or only if regular server has 12 or more players
![!srv](https://i.imgur.com/NoDAvV7.png)
\ No newline at end of file
![Come-Play Notifier](https://i.imgur.com/NoDAvV7.png)
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment