mirror of
https://github.com/qwerinope/qweribot.git
synced 2025-12-18 15:01:38 +01:00
add basic sub handling
This commit is contained in:
32
src/events/subscription.ts
Normal file
32
src/events/subscription.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { sendMessage } from "commands";
|
||||
import { getUserRecord } from "db/dbUser";
|
||||
import { changeBalance } from "lib/changeBalance";
|
||||
import { eventSub, streamerId } from "main";
|
||||
import User from "user";
|
||||
|
||||
eventSub.onChannelSubscription(streamerId, async msg => {
|
||||
if (msg.isGift) return;
|
||||
const user = await User.initUsername(msg.userName);
|
||||
await Promise.all([
|
||||
sendMessage(`YO THANKS FOR THE SUB ${msg.userDisplayName}! YOU GET 500 QBUCKS`),
|
||||
changeBalance(user!, await getUserRecord(user!), 500)
|
||||
]);
|
||||
});
|
||||
|
||||
eventSub.onChannelSubscriptionGift(streamerId, async msg => {
|
||||
if (msg.isAnonymous) { await sendMessage(`YO THANKS ANON FOR THE SCAM SUBS`); return; };
|
||||
const user = await User.initUsername(msg.gifterName);
|
||||
const amount = msg.amount;
|
||||
await Promise.all([
|
||||
sendMessage(`YO THANKS FOR THE SCAM GIFTS ${msg.gifterDisplayName}! YOU GET ${amount * 500} QBUCKS`),
|
||||
changeBalance(user!, await getUserRecord(user!), amount * 500)
|
||||
]);
|
||||
});
|
||||
|
||||
eventSub.onChannelSubscriptionEnd(streamerId, async msg => {
|
||||
|
||||
});
|
||||
|
||||
eventSub.onChannelSubscriptionMessage(streamerId, async msg => {
|
||||
|
||||
});
|
||||
@@ -12,7 +12,7 @@ import { connectionCheck } from "connectionCheck";
|
||||
await connectionCheck();
|
||||
|
||||
const CHATTERINTENTS = ["user:read:chat", "user:write:chat", "user:bot", "user:manage:whispers"];
|
||||
const STREAMERINTENTS = ["channel:bot", "user:read:chat", "moderation:read", "channel:manage:moderators", "moderator:manage:chat_messages", "moderator:manage:banned_users", "bits:read", "channel:moderate", "moderator:manage:shoutouts"];
|
||||
const STREAMERINTENTS = ["channel:bot", "user:read:chat", "moderation:read", "channel:manage:moderators", "moderator:manage:chat_messages", "moderator:manage:banned_users", "bits:read", "channel:moderate", "moderator:manage:shoutouts", "channel:read:subscriptions"];
|
||||
|
||||
export const singleUserMode = process.env.CHATTER_IS_STREAMER === 'true';
|
||||
export const chatterId = process.env.CHATTER_ID ?? "";
|
||||
|
||||
Reference in New Issue
Block a user