Serial Designation N
Serial Designation N
DIAdiscord.js - Imagine a bot
Created by Serial Designation N on 7/17/2024 in #djs-questions
Unknown message when deleting bot messages
works now
11 replies
DIAdiscord.js - Imagine a bot
Created by Serial Designation N on 7/17/2024 in #djs-questions
Unknown message when deleting bot messages
Thanks.
11 replies
DIAdiscord.js - Imagine a bot
Created by Serial Designation N on 7/17/2024 in #djs-questions
Unknown message when deleting bot messages
No description
11 replies
DIAdiscord.js - Imagine a bot
Created by Serial Designation N on 7/17/2024 in #djs-questions
Unknown message when deleting bot messages
but when i delete right after i send it, it throws an error in console
11 replies
DIAdiscord.js - Imagine a bot
Created by Serial Designation N on 7/17/2024 in #djs-questions
Unknown message when deleting bot messages
const { SlashCommandBuilder, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, ComponentType } = require('discord.js');
const fs = require('node:fs');
const path = require('node:path');
const { getEmojiURL } = require('../../Modules/GetEmojiURL');

module.exports = {
data: new SlashCommandBuilder()
.setName('help')
.setDescription('Lists all commands.'),
async execute(interaction) {
const client = interaction.client
const commandsPath = path.join(__dirname, '../../Commands_Slash');
const commandFiles = fs.readdirSync(commandsPath, { recursive: true }).filter(file => file.endsWith('.js'));

const commands = commandFiles.map(file => {
const filePath = path.join(commandsPath, file);
const command = require(filePath);
return { name: command.data.name, description: command.data.description };
});

const commandsPerPage = 5;
const totalPages = Math.ceil(commands.length / commandsPerPage);

let currentPage = 0;

async function generateEmbed(page) {
const start = page * commandsPerPage;
const end = start + commandsPerPage;

const embed = new EmbedBuilder()
.setAuthor({
name: "› Help",
iconURL: await getEmojiURL(interaction.client, "1263040971231465504"),
})
.setDescription("› Here are all the available commands:")
.setFooter({ text: `Page ${page + 1} of ${totalPages}` })
.setColor(0x00AE86)
.setImage(client.user.displayAvatarURL({dynamic: true, size: 1024}))

commands.slice(start, end).forEach(command => {
embed.addFields({ name: `/${command.name}`, value: `\`${command.description}\`` });
});

return embed;
};

const embedMessage = await interaction.reply({
embeds: [await generateEmbed(currentPage)],
components: [getRow(currentPage, totalPages)],
fetchReply: true
});

const collector = embedMessage.createMessageComponentCollector({
componentType: ComponentType.Button,
time: 60000
});

collector.on('collect', async i => {
if (i.user.id !== interaction.user.id) {
return i.reply({ content: 'The buttons are disabled for you. To see all commands, do `/help`.', ephemeral: true });
}

if (i.customId === 'previous') {
currentPage = Math.max(currentPage - 1, 0);
} else if (i.customId === 'next') {
currentPage = Math.min(currentPage + 1, totalPages - 1);
}

await i.update({ embeds: [await generateEmbed(currentPage)], components: [getRow(currentPage, totalPages)] });
});

collector.on('end', collected => {
embedMessage.edit({ components: [] });
});

function getRow(page, total) {
return new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId('previous')
.setLabel('Previous')
.setStyle(ButtonStyle.Primary)
.setDisabled(page === 0),
new ButtonBuilder()
.setCustomId('next')
.setLabel('Next')
.setStyle(ButtonStyle.Primary)
.setDisabled(page === total - 1)
);
}
},
};
const { SlashCommandBuilder, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, ComponentType } = require('discord.js');
const fs = require('node:fs');
const path = require('node:path');
const { getEmojiURL } = require('../../Modules/GetEmojiURL');

