mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-11 13:56:15 +00:00
feat: Allow multiples roles to train the bot (#8)
This commit is contained in:
@@ -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.',
|
||||
|
||||
@@ -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
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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.',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"discord": {
|
||||
"trainRole": "955220417969262612",
|
||||
"trainRoles": ["1019903194941362198", "955220417969262612"],
|
||||
"botId": "1038762591805247518",
|
||||
"ignoreRole": "1027874293192863765"
|
||||
},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"discord": {
|
||||
"trainRole": "955220417969262612",
|
||||
"trainRoles": ["1019903194941362198", "955220417969262612"],
|
||||
"botId": "1038762591805247518",
|
||||
"ignoreRole": "1027874293192863765"
|
||||
},
|
||||
|
||||
@@ -79,4 +79,4 @@ for (const file of helperEventFiles) {
|
||||
}
|
||||
}
|
||||
|
||||
client.login(process.env.DISCORD_TOKEN);
|
||||
client.login(process.env.DISCORD_TOKEN);
|
||||
8
apps/bot-discord/src/utils/checkPerms.js
Normal file
8
apps/bot-discord/src/utils/checkPerms.js
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user