ExperimentalWarning: buffer.File is an experimental feature and might change at any time

huangapple go评论58阅读模式
英文:

(node:7764) ExperimentalWarning: buffer.File is an experimental feature and might change at any time

问题

抱歉关于我的英语,

我尝试编写一个 Discord 机器人,它会向新成员发送一个验证码,如果验证码正确,我的机器人会给他们一个角色,它可以正常工作,但在获得角色后,我的机器人会崩溃,并显示以下错误消息:
console error image
这是我的代码:

const { Client, IntentsBitField, EmbedBuilder } = require("discord.js");
const client = new Client({
    intents: [
        IntentsBitField.Flags.Guilds,
        IntentsBitField.Flags.GuildMessages,
        IntentsBitField.Flags.MessageContent, //重要:确保在开发门户中启用“Message Content Intent”!
        IntentsBitField.Flags.GuildMembers,
        IntentsBitField.Flags.DirectMessages,
    ]
});

client.login("bot tk");

const { Captcha } = require("discord.js-captcha");

client.on("ready", () => {
    console.log("Bot opérationnel");
});

const captcha = new Captcha(client, {
    roleID: "role id", //可选
    channelID: "channel id", //可选
    sendToTextChannel: true, //可选,默认为false
    addRoleOnSuccess: true, //可选,默认为true。如果验证码被解决,是否要让机器人给用户添加角色
    kickOnFailure: true, //可选,默认为true。如果验证码失败,是否要让机器人踢出用户
    caseSensitive: true, //可选,默认为true。是否要求验证码响应区分大小写
    attempts: 3, //可选,默认为1。在验证码被视为失败之前的尝试次数
    timeout: 300000, //可选,默认为60000。用户在每次尝试中解决验证码的时间(以毫秒为单位)
    showAttemptCount: true, //可选,默认为true。是否在嵌入页脚中显示剩余尝试次数
    customPromptEmbed: new EmbedBuilder(), //自定义在请求验证码时将发送给用户的嵌入
    customSuccessEmbed: new EmbedBuilder(), //自定义在验证码解决时将发送给用户的嵌入
    customFailureEmbed: new EmbedBuilder(), //自定义当用户无法解决验证码时将发送给用户的嵌入
});

client.on("guildMemberAdd", async member => {
    //在开发门户中,确保已启用意向!
    captcha.present(member); //验证码由包创建,并发送给成员
});

captcha.on("success", data => {
    console.log(`Un membre a réussi le captcha !`);
    console.log(data);
});

captcha.on("failure", data => {
    console.log(`Un membre a raté le captcha !`);
    console.log(data);
});

感谢您的帮助!

英文:

Sorry about my English,
I tried to code a discord bot that sends a captcha to the new member, and if the captcha is good my bot gives them a role, it works but after it gets the role my bot crash with this error message:
console error image
voici mon code :

const { Client, IntentsBitField, EmbedBuilder } = require("discord.js");
const client = new Client({
intents: [
IntentsBitField.Flags.Guilds,
IntentsBitField.Flags.GuildMessages,
IntentsBitField.Flags.MessageContent, //IMPORTANT: make sure you enable "Message Content Intent" in the dev portal!
IntentsBitField.Flags.GuildMembers,
IntentsBitField.Flags.DirectMessages,
]
});
client.login("bot tk");
const { Captcha } = require("discord.js-captcha");
client.on("ready", () => {
console.log("Bot opérationnel");
});
const captcha = new Captcha(client, {
roleID: "role id", //optional
channelID: "channel id", //optional
sendToTextChannel: true, //optional, defaults to false
addRoleOnSuccess: true, //optional, defaults to true. whether you want the bot to add the role to the user if the captcha is solved
kickOnFailure: true, //optional, defaults to true. whether you want the bot to kick the user if the captcha is failed
caseSensitive: true, //optional, defaults to true. whether you want the captcha responses to be case-sensitive
attempts: 3, //optional, defaults to 1. number of attempts before captcha is considered to be failed
timeout: 300000, //optional, defaults to 60000. time the user has to solve the captcha on each attempt in milliseconds
showAttemptCount: true, //optional, defaults to true. whether to show the number of attempts left in embed footer
customPromptEmbed: new EmbedBuilder(), //customise the embed that will be sent to the user when the captcha is requested
customSuccessEmbed: new EmbedBuilder(), //customise the embed that will be sent to the user when the captcha is solved
customFailureEmbed: new EmbedBuilder(), //customise the embed that will be sent to the user when they fail to solve the captcha
});
client.on("guildMemberAdd", async member => {
//in your bot application in the dev portal, make sure you have intents turned on!
captcha.present(member); //captcha is created by the package, and sent to the member
});
captcha.on("success", data => {
console.log(`Un membre a réussie le captcha !`);
console.log(data);
});
captcha.on("failure", data => {
console.log(`Un membre a raté le captcha !`);
console.log(data);
});

Thanks for helping me!

答案1

得分: 1

.env文件位于项目的根目录中,如果您确信代码正在正确运行并希望移除这个特定警告,请创建一个环境变量:

NODE_NO_WARNINGS=1

英文:

If you are sure that the code is working correctly and you want to remove this particular warning, create an environment variable.

.env file at the root of your project:

NODE_NO_WARNINGS=1

答案2

得分: 0

这个错误是针对你的Node.js特别提到的,这是关于Node.js的警告,该功能可能在将来的Node.js版本中更改或被移除,它不是稳定的。

你可以忽略这个警告,因为它只与实验性功能相关,但你也可以通过在主要引发警告的文件顶部添加process.noDeprecation = true;来抑制它。

英文:

That error refers to your node.js particularly, this is warning regarding node.js that feature may change or be removed in future of node.js and it's not stable.

You can ignore the warning as it's experimental feature related only but you can suppress it by doing process.noDeprecation = true; in top of your file where this is causing mainly.

huangapple
  • 本文由 发表于 2023年2月6日 03:07:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/75354798.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定