BulkDelete error 50034

Error
31 Replies
Almeida
Almeida3y ago
pass true as the second parameter
d.js docs
d.js docs3y ago
method TextChannel#bulkDelete() Bulk deletes given messages that are newer than two weeks.
PAdventures
PAdventuresOP3y ago
like this ?
let { size } = await interaction.channel.bulkDelete(amount[filterOld: true])
let { size } = await interaction.channel.bulkDelete(amount[filterOld: true])
Almeida
Almeida3y ago
thats not valid syntax
PAdventures
PAdventuresOP3y ago
then how do i do it
Almeida
Almeida3y ago
.
PAdventures
PAdventuresOP3y ago
let { size } = await interaction.channel.bulkDelete(amount.true)?
Almeida
Almeida3y ago
seems like you're lacking javascript fundamentals
PAdventures
PAdventuresOP3y ago
JavaScript is alien to me i was just told it is good for coding a discord bot
Almeida
Almeida3y 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
PAdventuresOP3y ago
let { size } = await interaction.channel.bulkDelete(amount, filterOld: true)?
Almeida
Almeida3y ago
minus filterOld:
PAdventures
PAdventuresOP3y 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
Almeida3y ago
why did you put a ] after true
PAdventures
PAdventuresOP3y 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
Almeida3y ago
i wasnt, i was looking at this
PAdventures
PAdventuresOP3y ago
typo
Almeida
Almeida3y ago
you are using size in the catch block, which is not defined you only defined size in the try block
PAdventures
PAdventuresOP3y 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
Almeida3y ago
the error is pretty clear to send embeds you just use reply({ embeds: [embed] }) content is a string
PAdventures
PAdventuresOP3y 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
Almeida3y ago
you still have other places doing the same thhing
PAdventures
PAdventuresOP3y ago
but i want them to reply ephemeraly
Almeida
Almeida3y 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
PAdventuresOP3y ago
interaction.reply({ embeds: [failedEmbed], ephemeral:true})?
probablyraging
yes
PAdventures
PAdventuresOP3y 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
PAdventuresOP3y ago
thanks so much for the help
Want results from more Discord servers?
Add your server