gpt4 book ai didi

javascript - Discord.js 从 react 中获取用户 **已更新**

转载 作者:行者123 更新时间:2023-12-03 12:14:09 24 4
gpt4 key购买 nike

更新

我已经更新了当前为我工作的代码,它现在将创建 channel ,然后检查 channel 是否已创建。它将只允许 1 个用户创建一个 channel ,您将无法像同一用户一样创建 T5 channel 和 T4 channel 。

谢谢,祝大家圣诞快乐。

Client.on("message", async (message) => {
if (message.author.Client || message.channel.type === "dm") return;

let messageArray = message.content.split(" ");
let cmd = messageArray[0];
let args = message.content.substring(message.content.indexOf(" ") + 1);

if (cmd === `${prefix}battle`) {
let embed = new Discord.MessageEmbed()
.setTitle("⚔️ 1657 Battles! ⚔️")
.setDescription("React to this message to join the battle.")
.addFields(
{ name: "🥇", value: "T5" },
{ name: "🥈", value: "T4" },
{ name: "🥉", value: "T3" },
{ name: "🏅", value: "T2" },
{ name: "🎖", value: "T1" }
)
.setColor("#0099ff")
.setTimestamp()
.setFooter("Please pick the troop type you want to battle with!");

let msgEmbed = await message.channel.send(embed);
msgEmbed.react("🥇"); // T5
msgEmbed.react("🥈"); // T4
msgEmbed.react("🥉"); // T3
msgEmbed.react("🏅"); // T2
msgEmbed.react("🎖"); // T1
}
});

Client.on("messageReactionAdd", async (reaction, user, message) => {
//Add an event listener
if (reaction.message.partial) await reaction.message.fetch();
if (user.id === Client.user.id) return; //If the reaction was from the bot, return
if (!reaction.message.guild) return; //If the reaction was not in a guild
const guild = Client.guilds.cache.get("644295524404428832");
if (
guild.channels.cache.find((channel) => channel.name === "t5-battle-channel")
)
return;

if (reaction.emoji.name === "🥇") {
let guild = reaction.message.guild;
guild.channels.create("T5 Battle Channel", {
//Creating the channel
type: "text", //Make sure the channel type is text
permissionOverwrites: [
//Set overwrites
{
id: guild.id,
deny: "VIEW_CHANNEL",
},
{
id: "788400016736780338",
allow: ["VIEW_CHANNEL"],
},
],
});
}
if (
guild.channels.cache.find((channel) => channel.name === "t4-battle-channel")
)
return;

if (reaction.emoji.name === "🥈") {
let guild = reaction.message.guild;
guild.channels.create("T4 Battle Channel", {
//Creating the channel
type: "text", //Make sure the channel type is text
permissionOverwrites: [
//Set overwrites
{
id: guild.id,
deny: "VIEW_CHANNEL",
},
{
id: "788400619114463275",
allow: ["VIEW_CHANNEL"],
},
],
});
}
if (
guild.channels.cache.find((channel) => channel.name === "t3-battle-channel")
)
return;

if (reaction.emoji.name === "🥉") {
let guild = reaction.message.guild;
guild.channels.create("T3 Battle Channel", {
//Creating the channel
type: "text", //Make sure the channel type is text
permissionOverwrites: [
//Set overwrites
{
id: guild.id,
deny: "VIEW_CHANNEL",
},
{
id: "788400701130670110",
allow: ["VIEW_CHANNEL"],
},
],
});
}
if (
guild.channels.cache.find((channel) => channel.name === "t2-battle-channel")
)
return;

if (reaction.emoji.name === "🏅") {
let guild = reaction.message.guild;
guild.channels.create("T2 Battle Channel", {
//Creating the channel
type: "text", //Make sure the channel type is text
permissionOverwrites: [
//Set overwrites
{
id: guild.id,
deny: "VIEW_CHANNEL",
},
{
id: "788400738727624704",
allow: ["VIEW_CHANNEL"],
},
],
});
}
if (
guild.channels.cache.find((channel) => channel.name === "t1-battle-channel")
)
return;

if (reaction.emoji.name === "🎖") {
let guild = reaction.message.guild;
guild.channels.create("T1 Battle Channel", {
//Creating the channel
type: "text", //Make sure the channel type is text
permissionOverwrites: [
//Set overwrites
{
id: guild.id,
deny: "VIEW_CHANNEL",
},
{
id: "788400784420372490",
allow: ["VIEW_CHANNEL"],
},
],
});
}
});

最佳答案

如果你想获得一条消息的所有反应,你可以使用 reactions message 上的属性(property),如果您已经有了消息对象。这将返回 ReactionManager你可以使用它。

关于javascript - Discord.js 从 react 中获取用户 **已更新**,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65363885/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com