- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经发布了一个按钮,但它只能使用一次 但在那之后当我再次使用它时
还有
如果我使用它显示的deferUpdate
如何回复消息
代码
client.on('ready', () => {
client.user.setActivity('people and managing the server', {
type: 'WATCHING',
});
const channel = client.channels.cache.get('894171605608042496');
const row = new MessageActionRow().addComponents(
new MessageButton()
.setCustomId('openTicket')
.setLabel('Create ticket')
.setEmoji('📩')
.setStyle('SECONDARY')
);
channel
.send({
embeds: [
{
title: 'SGAS Tickets',
color: '#388e3c',
description: 'To create a ticket react with 📩',
},
],
components: [row],
})
.then(() => {
const filter = () => {
return true;
};
const collector = channel.createMessageComponentCollector({
filter,
time: 15 * 1000,
});
collector.on('collect', (i) => {
i.deferUpdate().then(() => {
Ticket.count({}, (err, result) => {
if (err) {
console.log(err);
} else {
const ticketNumber = result + 1;
const ticketString = convertNumber(ticketNumber);
const ticket = new Ticket({
tickedId: ticketString,
});
ticket.save((err) => {
if (err) {
console.log(err);
} else {
const myguild = client.guilds.cache.get('887277806386565150');
if (!myguild) {
console.log('guild not found');
return;
}
const category = myguild.channels.cache.find(
(c) =>
c.id === '887277807279947826' &&
c.type == 'GUILD_CATEGORY'
);
if (!category) {
console.log('category not found');
return;
}
myguild.channels
.create(`Ticket#${ticketString}`, {
type: 'GUILD_TEXT',
})
.then(async (myc) => {
myc.setParent(category).then(() => {
myc.send(
`Hello <@${i.user.id}>, your question will be solved here shortly`
);
i.reply({
content: `Go to <#${myc.id}>, for your question`,
ephemeral: true,
});
});
});
}
});
}
});
});
});
});
});
最佳答案
您正在使用一个组件收集器 - 如您的代码所示,它会在 15 秒后过期。这意味着 15 秒后,您的机器人将停止监听按钮点击。我的建议是使用 interactionCreate
事件来监听该按钮:参见文档 https://discord.js.org/#/docs/main/stable/class/ButtonInteraction
例子:
client.on("interactionCreate", (interaction) => {
if(!interaction.isButton()) return;
if(interaction.customId === "openTicket") {
// your ticket code here
}
});
关于node.js - Discord 按钮只工作一次 discord.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69426687/
当我在 repl.it 上运行我的 discord 机器人时,出现错误。在错误中,我在下面看到了一些 HTML 代码。 CloudFlare 似乎阻止了我的机器人访问 Discord。这是什么原因造成
我计划使用 python 制作一个不和谐的机器人。 discord.py 和 discord.py[voice] 有什么区别? 最佳答案 discord.py 和 discord[voice] 之间的
我正在尝试编写一个脚本来检测用户是否以及何时将他们在 discord 上的名称从“bob”更改为“.bob”之类的名称,它会禁止此更改并将其保留为“bob”。 if (user.nickname.st
我想使用 Discord Bot 向用户发送私有(private)消息。 用户与机器人不在同一台服务器上。 如果我可以使用 author.sendMessage,我该如何初始化(查找)作者变量? 我可
我正在尝试将某人添加到特定服务器,然后通过 DM 只用不和谐 ID 表示该人。 它的工作方式是,有人在网站上使用 Discord OAuth2 登录自己,登录后他应该被添加到特定服务器,然后机器人应该
我无法弄清楚如何使用类似于 /giphy、/xivdb 等的实时“反馈”来实现斜杠命令。没有公共(public) API 吗? ?我正在使用 discord.py,但我想这对于这个问题来说并不重要。
我正在尝试使用 Discord Bot 在 discord 服务器上创建一个类别,但我无法在 Internet 上找到该方法或其他内容。我还看了“discord.js.org”。然后我认为没有任何可能
我正在为桌面创建灯,当我的麦克风在 Discord 上处于事件状态时,该灯将为绿色,当我的麦克风静音时,该灯将为红色。所以我想从不和谐中获取我的麦克风状态。但我不知道怎么做。 当我不在进行语音聊天时,
我已经看到了您允许某个角色使用命令的变体。但是,我试图实现完全相反的效果:如何禁止某个角色使用命令。 我搜索了堆栈溢出,没有找到答案,也没有在 discord.py 官方文档上找到答案。任何形式的帮助
我开发了自己的简单 discord bot(使用 discord.js)并将其部署到节点服务器。 一切正常。 现在我想为它添加更多功能。在开发过程中,我想在本地进行测试(当然)。 问题是:我可以在本地
我正在使用 Discord.js 创建一个基本的 Discord 机器人。当机器人第一次启动时,我运行 client.guilds.array()获取机器人当前订阅的所有公会的列表。我将其保存到其他程
我想为付费成员(member)提供 Discord 服务器。我想我可以让他们通过 Stripe 付款,向他们发送付款邀请,然后定期运行 Python 脚本,该脚本检查我的所有 Discord 成员是否
我试图向我的机器人添加一些新功能,但它最终没有工作,所以我删除了新代码,现在它不会响应任何命令。它仍然在线,但正如我之前所说,它完全没有响应。我已经查看了代码,但找不到问题。我对编码机器人还是个新手,
我正在编写一个建议机器人,它应该将玩家的建议发送到我服务器中的建议 channel ,并在建议 channel 中用一些表情符号使用react。 问题是使用“消息”作为消息参数会对发送到触发代码的消息
我想创建一个清除命令,如果 example .clear @user#0000 100 它将清除@user#0000 发送的最后 100 条消息。这是我的代码: @commands.comma
所以,我想为我的机器人创建一个命令,它可以从给定的消息 ID 中获取所有反应并将这三个类别存储到数组中,对于每个 react : react 的名称(例如:smile:) 使用react的用户(例如
我正在尝试在 discord.js 上制作一个简单的右舷系统,删除消息部分让我很困惑。目前,如果一条消息获得星号,则会在右舷 channel 创建一个嵌入,而且至关重要的是,页脚是原始消息的 ID。我
我最近启动了一个新的 discord.js 机器人,但出现“无效 token ”错误。这不可能是因为 async 功能,因为我只启动了机器人并且我有 0 个命令,上次发生这种情况是当我试图在 hero
我正在尝试向我的机器人添加一条命令,该命令会回复用户邀请到服务器的总人数 我的代码: if message.content.startswith('!invites'): totalInvit
我在一些服务器/公会中添加了一个 Discord 机器人。我可以使用此处提供的资源获得特定公会: https://discord.com/developers/docs/resources/guild
我是一名优秀的程序员,十分优秀!