嗨,我如何使用discord.js在特定行会的每个频道中创建webhook(具有相同的名称和头像)? 以及如何使用discord.js在特定频道中使用第一个Webhook获取第一个Webhook并发送消息?
答案 0 :(得分:0)
我不知道,但是如果添加了此命令,它应该可以工作。在每个频道中运行
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