0.0.11 • Published 2 years ago
@mostfeatured/tbi v0.0.11
TwitchBotInfrastructure
What is this?
This is a twurple wrapper, for ease of use. You can interact with any twicth api to code user bot.
Example
const { createTBI } = require("@mostfeatured/tbi");
const tbi = createTBI("erdem", {
default: {
locale: "en",
},
tokenPath: "./token.json",
twitch: [
{
namespace: "test-1",
clientId: "CLIENT_ID",
clientSecret: "CLIENT_SECRET",
redirectUri: "http://localhost:3000",
scopes: ["analytics:read:extensions", "analytics:read:games", "bits:read", "channel:edit:commercial", "channel:manage:broadcast", "channel:manage:extensions", "channel:manage:moderators", "channel:manage:polls", "channel:manage:predictions", "channel:manage:raids", "channel:manage:redemptions", "channel:manage:schedule", "channel:manage:videos", "channel:manage:vips", "channel:moderate", "channel:read:charity", "channel:read:editors", "channel:read:goals", "channel:read:hype_train", "channel:read:polls", "channel:read:predictions", "channel:read:redemptions", "channel:read:stream_key", "channel:read:vips", "chat:edit", "chat:read", "clips:edit", "moderation:read", "moderator:manage:announcements", "moderator:manage:automod", "moderator:manage:automod_settings", "moderator:manage:banned_users", "moderator:manage:blocked_terms", "moderator:manage:chat_messages", "moderator:manage:chat_settings", "moderator:manage:shield_mode", "moderator:read:automod_settings", "moderator:read:blocked_terms", "moderator:read:chat_settings", "moderator:read:chatters", "moderator:read:shield_mode", "user:edit", "user:edit:follows", "user:manage:blocked_users", "user:manage:chat_color", "user:manage:whispers", "user:read:blocked_users", "user:read:broadcast", "user:read:email", "user:read:follows", "user:read:subscriptions", "whispers:edit", "whispers:read"]
}
]
});
(async () => {
tbi.register(({ Event }) => {
Event({
name: "StreamOnline",
clientNamespace: "test-1",
usernames: ["OhaLava", "thearmagan_", "eridieru"],
onExecute: async ({ user }) => {
console.log(user?.username, "is online!")
}
});
Event({
name: "StreamOffline",
clientNamespace: "test-1",
usernames: ["OhaLava", "thearmagan_", "eridieru"],
onExecute: async ({ stream, user }) => {
console.log(user.username, "is offline!")
}
});
Event({
name: "Message",
clientNamespace: "test-1",
onExecute: async ({ content, raw }) => {
console.log("Message", content);
}
});
});
await tbi.load({
chat: {
channels: ["OhaLava", "thearmagan_", "eridieru"],
}
});
await tbi.login();
console.log("Logged in!", (await tbi.client.users.fetchMe()).username);
})();