我最近在我的discord机器人上玩了很多本地化游戏,我在想一些事情.
使用本地化时,您可以根据用户的语言设置创建使用不同语言的回复.
如代码here所示:
client.on(Events.InteractionCreate, interaction => {
const locales = {
pl: 'Witaj Świecie!',
de: 'Hallo Welt!',
};
interaction.reply(locales[interaction.locale] ?? 'Hello World (default is english)');
});
我的问题是,我想做同样的事情,除了使用临时性参数,如下所示:
await interaction.followUp({ content: 'Pong !', ephemeral: true });
但当我试图将两者混合在一起时:
async execute(interaction) {
const locales = {
pl: 'Witaj Świecie!',
de: 'Hallo Welt!',
};
await interaction.reply(locales[interaction.locale] ?? 'Hello World!', ephemeral: true);
});
这是行不通的,因为你应该写一个简短的答案是这样的:
await interaction.followUp({ content: 'Pong again!', ephemeral: true });
所以我想知道有没有人有 idea ,关于如何使回复本地化和短暂,并可能更改我的代码,使其工作.
那就太有帮助了,谢谢!