Auth
Auth
DIAdiscord.js - Imagine a bot
Created by Auth on 9/20/2024 in #djs-questions
which perms do i need
i have this event
client.on('guildMemberUpdate', async (oldMember, newMember) => {
await handleMemberUpdate(oldMember, newMember, clientId)
});
client.on('guildMemberUpdate', async (oldMember, newMember) => {
await handleMemberUpdate(oldMember, newMember, clientId)
});
but its not firing when i remove someones timeout
40 replies
DIAdiscord.js - Imagine a bot
Created by Auth on 9/19/2024 in #djs-questions
slash command getting messed up
so yeah same issue again the previous slash command aint getting deleted heres deploy-commands.js
const { REST, Routes } = require('discord.js');
const fs = require('node:fs');
const path = require('node:path');
const { clientId, token } = require('./config.json');

// Validate required configuration
if (!token || !clientId) {
console.error('Missing bot token or clientId in config.json');
process.exit(1);
}

const commands = [];
const commandsPath = path.join(__dirname, 'commands', 'utility');
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));

// Load commands into an array for deployment
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.`);
}
}

const rest = new REST({ version: '10' }).setToken(token);

// Function to override commands
const overrideCommands = async () => {
try {
console.log(`Started overriding ${commands.length} application (/) commands.`);

// Override existing commands with the new set
const data = await rest.put(
Routes.applicationCommands(clientId),
{ body: commands }
);

console.log(`Successfully overrode ${data.length} application (/) commands.`);
} catch (error) {
console.error('Error overriding application commands:', error);
}
};

// Execute the override
overrideCommands();
const { REST, Routes } = require('discord.js');
const fs = require('node:fs');
const path = require('node:path');
const { clientId, token } = require('./config.json');

// Validate required configuration
if (!token || !clientId) {
console.error('Missing bot token or clientId in config.json');
process.exit(1);
}

const commands = [];
const commandsPath = path.join(__dirname, 'commands', 'utility');
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));

// Load commands into an array for deployment
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.`);
}
}

const rest = new REST({ version: '10' }).setToken(token);

// Function to override commands
const overrideCommands = async () => {
try {
console.log(`Started overriding ${commands.length} application (/) commands.`);

// Override existing commands with the new set
const data = await rest.put(
Routes.applicationCommands(clientId),
{ body: commands }
);

console.log(`Successfully overrode ${data.length} application (/) commands.`);
} catch (error) {
console.error('Error overriding application commands:', error);
}
};

