const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent
]
});
const players = new Map();
client.on('ready', () => {
console.log(`已登录为 ${client.user.tag}`);
});
client.on('messageCreate', (message) => {
if (message.author.bot) return;
const args = message.content.trim().split(/\s+/);
const command = args.shift().toLowerCase();
if (command === '探索') {
const [x, y] = args[0]?.split(',') || [1, 1];
const playerId = message.author.id;
if (x === '1' && y === '1') {
const rand = Math.random() < 0.5 ? 'A' : 'B';
players.set(playerId, { x, y, currentEvent: rand });
if (rand === 'A') {
message.reply('[剧情A] 你发现了一封信!\n输入 `选择 1` 打开');
} else {
message.reply('[剧情B] 你遇到受伤的旅人!\n输入 `选择 1` 帮助');
}
}
} else if (command === '选择') {
const player = players.get(message.author.id);
if (!player) return;
const choice = args[0];
if (player.currentEvent === 'A' && choice === '1') {
message.reply('信上写着:**小心龙之巢穴!**\n1. 前往调查\n2. 忽略');
} else if (player.currentEvent === 'B' && choice === '1') {
message.reply('旅人给了你一把钥匙!\n1. 去开宝箱\n2. 卖掉');
}
}
});
client.login('你的机器人TOKEN');