-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.js
144 lines (135 loc) · 5 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
// Require the necessary discord.js classes
const { Client, Intents, MessageEmbed } = require('discord.js');
const CommandsBuilder = require('./command-builder');
require('dotenv').config();
const LINK = process.env.INVITE_LINK;
// Create a new client instance
const client = new Client({
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES],
});
// When the client is ready, run this code (only once)
client.once('ready', () => {
console.log('Ready!');
client.user.setActivity('/help', {
type: 'LISTENING',
});
});
client.on('messageCreate', (message) => {
// creating a regular expression pattern to match word audrey case-insensitive
const pattern = /(audrey)/i;
// checking if message not from bot
if (!message.author.bot) {
// 2 check
// 1 - if audrey has mentioned using @audreyfeldroy
// 2 - audrey used in message
if (
message.mentions.users.find(
(user) => user.username === 'audreyfeldroy'
) ||
message.content.match(pattern)
) {
// <@501511414654042112> is refering to @audreyfeldroy
message.reply(
`${message.author}, Thank you for your message. <@501511414654042112> is unable to respond via typing. If you see her in the General voice channel feel free to join and communicate, or if there is no one in the voice channel then please wait until they come online.`
);
}
}
});
client.on('interactionCreate', async (interaction) => {
if (!interaction.isCommand()) return;
const { commandName } = interaction;
if (commandName === 'ping') {
await interaction.reply('Pong!');
} else if (commandName === 'server') {
await interaction.reply(
`Server name: ${interaction.guild.name}\nTotal members: ${interaction.guild.memberCount}`
);
} else if (commandName === 'user') {
await interaction.reply('User info.');
} else if (commandName === 'm') {
const minutes = interaction.options.getNumber('minutes') || 30;
await interaction.reply(
`Hi, is anyone around to help <@${interaction.user.id}> for ${minutes} minutes?` +
'@here'
);
} else if (commandName === 'l') {
await interaction.reply(
`Hey everyone, <@${interaction.user.id}> is available at General voice channel. If anyone needs help @here, \nJoin ${LINK}`
);
} else if (commandName === 'p') {
interaction.channel.send(
'Available priorities:\n1. Critical\n2. High \n3. Medium\n4. Low'
);
//if the interaction happening is with bot then the data wouldnt be collected
const filter = (interaction) => {
return !interaction.member.user.bot;
};
//Create a new collector in the channel where /p is used
const collector = interaction.channel.createMessageCollector({
filter,
max: 5,
time: 5000,
});
collector.on('collect', (m) => {
if (m.content === '1') {
return interaction.channel.send(`Priority is **Critical** @here`);
}
if (m.content === '2') {
return interaction.channel.send(`Priority is **high** @here`);
}
if (m.content === '3') {
return interaction.channel.send(`Priority is **Medium** @here`);
}
if (m.content === '4') {
return interaction.channel.send(`Priority is **Low** @here`);
} else {
return interaction.channel.send(`invalid option selected :C`);
}
});
collector.on('end', (collected) =>
console.log(`Collected ${collected.size} items`)
);
await interaction.reply(`This list of Priorities is as follows:`);
} else if (commandName === 'r') {
await interaction.reply(
`Hi! <@${interaction.user.id}> received your message and is available to talk now. Click on the Lounge voice channel on the left to speak now.`
);
// interaction.user.voice.setChannel(process.env.LOUNGE_VC_ID);
} else if (commandName[0] === 'm') {
const newEmbed = new MessageEmbed();
switch (commandName[1]) {
case 'c':
newEmbed.setColor('#ff3030').setTitle(`Priority is **Critical**`);
break;
case 'h':
newEmbed.setColor('#ff7b1c').setTitle(`Priority is **High**`);
break;
case 'm':
newEmbed.setColor('#1c7eff').setTitle(`Priority is **Medium**`);
break;
case 'l':
newEmbed.setColor('#55c278').setTitle(`Priority is **Low**`);
break;
}
await interaction.channel.send(
`Hi is anyone around to help me for 30min minutes? @here`
);
await interaction.reply({ embeds: [newEmbed] });
} else if (commandName === 'help' || commandName === 'h') {
const helpEmbed = new MessageEmbed()
.setColor('#3c7168')
.setAuthor('FingerTips Plugins Commands', client.user.displayAvatarURL())
.addFields(
CommandsBuilder.getAllCommands().map((cmd) => {
return {
name: `\`/${cmd.name}\``,
value: cmd.description,
inline: true,
};
})
);
await interaction.reply({ embeds: [helpEmbed] });
}
});
// Login to Discord with your client's token
client.login(process.env.DISCORD_TOKEN);