if (counterChannel && counterChannel.type === "GUILD_VOICE") {
const currentName = counterChannel.name;
const match = currentName.match(/^vouches-(\d+)$/);
if (match) {
const currentCount = parseInt(match[1]);
const newCount = currentCount + 1;
const newName = `vouches-${newCount}`;
await counterChannel.setName(newName);
console.log(`The counter channel's new name is ${newName}`);
} else {
console.error("Counter channel name format is invalid.");
}
} else {
console.error("Counter channel not found or is not a voice channel.");
}
我正在制作一个 Discord 机器人。它有一个 /vouch 命令,每次执行时计数器都应该增加 1,因此对于计数系统,我使用的是语音通道,每次都应该重命名,并且数字应该增加 1。
是的,所以它不太有效。