【发布时间】:2020-08-29 08:20:25
【问题描述】:
您好,我如何使用 discord.js 在特定公会的每个频道中创建 webhook(具有相同的名称和头像)? 以及如何使用 discord.js 在特定通道中使用第一个 webhook 获取第一个 webhook 并发送消息?
【问题讨论】:
标签: discord.js
您好,我如何使用 discord.js 在特定公会的每个频道中创建 webhook(具有相同的名称和头像)? 以及如何使用 discord.js 在特定通道中使用第一个 webhook 获取第一个 webhook 并发送消息?
【问题讨论】:
标签: discord.js
我不知道,但如果你添加了这个命令,它应该可以工作。在每个频道中运行它
const prefix = '';
const args = message.content.slice(prefix.length).trim().split(/ +/g);
if (msg.content === `${prefix}createwebhook`) {
let name = args.slice(1).join(" ");
//Check for permissions because we don't need everyone making webhooks!
if(!message.author.hasPermission("MANAGE_WEBHOOKS")) {
return message.channel.send("You are not authorized to do this!");
}
//What if the bot can't do it?
if(message.guild.me.hasPermission("MANAGE_WEBHOOKS")) {
return message.channel.send("I have not been allowed to make webhooks!");
}
message.channel.createWebhook(name, {
avatar: args[1], // So when doing this command, you must give it an image URL (Should end in .jpg, .png, etc.)
}).then(webhook => console.log(`Created webhook ${webhook}`)).catch(console.error);
message.channel.send(`${message.author}, created the webhook "${webhook}" with the profile picture ${args[0]}`);
}
文档可以在here找到
【讨论】: