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