因此,我有刚才发出的锁定命令,但是当我想启动bot时,我会得到以下错误
DiscordAPIError: Invalid Form Body
3.options[1].type: This field is required我试着修理它,但我不知道问题出在哪里。
它由4个文件组成。
文件1: GiveawaySys.js <--系统文件
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;
}文件2: Lockdown.js <-架构
const { model, Schema } = require("mongoose");
module.exports = model("Lockdown", new Schema({
GuildID: String,
ChannelID: String,
Time: String,
})
);文件3: lock.js <- lock命令
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));
}
},
};文件4: unlock.js <--解锁命令
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."),
],
});
},
};请帮我解决这个问题,我找不到这个问题
发布于 2022-02-24 00:02:48
您所得到的错误(.options[1].type is required)是对问题所在的一个非常大的提示。在搜索文件的代码时,我在options[1]中的第三个文件中看到了这个
{
name: "reason",
description: "Provide a reason for this lockdown.",
tyoe: "STRING",
}注意到问题了吗?这是个错误。"tyoe"而不是"type",导致djs抱怨需要"type"。
https://stackoverflow.com/questions/71228140
复制相似问题