我正在为抽搐平台编写一个机器人,我想让它对订阅该频道的用户做出响应。
我在文档https://dev.twitch.tv/docs/irc/commands#usernotice中找到了这方面的USERNOTICE
但我不太懂怎么用它。
像这样吗?
client.on("message", () => {
client.say(config.get('channel'), '/usernotice message');
});只需调用/usernotice命令,它应该响应此订阅消息吗?
这只是很难测试所有这些,我希望有一个或多或少的具体解决方案。
更新
在旧文档中,我还找到了以下代码
chatClient.onSub((channel, user) => {
chatClient.say(channel, `Thanks to @${user} for subscribing to the channel!`);
});
chatClient.onResub((channel, user, subInfo) => {
chatClient.say(channel, `Thanks to @${user} for subscribing to the channel for a total of ${subInfo.months} months!`);
});
chatClient.onSubGift((channel, user, subInfo) => {
chatClient.say(channel, `Thanks to ${subInfo.gifter} for gifting a subscription to ${user}!`);
});但是它抛出一个错误- TypeError: client.onSub不是一个函数。
现在有什么办法可以用吗?
chatClient.on('sub', (channel, user) => {
chatClient.say(channel, `Thanks to @${user} for subscribing to the channel!`);
});发布于 2022-05-31 01:07:14
假设您使用的是tmi.js,那么您应该查看tmi.js文档,而不是twitch的文档。这个文档可以位于这里。
在文档中,他们有一个订阅事件的示例,可以在这里找到:posts/v1.4.2/2019-03-03-Events.md#subscription
client.on("subscription", (channel, username, method, message, userstate) => {
// Do your stuff.
});https://stackoverflow.com/questions/72395646
复制相似问题