BulkDelete error 50034

Error
31 Replies
Almeida
Almeida2y ago
pass true as the second parameter
d.js docs
d.js docs2y ago
method TextChannel#bulkDelete() Bulk deletes given messages that are newer than two weeks.
PAdventures
PAdventures2y ago
like this ?
let { size } = await interaction.channel.bulkDelete(amount[filterOld: true])
let { size } = await interaction.channel.bulkDelete(amount[filterOld: true])
Almeida
Almeida2y ago
thats not valid syntax
PAdventures
PAdventures2y ago
then how do i do it
Almeida
Almeida2y ago
.
PAdventures
PAdventures2y ago
let { size } = await interaction.channel.bulkDelete(amount.true)?
Almeida
Almeida2y ago
seems like you're lacking javascript fundamentals
PAdventures
PAdventures2y ago
JavaScript is alien to me i was just told it is good for coding a discord bot
Almeida
Almeida2y ago
its extremely basic, and it works in the same way you'd pass a different argument to a function in math you separate them with a comma
PAdventures
PAdventures2y ago
let { size } = await interaction.channel.bulkDelete(amount, filterOld: true)?
Almeida
Almeida2y ago
minus filterOld:
PAdventures
PAdventures2y ago
let { size } = await interaction.channel.bulkDelete(amount, true)? now
ReferenceError: size is not defined
ReferenceError: size is not defined
? here
.setDescription(`❌ | Failed to delete ${size} messages as some may be over 14 days old.`)
.setDescription(`❌ | Failed to delete ${size} messages as some may be over 14 days old.`)
Almeida
Almeida2y ago
why did you put a ] after true
PAdventures
PAdventures2y ago
let { size } = await interaction.channel.bulkDelete(amount, true)
let { size } = await interaction.channel.bulkDelete(amount, true)
this is what i put oh dont look at soucebin
Almeida
Almeida2y ago
i wasnt, i was looking at this
PAdventures
PAdventures2y ago
typo
Almeida
Almeida2y ago
you are using size in the catch block, which is not defined you only defined size in the try block
PAdventures
PAdventures2y ago
k
const { EmbedBuilder, SlashCommandBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('clear')
.setDescription('Clears x number of messages')
.addIntegerOption(option => option.setName('number').setDescription('Enter an number.').setRequired(true)),
async execute(interaction) {
const useNumberClearEmbed = new EmbedBuilder()
.setColor('#ce3636')
.setDescription('😖 | Please use a number to specify the number of messages you want to clear.');
const deleteOneClearEmbed = new EmbedBuilder()
.setColor('#ce3636')
.setDescription('😖 | You must delete at least one message.');
const amount = interaction.options.getInteger('amount');
if(isNaN(amount)) {
return interaction.reply({ content: { embeds: [useNumberClearEmbed]}, ephemeral: true })
}
if(parseInt(amount) < 0) {
return interaction.reply({ content: { embeds: [deleteOneClearEmbed]}, ephemeral: true })
} else {
try {
let { size } = await interaction.channel.bulkDelete(amount, true)
const deletedEmbed = new EmbedBuilder()
.setColor('#36ce36')
.setDescription(`✅ | Deleted ${size} messages.`);
await interaction.reply({ content: { embeds: [deletedEmbed]}, ephemeral: true })
} catch(err) {
const failedEmbed = new EmbedBuilder()
.setColor('#ce3636')
.setDescription(`❌ | Failed to delete ${amount} messages as some may be over 14 days old.\n**__Error__**\n${err}`)
interaction.reply({ content: { embeds: [failedEmbed]}, ephemeral: true })
}
}
}
}
const { EmbedBuilder, SlashCommandBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('clear')
.setDescription('Clears x number of messages')
.addIntegerOption(option => option.setName('number').setDescription('Enter an number.').setRequired(true)),
async execute(interaction) {
const useNumberClearEmbed = new EmbedBuilder()
.setColor('#ce3636')
.setDescription('😖 | Please use a number to specify the number of messages you want to clear.');
const deleteOneClearEmbed = new EmbedBuilder()
.setColor('#ce3636')
.setDescription('😖 | You must delete at least one message.');
const amount = interaction.options.getInteger('amount');
if(isNaN(amount)) {
return interaction.reply({ content: { embeds: [useNumberClearEmbed]}, ephemeral: true })
}
if(parseInt(amount) < 0) {
return interaction.reply({ content: { embeds: [deleteOneClearEmbed]}, ephemeral: true })
} else {
try {
let { size } = await interaction.channel.bulkDelete(amount, true)
const deletedEmbed = new EmbedBuilder()
.setColor('#36ce36')
.setDescription(`✅ | Deleted ${size} messages.`);
await interaction.reply({ content: { embeds: [deletedEmbed]}, ephemeral: true })
} catch(err) {
const failedEmbed = new EmbedBuilder()
.setColor('#ce3636')
.setDescription(`❌ | Failed to delete ${amount} messages as some may be over 14 days old.\n**__Error__**\n${err}`)
interaction.reply({ content: { embeds: [failedEmbed]}, ephemeral: true })
}
}
}
}
Error
D:\PA_Admin Backup copy\node_modules\discord.js\src\util\Util.js:357
if (typeof data !== 'string') throw new error(errorMessage);
^