module.exports = {
data: new SlashCommandBuilder()
.setName('help')
.setDescription('Lists all commands.'),
async execute(interaction) {
const client = interaction.client
const commandsPath = path.join(__dirname, '../../Commands_Slash');
const commandFiles = fs.readdirSync(commandsPath, { recursive: true }).filter(file => file.endsWith('.js'));

const commands = commandFiles.map(file => {
const filePath = path.join(commandsPath, file);
const command = require(filePath);
return { name: command.data.name, description: command.data.description };
});

const commandsPerPage = 5;
const totalPages = Math.ceil(commands.length / commandsPerPage);

let currentPage = 0;

async function generateEmbed(page) {
const start = page * commandsPerPage;
const end = start + commandsPerPage;

const embed = new EmbedBuilder()
.setAuthor({
name: "› Help",
iconURL: await getEmojiURL(interaction.client, "1263040971231465504"),
})
.setDescription("› Here are all the available commands:")
.setFooter({ text: `Page ${page + 1} of ${totalPages}` })
.setColor(0x00AE86)
.setImage(client.user.displayAvatarURL({dynamic: true, size: 1024}))

commands.slice(start, end).forEach(command => {
embed.addFields({ name: `/${command.name}`, value: `\`${command.description}\`` });
});

return embed;
};

const embedMessage = await interaction.reply({
embeds: [await generateEmbed(currentPage)],
components: [getRow(currentPage, totalPages)],
fetchReply: true
});

const collector = embedMessage.createMessageComponentCollector({
componentType: ComponentType.Button,
time: 60000
});

collector.on('collect', async i => {
if (i.user.id !== interaction.user.id) {
return i.reply({ content: 'The buttons are disabled for you. To see all commands, do `/help`.', ephemeral: true });
}

if (i.customId === 'previous') {
currentPage = Math.max(currentPage - 1, 0);
} else if (i.customId === 'next') {
currentPage = Math.min(currentPage + 1, totalPages - 1);
}

await i.update({ embeds: [await generateEmbed(currentPage)], components: [getRow(currentPage, totalPages)] });
});

collector.on('end', collected => {
embedMessage.edit({ components: [] });
});

function getRow(page, total) {
return new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId('previous')
.setLabel('Previous')
.setStyle(ButtonStyle.Primary)
.setDisabled(page === 0),
new ButtonBuilder()
.setCustomId('next')
.setLabel('Next')
.setStyle(ButtonStyle.Primary)
.setDisabled(page === total - 1)
);
}
},
};
it happens when i delete the embed from this command. when i send it, restart and THEN delete, nothing happens.
11 replies
DIAdiscord.js - Imagine a bot
Created by Serial Designation N on 7/17/2024 in #djs-questions
Unknown message when deleting bot messages
So you mean I should look for a code that tries to edit a message?
11 replies
DIAdiscord.js - Imagine a bot
Created by Serial Designation N on 7/17/2024 in #djs-questions
Unknown message when deleting bot messages
No description
11 replies
DIAdiscord.js - Imagine a bot
Created by Serial Designation N on 7/17/2024 in #djs-questions
Unknown message when deleting bot messages
my code:
const { Events, EmbedBuilder, ChannelType, AuditLogEvent } = require('discord.js');
const Server = require('../Database/Server');
const { getEmojiURL } = require('../Modules/GetEmojiURL');


module.exports = {
name: Events.MessageDelete,
async execute(message) {
if (message.author.bot) { return }
const serverData = await Server.findOne({ Guild: message.guild.id })
if (serverData) {
if (serverData.MessageLog && serverData.MessageLog!= "") {
const logChannel = await message.guild.channels.fetch(serverData.MessageLog)
// const auditLogs = await message.guild.fetchAuditLogs({
// type: AuditLogEvent.MessageDelete,
// limit: 1,
// });
// const deletionLog = auditLogs.entries.first();
// const executor = deletionLog.executor;
// const deletionTimestamp = deletionLog.createdTimestamp;
// const currentTime = Date.now();


// let executorValue;
// if (Math.abs(deletionTimestamp - currentTime) < 1000) {
// executorValue = `${executor?? "*The executor could not be retrieved*"}`;
// } else {
// executorValue = "*Self Deletion*";
// }

await logChannel.send({
embeds: [
new EmbedBuilder()
.setAuthor({ name: "› Message Deleted", iconURL: await getEmojiURL(message.client, "1262303811201142805") })
.setDescription(`› The message send in ${message.channel} has been deleted.`)
.setFields(
{
name: "Message ID",
value: `\`${message.id}\``
},
{
name: "Message Author",
value: `${message.author ? `@${message.author.tag} (${message.author})`: "*The author could not be retrieved*"}`
},
{
name: "Deleted at",
value: `<t:${Math.floor(new Date().getTime() / 1000)}:R>`
},
{
name: "Message Content",
value: `${message.content?.length > 0? message.content : "*The content could not be retrieved*"}`
},
// {
// name: "Executor",
// value: executorValue
// }
)
.setColor("LightGrey")
]
})
}
}
}
}
const { Events, EmbedBuilder, ChannelType, AuditLogEvent } = require('discord.js');
const Server = require('../Database/Server');
const { getEmojiURL } = require('../Modules/GetEmojiURL');


