【发布时间】:2021-12-10 05:56:56
【问题描述】:
它是如何工作的:
我正在努力做到这一点,如果有人对工作人员发送的消息做出反应,它会打开一张票。
问题:
我想使用成员的 id,但它太大了。 我尝试使用播放器的名称,但由于某种原因它没有找到它作为频道,也许唯一的数字更好?
我使用的是命令处理系统,所以你不会看到任何基本的东西(例如client.login)
这是我的代码:
const { Discord } = require('discord.js');
const axios = require("axios")
module.exports = {
name: 'thing',
category: 'Owner',
aliases: ["t"],
description: 'thing command.',
usage: 'thing',
userperms: [],
botperms: [],
run: async (client, message, args) => {
message.channel.send('Click "⚔" to open a ticket!').then(function(message) {
message.react('⚔');
const filter = (reaction, user) => {
return ['⚔'].includes(reaction.emoji.name) && user.id === message.author.id;
}});
client.on('messageReactionAdd', (reaction, ruser) => {
if (!ruser.bot) {
if (reaction.emoji.name == '⚔') {
if(message.guild.channels.cache.find(channel => channel.name == (`t-${ruser.id}`))) {
return message.channel.send('<@' + ruser.id + '> you already have a ticket, please close your existing ticket first before opening a new one!')
.then(m => m.delete({timeout: 3000}));
}
message.guild.channels.create(`t-${ruser.id}`, {
permissionOverwrites: [
{
id: message.author.id,
allow: ['SEND_MESSAGES', 'VIEW_CHANNEL'],
},
{
id: message.guild.roles.everyone,
deny: ['VIEW_CHANNEL'],
},
],
type: 'text',
}).then(async channel => {
message.channel.send(`<@` + ruser.id + `>, you have successfully created a ticket! Please click on ${channel} to view your ticket.`)
.then(m => m.delete({timeout: 3000}));
channel.send(`Hi <@` + ruser.id + `>, welcome to your ticket! Please be patient, we will be with you shortly.`);
const logchannel = message.guild.channels.cache.find(channel => channel.name === 'server-logs');
if(logchannel) {
logchannel.send(`Ticket-${ruser.username} created. Click the following to veiw <#${channel.id}>`);
}
});
}
}});
}}
【问题讨论】:
标签: javascript discord.js