如何获取发送至服务器的Webhook详情?Discord BOT拦截功能实现求助
Discord机器人拦截Webhook消息问题及Webhook详情获取咨询
各位同事下午好。我正在为我的Discord服务器开发一款机器人,唯一功能是拦截通过Webhook接收的消息,但目前还没成功实现。运行代码时出现如下错误:

以下是我当前的代码:
const { Client, GatewayIntentBits, Partials, Collection, WebhookClient, } = require("discord.js"); // const { Webhook } = require("discord-webhook-node"); const config = require("./config"); const webhook = new WebhookClient([config.webhooks.bizDataMr]); console.clear(); //webhook.fetchMessage() const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages], partials: [Partials.GUILD_MEMBER, Partials.USER], }); client.on("ready", () => { console.log(`${client.user.tag} is alive!`); }); client.on("messageCreate", async (msg) => { if ( msg.author.id === "1169644794788716685" || msg.author.id === "282859044593598464" ) return; const destinyChannel = msg.guild.channels.cache.get("1169671299459731536"); if (msg.channelId === "1169011873031659590") { console.log(msg); console.log(await webhook.fetchMessage(msg.id)); destinyChannel.send( `New message in <#${msg.channelId}>, <@&1169442693756223508>` ); } }); client.setMaxListeners(0); client.login(config.bot.token); // .login(config.bot.token) // .then(() => { // console.log(`${client.user.username} is active`); // }) // .catch((err) => { // console.error(err); // });
我知道代码较为杂乱,打算实现功能后再进行整理。
请问:
- 我能否通过WebhookClient实现拦截Webhook消息的需求?或者该需求是否无法完成?
- 如何获取发送至我的服务器的Webhook详情?
内容的提问来源于stack exchange,提问作者Saco04
相关产品推荐
相关产品推荐