module.exports = {
name: Events.MessageDelete,
async execute(message) {
if (message.author.bot) { return }
const serverData = await Server.findOne({ Guild: message.guild.id })
if (serverData) {
if (serverData.MessageLog && serverData.MessageLog!= "") {
const logChannel = await message.guild.channels.fetch(serverData.MessageLog)
// const auditLogs = await message.guild.fetchAuditLogs({
// type: AuditLogEvent.MessageDelete,
// limit: 1,
// });
// const deletionLog = auditLogs.entries.first();
// const executor = deletionLog.executor;
// const deletionTimestamp = deletionLog.createdTimestamp;
// const currentTime = Date.now();


// let executorValue;
// if (Math.abs(deletionTimestamp - currentTime) < 1000) {
// executorValue = `${executor?? "*The executor could not be retrieved*"}`;
// } else {
// executorValue = "*Self Deletion*";
// }

await logChannel.send({
embeds: [
new EmbedBuilder()
.setAuthor({ name: "› Message Deleted", iconURL: await getEmojiURL(message.client, "1262303811201142805") })
.setDescription(`› The message send in ${message.channel} has been deleted.`)
.setFields(
{
name: "Message ID",
value: `\`${message.id}\``
},
{
name: "Message Author",
value: `${message.author ? `@${message.author.tag} (${message.author})`: "*The author could not be retrieved*"}`
},
{
name: "Deleted at",
value: `<t:${Math.floor(new Date().getTime() / 1000)}:R>`
},
{
name: "Message Content",
value: `${message.content?.length > 0? message.content : "*The content could not be retrieved*"}`
},
// {
// name: "Executor",
// value: executorValue
// }
)
.setColor("LightGrey")
]
})
}
}
}
}
11 replies
DIAdiscord.js - Imagine a bot
Created by Serial Designation N on 7/13/2024 in #djs-questions
Nuke Protection
right
13 replies
DIAdiscord.js - Imagine a bot
Created by Serial Designation N on 7/13/2024 in #djs-questions
Nuke Protection
No description
13 replies
DIAdiscord.js - Imagine a bot
Created by Serial Designation N on 7/13/2024 in #djs-questions
Nuke Protection
No, not bots. Someone hacked an admin account and created many roles, mass banned members, and deleted and created channels. I need a code that quickly recognizes such activities and acts accordingly
13 replies
DIAdiscord.js - Imagine a bot
Created by Serial Designation N on 4/22/2024 in #djs-questions
automoderationRules
forgot to put "keywordFilter" into "triggerMetadata"
8 replies
DIAdiscord.js - Imagine a bot
Created by Serial Designation N on 4/22/2024 in #djs-questions
automoderationRules
nvm i got it
8 replies
DIAdiscord.js - Imagine a bot
Created by Serial Designation N on 4/22/2024 in #djs-questions
automoderationRules
I tried the edit thing but it doesnt work. Idk if i have done it correctly. Is there a code example to show me how to edit it right? It would help me a lot
8 replies
DIAdiscord.js - Imagine a bot
Created by Serial Designation N on 4/22/2024 in #djs-questions
automoderationRules
is it possible to fetch rules with specific triggerType?
8 replies
DIAdiscord.js - Imagine a bot
Created by Serial Designation N on 11/10/2023 in #djs-voice
cannot hear my bot
can i fetch the active player and pause it when clicking a button?
7 replies
DIAdiscord.js - Imagine a bot
Created by Serial Designation N on 11/10/2023 in #djs-voice
cannot hear my bot
But another question: How can I detect the end of the audio to restart it automatically?
7 replies
DIAdiscord.js - Imagine a bot
Created by Serial Designation N on 11/10/2023 in #djs-voice
cannot hear my bot
i fixed it. i wass missing the GuildVoiceStates intent :,)
7 replies
DIAdiscord.js - Imagine a bot
Created by Serial Designation N on 7/14/2023 in #djs-questions
Why do I have my commands twice?
it worked. i used accidently this one to redeploy XD thats why the guild one was still there
17 replies
DIAdiscord.js - Imagine a bot
Created by Serial Designation N on 7/14/2023 in #djs-questions
Why do I have my commands twice?
i wil try
17 replies