Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
retconned committed Feb 1, 2025
2 parents 619a6eb + 3715521 commit f5551b5
Show file tree
Hide file tree
Showing 9 changed files with 585 additions and 397 deletions.
35 changes: 20 additions & 15 deletions examples/basic-bot.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
import { createClient, type MessageData } from "@retconned/kick-js";
import "dotenv/config";

const client = createClient("xqc", { logger: true });
const client = createClient("xqc", { logger: true, readOnly: false });

// client.login({
// type: "login",
// credentials: {
// username: process.env.USERNAME!,
// password: process.env.PASSWORD!,
// otp_secret: process.env.OTP_SECRET!,
// },
// });

client.login({
username: process.env.USERNAME!,
password: process.env.PASSWORD!,
otp_secret: process.env.OTP_SECRET!,
type: "tokens",
credentials: {
bearerToken: process.env.BEARER_TOKEN!,
xsrfToken: process.env.XSRF_TOKEN!,
cookies: process.env.COOKIES!,
},
});

client.on("ready", () => {
Expand All @@ -16,28 +29,20 @@ client.on("ChatMessage", async (message: MessageData) => {
console.log(`${message.sender.username}: ${message.content}`);

if (message.content.match("!ping")) {
client.sendMessage("pong");
client.sendMessage(Math.random().toString(36).substring(7));
}

if (message.content.match("!slowmode on")) {
const splitMessage = message.content.split(" ");
const duration = splitMessage[1];
if (duration) {
const durationNumber = parseInt(duration);
client.slowMode("on", durationNumber);
const durationInSeconds = parseInt(duration);
client.slowMode("on", durationInSeconds);
}
}
if (message.content.match("!slowmode off")) {
client.slowMode("off");
}

if (message.content.match("!ban")) {
const splitMessage = message.content.split(" ");
const bannedUser = splitMessage[1];
if (bannedUser) {
client.permanentBan(bannedUser);
}
}
});

client.on("Subscription", async (subscription) => {
Expand Down
Loading

0 comments on commit f5551b5

Please sign in to comment.