#node.js #discord #discord.js #bots
#node.js #Discord #discord.js #боты
Вопрос:
Я попытался создать приветственное сообщение, но получаю сообщение об ошибке. Кто-нибудь знает, как исправить эту ошибку?
код:
const client = new Client({
allowedMentions: { parse: ["users", "roles", "reaction"]},
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILD_MEMBERS,
Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
Intents.FLAGS.GUILD_WEBHOOKS,
Intents.FLAGS.GUILD_VOICE_STATES,
Intents.FLAGS.GUILD_INVITES,
Intents.FLAGS.GUILD_BANS,
Intents.FLAGS.GUILD_PRESENCES,
]
})
client.on(`guildMemberAdd` , (member, guild) =>{
const arten = [
`Halli Hallo <@!${member.id}>, Willkommen auf dem Teckles.net Server <:T_:788703077184045076>`,
`Willkommen <@!${member.id}>, wir hoffen du hast viel Spaß auf Teckles.net <:T_:788703077184045076>`,
`<@!${member.id}> hat sich dazu entschieden eine Runde mit uns zu spielen <:T_:788703077184045076>`,
]
const welcomemessage = `${arten[Math.floor(Math.random() * arten.length)]}`
let roles = ['781625371682275360', `811351035209056307`, '811351288146821161', '811351128372936704', '828942314046357535']
for (number = 0; number < roles.length; number ) {
let role = member.guild.roles.cache.find(r => r.id === roles[number])
member.roles.add(role)
}
const channel = client.channels.cache.find(channel => channel.id === '916730472950792252')
channel.send({ content: welcomemessage})
})
ошибка:
DiscordAPIError: Invalid Form Body
allowed_mentions.parse[2]: Value must be one of ('roles', 'users', 'everyone').
at RequestHandler.execute (F:ProgrammierenTecklesnode_modulesdiscord.jssrcrestRequestHandler.js:298:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (F:ProgrammierenTecklesnode_modulesdiscord.jssrcrestRequestHandler.js:50:14)
at async TextChannel.send (F:ProgrammierenTecklesnode_modulesdiscord.jssrcstructuresinterfacesTextBasedChannel.js:172:15) {
method: 'post',
path: '/channels/916730472950792252/messages',
code: 50035,
httpStatus: 400,
requestData: {
json: {
content: 'Halli Hallo <@!777498801349853186>, Willkommen auf dem Teckles.net Server <:T_:788703077184045076>',
tts: false,
nonce: undefined,
embeds: undefined,
components: undefined,
username: undefined,
avatar_url: undefined,
allowed_mentions: {
parse: [ 'users', 'roles', 'reaction' ],
replied_user: undefined
},
flags: undefined,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined
},
files: []
}
}
Ответ №1:
Типы сообщений могут быть только roles
, users
или everyone
. reaction
не совместим с MessageMentionTypes
. Удалить reaction
из client.allowedMentions.parse
.