RangeError [MessageContentType]: Message content must be a string.
at verifyString (D:\PA_Admin Backup copy\node_modules\discord.js\src\util\Util.js:357:39)
at MessagePayload.makeContent (D:\PA_Admin Backup copy\node_modules\discord.js\src\structures\MessagePayload.js:110:17)
at MessagePayload.resolveBody (D:\PA_Admin Backup copy\node_modules\discord.js\src\structures\MessagePayload.js:125:26)
at ChatInputCommandInteraction.reply (D:\PA_Admin Backup copy\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:108:56)
at Object.execute (D:\PA_Admin Backup copy\Commands\clear.js:31:29)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Object.execute (D:\PA_Admin Backup copy\Events\interactionCreate.js:12:13) {
[Symbol(code)]: 51
}
D:\PA_Admin Backup copy\node_modules\discord.js\src\util\Util.js:357
if (typeof data !== 'string') throw new error(errorMessage);
^

RangeError [MessageContentType]: Message content must be a string.
at verifyString (D:\PA_Admin Backup copy\node_modules\discord.js\src\util\Util.js:357:39)
at MessagePayload.makeContent (D:\PA_Admin Backup copy\node_modules\discord.js\src\structures\MessagePayload.js:110:17)
at MessagePayload.resolveBody (D:\PA_Admin Backup copy\node_modules\discord.js\src\structures\MessagePayload.js:125:26)
at ChatInputCommandInteraction.reply (D:\PA_Admin Backup copy\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:108:56)
at Object.execute (D:\PA_Admin Backup copy\Commands\clear.js:31:29)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Object.execute (D:\PA_Admin Backup copy\Events\interactionCreate.js:12:13) {
[Symbol(code)]: 51
}
Almeida
Almeida2y ago
the error is pretty clear to send embeds you just use reply({ embeds: [embed] }) content is a string
PAdventures
PAdventures2y ago
const { EmbedBuilder, SlashCommandBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('clear')
.setDescription('Clears x number of messages')
.addIntegerOption(option => option.setName('number').setDescription('Enter an number.').setRequired(true)),
async execute(interaction) {
const useNumberClearEmbed = new EmbedBuilder()
.setColor('#ce3636')
.setDescription('😖 | Please use a number to specify the number of messages you want to clear.');
const deleteOneClearEmbed = new EmbedBuilder()
.setColor('#ce3636')
.setDescription('😖 | You must delete at least one message.');
const amount = interaction.options.getInteger('amount');
if(isNaN(amount)) {
return interaction.reply({ content: { embeds: [useNumberClearEmbed]}, ephemeral: true })
}
if(parseInt(amount) < 0) {
return interaction.reply({ content: { embeds: [deleteOneClearEmbed]}, ephemeral: true })
} else {
try {
let { size } = await interaction.channel.bulkDelete(amount, true)
const deletedEmbed = new EmbedBuilder()
.setColor('#36ce36')
.setDescription(`✅ | Deleted ${size} messages.`);
await interaction.reply({ content: { embeds: [deletedEmbed]}, ephemeral: true })
} catch(err) {
const failedEmbed = new EmbedBuilder()
.setColor('#ce3636')
.setDescription(`❌ | Failed to delete ${amount} messages as some may be over 14 days old.\n**__Error__**\n${err}`)
interaction.reply({ embeds: [failedEmbed]})
}
}
}
}
const { EmbedBuilder, SlashCommandBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('clear')
.setDescription('Clears x number of messages')
.addIntegerOption(option => option.setName('number').setDescription('Enter an number.').setRequired(true)),
async execute(interaction) {
const useNumberClearEmbed = new EmbedBuilder()
.setColor('#ce3636')
.setDescription('😖 | Please use a number to specify the number of messages you want to clear.');
const deleteOneClearEmbed = new EmbedBuilder()
.setColor('#ce3636')
.setDescription('😖 | You must delete at least one message.');
const amount = interaction.options.getInteger('amount');
if(isNaN(amount)) {
return interaction.reply({ content: { embeds: [useNumberClearEmbed]}, ephemeral: true })
}
if(parseInt(amount) < 0) {
return interaction.reply({ content: { embeds: [deleteOneClearEmbed]}, ephemeral: true })
} else {
try {
let { size } = await interaction.channel.bulkDelete(amount, true)
const deletedEmbed = new EmbedBuilder()
.setColor('#36ce36')
.setDescription(`✅ | Deleted ${size} messages.`);
await interaction.reply({ content: { embeds: [deletedEmbed]}, ephemeral: true })
} catch(err) {
const failedEmbed = new EmbedBuilder()
.setColor('#ce3636')
.setDescription(`❌ | Failed to delete ${amount} messages as some may be over 14 days old.\n**__Error__**\n${err}`)
interaction.reply({ embeds: [failedEmbed]})
}
}
}
}
Error sent to channel
RangeError [MessageContentType]: Message content must be a string.
RangeError [MessageContentType]: Message content must be a string.
Almeida
Almeida2y ago
you still have other places doing the same thhing
PAdventures
PAdventures2y ago
but i want them to reply ephemeraly
Almeida
Almeida2y ago
add ephemeral: true to the options
probablyraging
You're sending an embed as the content, you don't need to, you send embeds as the embeds option
PAdventures
PAdventures2y ago
interaction.reply({ embeds: [failedEmbed], ephemeral:true})?
probablyraging
yes
PAdventures
PAdventures2y ago
k when i run the command it deletes ALL messages that it can even if i say to delete 2, it will delete 7 when i console.log(amount) it returns with null
probablyraging
You set the option name as number but you're trying to get the int from amount which doesn't exist
PAdventures
PAdventures2y ago
thanks so much for the help