这是我的代码:
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: client.config.openai,
});
const openai = new OpenAIApi(configuration);
client.on("messageCreate", async (message) => {
if (message.author.bot) return;
if (message.content.startsWith("!")) return;
if (message.channel.type !== ChannelType.DM) return;
let conversationLog = [
{ role: "system", content: "Hello, how can I help you?" },
];
conversationLog.push({
role: "user",
content: message.content,
});
await message.channel.sendTyping();
const result = await openai.createChatCompletion({
model: "gpt-3.5-turbo",
messages: conversationLog,
});
message.reply(result.data.choices[0].message);
});
这是我的问题,我试图创建一个聊天机器人,将只响应DM,而不是任何其他渠道/公会,但它失败了!当我把ChannelType.DM
转到ChannelType.GuildText
并在文本频道上聊天时,它会响应!我该怎么办?顺便说一句,这些是我的意图:
const {
Guilds,
GuildMembers,
GuildMessages,
MessageContent,
DirectMessages,
GuildVoiceStates,
} = GatewayIntentBits;
这些是我的部分:
const { User, Message, GuildMember, ThreadMember } = Partials;
任何答案都可以接受!
注意:
这个或this答案似乎不起作用!
1条答案
按热度按时间fwzugrvs1#
DM通道可以不缓存,因此您还需要添加
Channel
部分: