Somebody
Somebody
DIAdiscord.js - Imagine an app
Created by Somebody on 2/23/2024 in #djs-questions
Setting different commands for different types of servers.
that worked, thanks a lot.
25 replies
DIAdiscord.js - Imagine an app
Created by Somebody on 2/23/2024 in #djs-questions
Setting different commands for different types of servers.
i suspect its due to the async nature but im unsure
25 replies
DIAdiscord.js - Imagine an app
Created by Somebody on 2/23/2024 in #djs-questions
Setting different commands for different types of servers.
whilst sometimes it works perfect
25 replies
DIAdiscord.js - Imagine an app
Created by Somebody on 2/23/2024 in #djs-questions
Setting different commands for different types of servers.
however,, sometimes it compltely deletes all the faction commands (im trying to refresh them)
25 replies
DIAdiscord.js - Imagine an app
Created by Somebody on 2/23/2024 in #djs-questions
Setting different commands for different types of servers.
so i did what you said, all works fine except, i wrote this refresh commands module based on faction type
25 replies
DIAdiscord.js - Imagine an app
Created by Somebody on 2/23/2024 in #djs-questions
Setting different commands for different types of servers.
25 replies
DIAdiscord.js - Imagine an app
Created by Somebody on 2/23/2024 in #djs-questions
Setting different commands for different types of servers.
ok i'll try something and be back
25 replies
DIAdiscord.js - Imagine an app
Created by Somebody on 2/23/2024 in #djs-questions
Setting different commands for different types of servers.
factions are common cmds
25 replies
DIAdiscord.js - Imagine an app
Created by Somebody on 2/23/2024 in #djs-questions
Setting different commands for different types of servers.
same with law
25 replies
DIAdiscord.js - Imagine an app
Created by Somebody on 2/23/2024 in #djs-questions
Setting different commands for different types of servers.
criminal folder has criminal specific stuff (which is a faction type for a game)
25 replies
DIAdiscord.js - Imagine an app
Created by Somebody on 2/23/2024 in #djs-questions
Setting different commands for different types of servers.
No description
25 replies
DIAdiscord.js - Imagine an app
Created by Somebody on 2/23/2024 in #djs-questions
Setting different commands for different types of servers.
this is for just one guild
25 replies
DIAdiscord.js - Imagine an app
Created by Somebody on 2/23/2024 in #djs-questions
Setting different commands for different types of servers.
can you elaborate further? how can i do it
25 replies
DIAdiscord.js - Imagine an app
Created by Somebody on 2/23/2024 in #djs-questions
Setting different commands for different types of servers.
const { REST, Routes } = require('discord.js');
clientId = '1172582289805430794';
guildId = '1172581606687518750';
const fs = require('node:fs');
const path = require('node:path');
token = process.env.SSRP_BOT_TOKEN;
const rest = new REST().setToken(token);

rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: [] })
.then(() => console.log('Successfully deleted all guild commands.'))
.catch(console.error);

rest.put(Routes.applicationCommands(clientId), { body: [] })
.then(() => console.log('Successfully deleted all application commands.'))
.catch(console.error);


const commands = [];
const foldersPath = path.join(__dirname, 'commands');
const commandFolders = fs.readdirSync(foldersPath);

for (const folder of commandFolders) {
// Grab all the command files from the commands directory you created earlier
const commandsPath = path.join(foldersPath, folder);
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
const command = require(filePath);
if ('data' in command && 'execute' in command) {
commands.push(command.data.toJSON());
} else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
}
}
}
(async () => {
try {
console.log(`Started refreshing ${commands.length} application (/) commands.`);
const data = await rest.put(
Routes.applicationGuildCommands(clientId, guildId),
{ body: commands },
);

console.log(`Successfully reloaded ${data.length} application (/) commands.`);
} catch (error) {
console.error(error);
}
})();
const { REST, Routes } = require('discord.js');
clientId = '1172582289805430794';
guildId = '1172581606687518750';
const fs = require('node:fs');
const path = require('node:path');
token = process.env.SSRP_BOT_TOKEN;
const rest = new REST().setToken(token);

rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: [] })
.then(() => console.log('Successfully deleted all guild commands.'))
.catch(console.error);

rest.put(Routes.applicationCommands(clientId), { body: [] })
.then(() => console.log('Successfully deleted all application commands.'))
.catch(console.error);


const commands = [];
const foldersPath = path.join(__dirname, 'commands');
const commandFolders = fs.readdirSync(foldersPath);

for (const folder of commandFolders) {
// Grab all the command files from the commands directory you created earlier
const commandsPath = path.join(foldersPath, folder);
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
const command = require(filePath);
if ('data' in command && 'execute' in command) {
commands.push(command.data.toJSON());
} else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
}
}
}
(async () => {
try {
console.log(`Started refreshing ${commands.length} application (/) commands.`);
const data = await rest.put(
Routes.applicationGuildCommands(clientId, guildId),
{ body: commands },
);

console.log(`Successfully reloaded ${data.length} application (/) commands.`);
} catch (error) {
console.error(error);
}
})();
this is how im doing it,
25 replies
DIAdiscord.js - Imagine an app
Created by Somebody on 2/16/2024 in #djs-questions
how to make bot handle external embed
thank you^
38 replies
DIAdiscord.js - Imagine an app
Created by Somebody on 2/16/2024 in #djs-questions
how to make bot handle external embed
its unnecessary. However it was solved by creating the component using the webhook from my app (which the bot created btw) later i got the bot to respond to it (as it would normally) Here's how i created the component:
$jsonBody = '{
"components": [
{
"type": 1,
"components": [
{
"style": 1,
"label": "test",
"custom_id": "row_0_button_0",
"disabled": false,
"type": 2
}
]
}
]
}'

Invoke-RestMethod -Uri $webhookUrl -Method Post -Body $jsonBody -ContentType "application/json"
$jsonBody = '{
"components": [
{
"type": 1,
"components": [
{
"style": 1,
"label": "test",
"custom_id": "row_0_button_0",
"disabled": false,
"type": 2
}
]
}
]
}'

Invoke-RestMethod -Uri $webhookUrl -Method Post -Body $jsonBody -ContentType "application/json"
Here's how i handled the event in bot:
client.on(Events.InteractionCreate, async interaction => {
if (!interaction.isButton()) return; // Ignore interactions that are not buttons
console.log("button interaction recieved.")
// Check if the button is the one you're interested in
if (interaction.customId === 'row_0_button_0') {
console.log("responding to button interaction.")
// Reply to the interaction
await interaction.reply('You clicked the button!');
}
});
client.on(Events.InteractionCreate, async interaction => {
if (!interaction.isButton()) return; // Ignore interactions that are not buttons
console.log("button interaction recieved.")
// Check if the button is the one you're interested in
if (interaction.customId === 'row_0_button_0') {
console.log("responding to button interaction.")
// Reply to the interaction
await interaction.reply('You clicked the button!');
}
});
38 replies
DIAdiscord.js - Imagine an app
Created by Somebody on 2/16/2024 in #djs-questions
how to make bot handle external embed
basically a server
38 replies
DIAdiscord.js - Imagine an app
Created by Somebody on 2/16/2024 in #djs-questions
how to make bot handle external embed
well its samp, written in pawn
38 replies
DIAdiscord.js - Imagine an app
Created by Somebody on 2/16/2024 in #djs-questions
how to make bot handle external embed
ohhh, i'll try that thanks
38 replies
DIAdiscord.js - Imagine an app
Created by Somebody on 2/16/2024 in #djs-questions
how to make bot handle external embed
is my point 2 possible?
38 replies