feat: Allow multiples roles to train the bot (#8)

This commit is contained in:
GeekCorner
2023-06-24 21:46:31 +02:00
committed by GitHub
parent 8b9f45dc22
commit 1cd481040f
7 changed files with 40 additions and 34 deletions

View File

@@ -1,3 +1,4 @@
import { checkForPerms } from '../utils/checkPerms.js';
import trainAISelectMenu from '../utils/trainAISelectMenu.js';
export default {
@@ -6,9 +7,7 @@ export default {
},
async execute(helper, config, interaction) {
if (
interaction.member.roles.highest.comparePositionTo(
config.discord.trainRole
) < 0
checkForPerms(config, interaction.member)
)
return interaction.reply({
content: 'You don\'t have the permission to do this.',

View File

@@ -1,29 +1,29 @@
import { checkForPerms } from '../utils/checkPerms.js';
export default {
data: {
name: 'fb-like'
},
async execute(helper, config, interaction) {
if (
interaction.member.roles.highest.comparePositionTo(
config.discord.trainRole
) < 0
)
return interaction.reply({
content: 'You don\'t have the permission to do this.',
ephemeral: true
});
// FIXME: somehow get the intent?
// maybe storing in a collection and fetching the msg id with its label?
/*
helper.sendTrainData(interactedMessage, i.values[0]);
data: {
name: 'fb-like'
},
async execute(helper, config, interaction) {
if (
checkForPerms(config, interaction.member)
)
return interaction.reply({
content: 'You don\'t have the permission to do this.',
ephemeral: true
});
// FIXME: somehow get the intent?
// maybe storing in a collection and fetching the msg id with its label?
/*
helper.sendTrainData(interactedMessage, i.values[0]);
i.reply({ content: 'Sent training data to server.', ephemeral: true });
i.reply({ content: 'Sent training data to server.', ephemeral: true });
interaction.message.edit({ components: [] });
*/
interaction.reply({
content: 'Feature currently not available. Please use the dislike button.',
ephemeral: true
})
}
interaction.message.edit({ components: [] });
*/
interaction.reply({
content: 'Feature currently not available. Please use the dislike button.',
ephemeral: true
});
}
};

View File

@@ -1,5 +1,6 @@
import { ContextMenuCommandBuilder, ApplicationCommandType } from 'discord.js';
import trainAISelectMenu from '../utils/trainAISelectMenu.js';
import { checkForPerms } from '../utils/checkPerms.js';
export default {
data: new ContextMenuCommandBuilder()
@@ -7,9 +8,7 @@ export default {
.setType(ApplicationCommandType.Message),
async execute(helper, config, interaction) {
if (
interaction.member.roles.highest.comparePositionTo(
interaction.member.guild.roles.cache.get(config.discord.trainRole)
) < 0
checkForPerms(config, interaction.member)
)
return interaction.reply({
content: 'You don\'t have the permission to do this.',

View File

@@ -1,6 +1,6 @@
{
"discord": {
"trainRole": "955220417969262612",
"trainRoles": ["1019903194941362198", "955220417969262612"],
"botId": "1038762591805247518",
"ignoreRole": "1027874293192863765"
},

View File

@@ -1,6 +1,6 @@
{
"discord": {
"trainRole": "955220417969262612",
"trainRoles": ["1019903194941362198", "955220417969262612"],
"botId": "1038762591805247518",
"ignoreRole": "1027874293192863765"
},

View File

@@ -79,4 +79,4 @@ for (const file of helperEventFiles) {
}
}
client.login(process.env.DISCORD_TOKEN);
client.login(process.env.DISCORD_TOKEN);

View File

@@ -0,0 +1,8 @@
export function checkForPerms(config, member) {
for (let role in config.discord.trainRoles) {
if (member.roles.cache.get(role)) {
return true;
}
}
return false;
}