Reputation: 101
so I have this lockdown command I just made, but when I want to start the bot I get the following error
DiscordAPIError: Invalid Form Body
3.options[1].type: This field is required
I tried fixing it but I have no idea where the issue is.
It exists of 4 files.
File 1: GiveawaySys.js <-- system file
const { GiveawaysManager } = require('discord-giveaways');
const giveawayModel = require("../Structures/Schemas/GiveawayDB");
module.exports = (client) => {
const GiveawayManagerWithOwnDatabase = class extends GiveawaysManager {
async getAllGiveaways() {
return await giveawayModel.find().lean().exec();
}
async saveGiveaway(messageId, giveawayData) {
await giveawayModel.create(giveawayData);
return true;
}
async editGiveaway(messageId, giveawayData) {
await giveawayModel.updateOne({ messageId }, giveawayData, { omitUndefined: true }).exec();
return true;
}
async deleteGiveaway(messageId) {
await giveawayModel.deleteOne({ messageId }).exec();
return true;
}
};
const manager = new GiveawayManagerWithOwnDatabase(client, {
default: {
botsCanWin: false,
embedColor: '#FF0000',
embedColorEnd: '#000000',
reaction: '🎉'
}
});
client.giveawaysManager = manager;
}
File 2: Lockdown.js <-- Schema
const { model, Schema } = require("mongoose");
module.exports = model("Lockdown", new Schema({
GuildID: String,
ChannelID: String,
Time: String,
})
);
File 3: lock.js <-- lock command
const {
CommandInteraction,
MessageEmbed
} = require("discord.js");
const DB = require("../../Structures/Schemas/LockDown");
const ms = require("ms");
module.exports = {
name: "lock",
description: "Lockdown this channel",
permission: "MANAGE_CHANNELS",
options: [{
name: "time",
description: "Expire date for this lockdown (1m, 1h, 1d)",
type: "STRING",
},
{
name: "reason",
description: "Provide a reason for this lockdown.",
tyoe: "STRING",
},
],
/**
*
* @param {CommandInteraction} interaction
*/
async execute(interaction) {
const {
guild,
channel,
options
} = interaction;
const Reason = options.getString("reason") || "no specified reason";
const Embed = new MessageEmbed();
if (!channel.permissionsFor(guild.id).has("SEND_MESSAGES"))
return interaction.reply({
embeds: [Embed.setColor("RED").
setDescription("â›” | This channel is already locked."),
],
ephemeral: true,
});
channel.permissionOverwrites.edit(guild.id, {
SEND_MESSAGES: false,
});
interaction.reply({
embeds: [Embed
.setColor("RED")
.setDescription(`🔒 | This channel is now under lockdown for: ${Reason}`
),
],
});
const Time = options.getString("time");
if (Time) {
const ExpireDate = Date.now() + ms(Time);
DB.create({
GuildID: guild.id,
ChannelID: channel.id,
Time: ExpireDate
});
setTimeout(async () => {
channel.permissionOverwrites.edit(guild.id, {
SEND_MESSAGES: null,
});
interaction.editReply({
embeds: [Embed
.setDescription("🔓 | The lockdown has been lifted")
.setColor("GREEN")
],
})
.catch(() => {});
await DB.deleteOne({
ChannelID: channel.id
});
}, ms(Time));
}
},
};
File 4: unlock.js <-- unlock command
const {
CommandInteraction,
MessageEmbed
} = require("discord.js");
const DB = require("../../Structures/Schemas/LockDown");
module.exports = {
name: "unlock",
description: "Lift a lockdown from a channel",
permission: "MANAGE_CHANNELS",
/**
*
* @param {CommandInteraction} interaction
*/
async execute(interaction) {
const {
guild,
channel
} = interaction;
const Embed = new MessageEmbed();
if (channel.permissionsFor(guild.id).has("SEND_MESSAGES"))
return interaction.reply({
embeds: [Embed
.setColor("RED")
.setDescription("â›” | This channel is not locked"),
],
ephemeral: true,
});
channel.permissionOverwrites.edit(guild.id, {
SEND_MESSAGES: null,
});
await DB.deleteOne({
ChannelID: channel.id
});
interaction.reply({
embeds: [Embed
.setColor("GREEN")
.setDescription("🔓 | Lockdown has been lifted."),
],
});
},
};
Please help me with this one, I can't find the issue here
Upvotes: 0
Views: 3924
Reputation: 4520
The error you are getting (.options[1].type is required
) is a very big hint as to what the issue is. Searching the code of your files, I saw this in your third file in options[1]
:
{
name: "reason",
description: "Provide a reason for this lockdown.",
tyoe: "STRING",
}
Notice the problem? It's a typo. "tyoe"
instead of "type"
, causing djs to complain about "type"
being required.
Upvotes: 1