// Execute the override
overrideCommands();
12 replies
DIAdiscord.js - Imagine a bot
Created by Auth on 9/19/2024 in #djs-questions
which permisson i need
i have this event handler but it requires intent but it only works when i give it admin i generally cant give it admin but which perm i need to give exactly https://pastebin.com/vcp0cjY4 i am talking about automodactionexectution what happens is when it dont have admin it runs another event of updatemember https://pastebin.com/mGZT8HxX which shows me as timeout moderator but when i give it server insight perms it shows itself as timeout mod lmao idk what am i suppose to do
10 replies
DIAdiscord.js - Imagine a bot
Created by Auth on 9/19/2024 in #djs-questions
unable to delete slash commands
like i originally had a different code now i am using that same bot for another code but previous slash commands aint getting deleted im running this script but new commands got registerd so now its all a mess https://pastebin.com/QJt1Q2zR
7 replies
DIAdiscord.js - Imagine a bot
Created by Auth on 9/19/2024 in #djs-questions
slash command not getting registerd
index.js - https://pastebin.com/v0UAU7g1 sample slash command - https://pastebin.com/U32EXgVN file structure - . ├── commands │   ├── helper │   │   ├── handleDirectMessage.js │   │   ├── handleMemberUpdate.js │   │   ├── intervalTimeoutRemove.js │   │   ├── leetcode.js │   │   └── run-migrations.js │   └── utility │   ├── approve.js │   ├── ping.js │   └── server.js ├── config.json ├── db.js ├── index.js ├── migrations │   └── 0000_create_users_table.js ├── models │   └── User.js ├── mydatabase.sqlite ├── package.json ├── package-lock.json └── payload └── leetcode.txt
23 replies
DIAdiscord.js - Imagine a bot
Created by Auth on 9/18/2024 in #djs-questions
How can i detect someone timeout got removed?
i wanna delete the user from the db whos timeout gets removed, till i know only 2 possiblity exists of timeout getting removed - timeout period got over - someone manually removed it
10 replies
DIAdiscord.js - Imagine a bot
Created by Auth on 9/18/2024 in #djs-questions
AutoModerationActionExecution event
client.on(Events.AutoModerationActionExecution, async (autoModerationActionExecution) => {
try {
console.log('AutoModerationActionExecution event triggered:');

// Log relevant properties
console.log(`Action ID: ${autoModerationActionExecution.action.id}`);
console.log(`Action Type: ${autoModerationActionExecution.action.type}`);
console.log(`Action Metadata: ${autoModerationActionExecution.action.metadata}`);
console.log(`Execution Status: ${autoModerationActionExecution.status}`);
console.log(`Rule ID: ${autoModerationActionExecution.ruleId}`);
console.log(`Rule Name: ${autoModerationActionExecution.ruleName}`);
console.log(`User ID: ${autoModerationActionExecution.user.id}`);
console.log(`User Tag: ${autoModerationActionExecution.user.tag}`);
console.log(`Channel ID: ${autoModerationActionExecution.channel.id}`);
console.log(`Channel Name: ${autoModerationActionExecution.channel.name}`);
console.log(`Content: ${autoModerationActionExecution.content}`);

// Add custom logic here to handle the auto-moderation action execution
// For example, send a message to a log channel or notify moderators
} catch (error) {
console.error('Error handling AutoModerationActionExecution event:', error);
}
});
client.on(Events.AutoModerationActionExecution, async (autoModerationActionExecution) => {
try {
console.log('AutoModerationActionExecution event triggered:');

// Log relevant properties
console.log(`Action ID: ${autoModerationActionExecution.action.id}`);
console.log(`Action Type: ${autoModerationActionExecution.action.type}`);
console.log(`Action Metadata: ${autoModerationActionExecution.action.metadata}`);
console.log(`Execution Status: ${autoModerationActionExecution.status}`);
console.log(`Rule ID: ${autoModerationActionExecution.ruleId}`);
console.log(`Rule Name: ${autoModerationActionExecution.ruleName}`);
console.log(`User ID: ${autoModerationActionExecution.user.id}`);
console.log(`User Tag: ${autoModerationActionExecution.user.tag}`);
console.log(`Channel ID: ${autoModerationActionExecution.channel.id}`);
console.log(`Channel Name: ${autoModerationActionExecution.channel.name}`);
console.log(`Content: ${autoModerationActionExecution.content}`);

// Add custom logic here to handle the auto-moderation action execution
// For example, send a message to a log channel or notify moderators
} catch (error) {
console.error('Error handling AutoModerationActionExecution event:', error);
}
});
WHY IT AINT DETECTING AUTOMOD ACTIONS?
17 replies
DIAdiscord.js - Imagine a bot
Created by Auth on 9/15/2024 in #djs-questions
how to get this typa button
No description
11 replies
DIAdiscord.js - Imagine a bot
Created by Auth on 9/15/2024 in #djs-questions
"Unkown command" when using context command
so heres my code i've no idea why the context command says unkown command
14 replies
DIAdiscord.js - Imagine a bot
Created by Auth on 9/15/2024 in #djs-questions
lil doubt
like i wanna make a slash command when i use that slash command while replying to some guy, the message i am replying to should get deleted
27 replies
DIAdiscord.js - Imagine a bot
Created by Auth on 9/10/2024 in #djs-questions
Invalid bitfield flag or number: undefined.
WHAT DOES THIS EVEN MEANS
42 replies
DIAdiscord.js - Imagine a bot
Created by Auth on 9/10/2024 in #djs-questions
can send normal message but cant send embded message
try {
// Send DM to the user with the LeetCode question
await member.user.send(
`You have been timed out in ${member.guild.name}. To get your timeout removed, solve this LeetCode question and reply with submission link or screenshot: ${randomLeetCodeQuestion}`,
);
console.log(`Successfully sent LeetCode question to ${member.user.tag}`);
const redirectChannel = member.guild.channels.cache.get(
config.LEETCODE_LOGS_CHANNEL_ID,
);
await redirectChannel.send(
`Successfully sent LeetCode question to ${member.user.tag}`,
);
} catch (error) {
console.error(`Failed to send DM to ${member.user.tag}:`, error);
}
try {
// Send DM to the user with the LeetCode question
await member.user.send(
`You have been timed out in ${member.guild.name}. To get your timeout removed, solve this LeetCode question and reply with submission link or screenshot: ${randomLeetCodeQuestion}`,
);
console.log(`Successfully sent LeetCode question to ${member.user.tag}`);
const redirectChannel = member.guild.channels.cache.get(
config.LEETCODE_LOGS_CHANNEL_ID,
);
await redirectChannel.send(
`Successfully sent LeetCode question to ${member.user.tag}`,
);
} catch (error) {
console.error(`Failed to send DM to ${member.user.tag}:`, error);
}
this code works
23 replies
DIAdiscord.js - Imagine a bot
Created by Auth on 9/9/2024 in #djs-questions
unable to send message in channel
// Send DM to the user with the LeetCode question
await member.user.send(
`You have been timed out in ${member.guild.name}. To get your timeout removed, solve this LeetCode question and reply with submission link or screenshot: ${randomLeetCodeQuestion}`,
);
const redirectChannel = member.guild.channels.cache.get(config.REDIRECT_CHANNEL_ID);
await redirectChannel.send("yo");
// Send DM to the user with the LeetCode question
await member.user.send(
`You have been timed out in ${member.guild.name}. To get your timeout removed, solve this LeetCode question and reply with submission link or screenshot: ${randomLeetCodeQuestion}`,
);
const redirectChannel = member.guild.channels.cache.get(config.REDIRECT_CHANNEL_ID);
await redirectChannel.send("yo");
13 replies
DIAdiscord.js - Imagine a bot
Created by Auth on 9/9/2024 in #djs-questions
others unable to see slash commands
well i want so when someone execute a slash commands other can also see it but in this case only i am able to see it
await interaction.reply({
content: `Removed timeout for ${member.user.tag}.`,
});
await interaction.reply({
content: `Removed timeout for ${member.user.tag}.`,
});
31 replies