mirror of
https://github.com/PretendoNetwork/Yamamura.git
synced 2024-05-31 19:17:50 -04:00
remove safety checks
This commit is contained in:
parent
ae55d54292
commit
088ca51fcd
|
@ -1,5 +1,4 @@
|
||||||
{
|
{
|
||||||
"bot_token": "TOKEN",
|
"bot_token": "TOKEN",
|
||||||
"guild_id": "GUILDID",
|
|
||||||
"application_id": "APPID"
|
"application_id": "APPID"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
const Discord = require('discord.js');
|
const Discord = require('discord.js');
|
||||||
const db = require('../db');
|
const db = require('../db');
|
||||||
const { guild_id } = require('../../config.json');
|
|
||||||
const { SlashCommandBuilder } = require('@discordjs/builders');
|
const { SlashCommandBuilder } = require('@discordjs/builders');
|
||||||
|
|
||||||
const editableOptions = [
|
const editableOptions = [
|
||||||
|
@ -13,16 +12,11 @@ const editableOptions = [
|
||||||
'stats.channels.bots',
|
'stats.channels.bots',
|
||||||
];
|
];
|
||||||
|
|
||||||
async function isValidkey(interaction) {
|
async function verifyInputtedKey(interaction) {
|
||||||
const key = interaction.options.getString('key');
|
const key = interaction.options.getString('key');
|
||||||
if (!editableOptions.includes(key)) {
|
if (!editableOptions.includes(key)) {
|
||||||
await interaction.reply({
|
throw new Error('Cannot edit this setting - not a valid setting');
|
||||||
content: 'Cannot edit this setting - not a valid setting',
|
|
||||||
ephemeral: true,
|
|
||||||
});
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,17 +24,9 @@ async function isValidkey(interaction) {
|
||||||
* @param {Discord.CommandInteraction} interaction
|
* @param {Discord.CommandInteraction} interaction
|
||||||
*/
|
*/
|
||||||
async function settingsHandler(interaction) {
|
async function settingsHandler(interaction) {
|
||||||
if (interaction.guildId !== guild_id) {
|
|
||||||
await interaction.reply({
|
|
||||||
content: 'Cannot edit this setting - this guild is not whitelisted',
|
|
||||||
ephemeral: true,
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const key = interaction.options.getString('key');
|
const key = interaction.options.getString('key');
|
||||||
if (interaction.options.getSubcommand() === 'get') {
|
if (interaction.options.getSubcommand() === 'get') {
|
||||||
if (!(await isValidkey(interaction))) return;
|
await verifyInputtedKey(interaction);
|
||||||
// this is hellish string concatenation, I know
|
// this is hellish string concatenation, I know
|
||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
content:
|
content:
|
||||||
|
@ -54,7 +40,7 @@ async function settingsHandler(interaction) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (interaction.options.getSubcommand() === 'set') {
|
if (interaction.options.getSubcommand() === 'set') {
|
||||||
if (!(await isValidkey(interaction))) return;
|
await verifyInputtedKey(interaction);
|
||||||
db.getDB().set(key, interaction.options.getString('value'));
|
db.getDB().set(key, interaction.options.getString('value'));
|
||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
content: `setting \`${key}\` has been saved successfully`,
|
content: `setting \`${key}\` has been saved successfully`,
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
const Discord = require('discord.js');
|
const Discord = require('discord.js');
|
||||||
const { SlashCommandBuilder } = require('@discordjs/builders');
|
const { SlashCommandBuilder } = require('@discordjs/builders');
|
||||||
|
|
||||||
const allowedSelfAssignRoles = [
|
|
||||||
'streamping',
|
|
||||||
'updates'
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param {Discord.CommandInteraction} interaction
|
* @param {Discord.CommandInteraction} interaction
|
||||||
|
@ -20,15 +15,6 @@ async function toggleroleHandler(interaction) {
|
||||||
const guild = await interaction.guild.fetch();
|
const guild = await interaction.guild.fetch();
|
||||||
const roles = await guild.roles.fetch();
|
const roles = await guild.roles.fetch();
|
||||||
const role = roles.find(role => role.name.toLowerCase() === roleName);
|
const role = roles.find(role => role.name.toLowerCase() === roleName);
|
||||||
|
|
||||||
if (!allowedSelfAssignRoles.includes(roleName)) {
|
|
||||||
await interaction.followUp({
|
|
||||||
content: 'Requested role is not self-assignable.',
|
|
||||||
ephemeral: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!role) {
|
if (!role) {
|
||||||
await interaction.followUp({
|
await interaction.followUp({
|
||||||
|
@ -73,7 +59,4 @@ module.exports = {
|
||||||
help: 'Toggle on/off a given user role.\n```\nUsage: /togglerole <role>\n```',
|
help: 'Toggle on/off a given user role.\n```\nUsage: /togglerole <role>\n```',
|
||||||
handler: toggleroleHandler,
|
handler: toggleroleHandler,
|
||||||
deploy: command.toJSON(),
|
deploy: command.toJSON(),
|
||||||
extra: {
|
|
||||||
allowedSelfAssignRoles,
|
|
||||||
},
|
|
||||||
};
|
};
|
|
@ -1,7 +1,7 @@
|
||||||
const Discord = require('discord.js');
|
const Discord = require('discord.js');
|
||||||
const glob = require('glob');
|
const glob = require('glob');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { deployCommands, setupGuild } = require('../setup-guild');
|
const { setupGuild } = require('../setup-guild');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -13,9 +13,6 @@ async function readyHandler(client) {
|
||||||
loadBotHandlersCollection('context-menus', client.contextMenus);
|
loadBotHandlersCollection('context-menus', client.contextMenus);
|
||||||
loadBotHandlersCollection('modals', client.modals);
|
loadBotHandlersCollection('modals', client.modals);
|
||||||
loadBotHandlersCollection('select-menus', client.selectMenus);
|
loadBotHandlersCollection('select-menus', client.selectMenus);
|
||||||
|
|
||||||
// deploy commands globally
|
|
||||||
await deployCommands(client);
|
|
||||||
console.log('Registered global commands');
|
console.log('Registered global commands');
|
||||||
|
|
||||||
// setup joined guilds
|
// setup joined guilds
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
const Discord = require('discord.js');
|
const Discord = require('discord.js');
|
||||||
const { allowedSelfAssignRoles } = require('../commands/togglerole').extra;
|
|
||||||
|
|
||||||
const roleSelectMenu = new Discord.MessageSelectMenu();
|
const roleSelectMenu = new Discord.MessageSelectMenu();
|
||||||
roleSelectMenu.setCustomId('role-self-assign');
|
roleSelectMenu.setCustomId('role-self-assign');
|
||||||
|
@ -33,15 +32,6 @@ async function roleSelfAssignHandler(interaction) {
|
||||||
const roles = await guild.roles.fetch();
|
const roles = await guild.roles.fetch();
|
||||||
const role = roles.find(role => role.name.toLowerCase() === roleName);
|
const role = roles.find(role => role.name.toLowerCase() === roleName);
|
||||||
|
|
||||||
if (!allowedSelfAssignRoles.includes(roleName)) {
|
|
||||||
await interaction.followUp({
|
|
||||||
content: 'Requested role is not self-assignable.',
|
|
||||||
ephemeral: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!role) {
|
if (!role) {
|
||||||
await interaction.followUp({
|
await interaction.followUp({
|
||||||
content: 'Unable to find the requested role. Contact and admin as soon as possible',
|
content: 'Unable to find the requested role. Contact and admin as soon as possible',
|
||||||
|
|
|
@ -2,7 +2,7 @@ const Discord = require('discord.js');
|
||||||
const { REST } = require('@discordjs/rest');
|
const { REST } = require('@discordjs/rest');
|
||||||
const { Routes } = require('discord-api-types/v10');
|
const { Routes } = require('discord-api-types/v10');
|
||||||
const util = require('./util');
|
const util = require('./util');
|
||||||
const { bot_token: botToken, application_id: applicationId } = require('../config.json');
|
const { bot_token: botToken } = require('../config.json');
|
||||||
const rest = new REST({ version: '10' }).setToken(botToken);
|
const rest = new REST({ version: '10' }).setToken(botToken);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,23 +47,6 @@ async function deployCommandsToGuild(guild) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function deployCommands(client) {
|
|
||||||
const deploy = [];
|
|
||||||
|
|
||||||
client.commands.forEach((command) => {
|
|
||||||
deploy.push(command.deploy);
|
|
||||||
});
|
|
||||||
|
|
||||||
client.contextMenus.forEach((contextMenu) => {
|
|
||||||
deploy.push(contextMenu.deploy);
|
|
||||||
});
|
|
||||||
|
|
||||||
await rest.put(Routes.applicationCommands(applicationId), {
|
|
||||||
body: deploy,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
setupGuild,
|
setupGuild,
|
||||||
deployCommands,
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue