带编号的购票渠道名称

Ticket channel name with numbers

我有一个支持票系统,但我希望我的频道被命名为:USERNAME-001。 即使删除了旧的,它仍然是 USERNAME-002。 在 300 处是 001。 我不知道我是否被理解了。 我想有点像 public discord 机器人:Tickety:http://prntscr.com/mwiqp5 因为现在它就像:USERNAME-USERNAMEDISCRIMINATOR : http://prntscr.com/mwit8q

询问我是否需要有关部分代码或请求的更多详细信息...

我创建当前频道的代码:

message.guild.createChannel(message.author.username + " - " + message.author.discriminator, "text").then((channel) => {

此致

const counter = 0; // This has to defined in previous code. If I were you, I would use a database for this.

正如我在评论中所写,我会为此使用一个数据库,您可以在其中计算在 Discord 服务器上创建的每张票。

然后你可以使用下面的代码:

var reached300 = false;

if (reached300 === true && counter !== 0) {
  counter -= 1;
} else {
  counter += 1;
}

if (counter === 300) {
  reached300 = true;
} else if (counter === 0) {
  reached300 = false;
}

var counterName;

if (counter <= 10) {
  counterName = `#000${counter}`
} else if (counter <= 100) {
  counterName = `#00${counter}`
} else if (counter <= 1000) {
  counterName = `#0${counter}`
} else {
  counterName = `#${counter}`
}

message.guild.createChannel(`ticket-${counterName}`, "text").then((channel) => {
 // CODE HERE
});