Not Toby
Not Toby
DIAdiscord.js - Imagine an app
Created by Not Toby on 10/12/2023 in #djs-questions
Button does not reflect newest data when use next or previous page
No description
4 replies
DIAdiscord.js - Imagine an app
Created by Not Toby on 10/12/2023 in #djs-questions
The reply to this interaction has already been sent or deferred.
No description
7 replies
DIAdiscord.js - Imagine an app
Created by Not Toby on 10/9/2023 in #djs-questions
Slash Command Error - I have no idea why
current problem is between data.js in command folder and index.js There are 2 problem. First is Warning: Accessing non-existent property 'database' of module exports inside circular dependency it seem like it cant database property in index? and get data from data folder? Second is I do not know what wrong with my data.js? console log:
root@API:~/discord_bot# node index.js
(node:7813) Warning: Accessing non-existent property 'database' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
Bot is now online!
/root/discord_bot/node_modules/@discordjs/rest/dist/index.js:687
throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
^

DiscordAPIError[50035]: Invalid Form Body
0.name[BASE_TYPE_REQUIRED]: This field is required
at handleErrors (/root/discord_bot/node_modules/@discordjs/rest/dist/index.js:687:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async SequentialHandler.runRequest (/root/discord_bot/node_modules/@discordjs/rest/dist/index.js:1072:23)
at async SequentialHandler.queueRequest (/root/discord_bot/node_modules/@discordjs/rest/dist/index.js:913:14)
at async _REST.request (/root/discord_bot/node_modules/@discordjs/rest/dist/index.js:1218:22)
at async ApplicationCommandManager.set (/root/discord_bot/node_modules/discord.js/src/managers/ApplicationCommandManager.js:171:18) {
requestBody: {
files: undefined,
json: [
{
name: undefined,
name_localizations: undefined,
description: undefined,
nsfw: undefined,
description_localizations: undefined,
type: undefined,
options: undefined,
default_member_permissions: undefined,
dm_permission: undefined
},
{
name: 'ping',
name_localizations: undefined,
description: 'Replies with "pong!"',
nsfw: undefined,
description_localizations: undefined,
type: undefined,
options: undefined,
default_member_permissions: undefined,
dm_permission: undefined
}
]
},
rawError: {
message: 'Invalid Form Body',
code: 50035,
errors: {
'0': { name: { _errors: [ [Object] ] } }
}
},
code: 50035,
status: 400,
method: 'PUT',
url: 'https://discord.com/api/v10/applications/1044260619894931506/commands'
}
root@API:~/discord_bot# node index.js
(node:7813) Warning: Accessing non-existent property 'database' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
Bot is now online!
/root/discord_bot/node_modules/@discordjs/rest/dist/index.js:687
throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
^

DiscordAPIError[50035]: Invalid Form Body
0.name[BASE_TYPE_REQUIRED]: This field is required
at handleErrors (/root/discord_bot/node_modules/@discordjs/rest/dist/index.js:687:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async SequentialHandler.runRequest (/root/discord_bot/node_modules/@discordjs/rest/dist/index.js:1072:23)
at async SequentialHandler.queueRequest (/root/discord_bot/node_modules/@discordjs/rest/dist/index.js:913:14)
at async _REST.request (/root/discord_bot/node_modules/@discordjs/rest/dist/index.js:1218:22)
at async ApplicationCommandManager.set (/root/discord_bot/node_modules/discord.js/src/managers/ApplicationCommandManager.js:171:18) {
requestBody: {
files: undefined,
json: [
{
name: undefined,
name_localizations: undefined,
description: undefined,
nsfw: undefined,
description_localizations: undefined,
type: undefined,
options: undefined,
default_member_permissions: undefined,
dm_permission: undefined
},
{
name: 'ping',
name_localizations: undefined,
description: 'Replies with "pong!"',
nsfw: undefined,
description_localizations: undefined,
type: undefined,
options: undefined,
default_member_permissions: undefined,
dm_permission: undefined
}
]
},
rawError: {
message: 'Invalid Form Body',
code: 50035,
errors: {
'0': { name: { _errors: [ [Object] ] } }
}
},
code: 50035,
status: 400,
method: 'PUT',
url: 'https://discord.com/api/v10/applications/1044260619894931506/commands'
}
14 replies
DIAdiscord.js - Imagine an app
Created by Not Toby on 10/9/2023 in #djs-questions
Slash Command Question
const { SlashCommandBuilder } = require('@discordjs/builders');

module.exports = {
name: 'data',
description: 'Commands related to user data.',

subcommands: [
new SlashCommandBuilder()
.setName('create')
.setDescription('Creates a new user account.'),
new SlashCommandBuilder()
.setName('delete')
.setDescription('Deletes all data of the specified user.')
.addStringOption(option => option.setName('user_id').setDescription('The ID of the user to delete data for.').setRequired(true)),
new SlashCommandBuilder()
.setName('showraw')
.setDescription('Shows all data of a specified user.')
.addStringOption(option => option.setName('user_id').setDescription('The ID of the user to show data for.').setRequired(true)),

],

async function dataCommand(client, interaction) {
// Get the subcommand name
const subcommandName = interaction.options.getSubcommand();

// Check if the subcommand name is valid
if (!subcommandName) {
// The user did not specify a subcommand
await interaction.reply('You need to specify a subcommand.');
return;
}

// Call the appropriate function based on the subcommand name
switch (subcommandName) {
case 'create':
await create(client, interaction);
break;

case 'delete':
await deleteUserData(client, interaction);
break;

case 'showraw':
await showraw(client, interaction);
break;
}
}
const { SlashCommandBuilder } = require('@discordjs/builders');

module.exports = {
name: 'data',
description: 'Commands related to user data.',

subcommands: [
new SlashCommandBuilder()
.setName('create')
.setDescription('Creates a new user account.'),
new SlashCommandBuilder()
.setName('delete')
.setDescription('Deletes all data of the specified user.')
.addStringOption(option => option.setName('user_id').setDescription('The ID of the user to delete data for.').setRequired(true)),
new SlashCommandBuilder()
.setName('showraw')
.setDescription('Shows all data of a specified user.')
.addStringOption(option => option.setName('user_id').setDescription('The ID of the user to show data for.').setRequired(true)),

],

async function dataCommand(client, interaction) {
// Get the subcommand name
const subcommandName = interaction.options.getSubcommand();

// Check if the subcommand name is valid
if (!subcommandName) {
// The user did not specify a subcommand
await interaction.reply('You need to specify a subcommand.');
return;
}

// Call the appropriate function based on the subcommand name
switch (subcommandName) {
case 'create':
await create(client, interaction);
break;

case 'delete':
await deleteUserData(client, interaction);
break;

case 'showraw':
await showraw(client, interaction);
break;
}
}
I strongly believe i did something wrong related to SlashCommandBuilder but dunno how to fix So I want to create a slash command like /data <option_require> option is create, delete, showraw. when select delete or showraw // <option2> will appear where i can input userid or something
11 replies