Compare commits

...

2 Commits

5 changed files with 53 additions and 9 deletions

View File

@ -1,3 +1,5 @@
const prisma = require("../clients/prisma");
const command = { const command = {
name: "join", name: "join",
desc: "make the bot listen to a channel", desc: "make the bot listen to a channel",
@ -18,6 +20,21 @@ const command = {
return; return;
} }
const storeChannel = await prisma.channel.create({
data: {
name: msg.senderUsername,
},
});
if (!storeChannel) {
await client.say(
msg.channelName,
`${msg.displayName}, something went wrong saving`
);
return;
}
await client await client
.join(msg.senderUsername) .join(msg.senderUsername)
.then( .then(
@ -26,14 +43,14 @@ const command = {
msg.channelName, msg.channelName,
`${msg.displayName}, joined ${msg.senderUsername} BroBalt` `${msg.displayName}, joined ${msg.senderUsername} BroBalt`
) )
) );
.then(() => client.say(msg.senderUsername, "MrDestructoid"))
.catch( await client
async () => .say(msg.senderUsername, "MrDestructoid")
await client.say( .catch((err) =>
msg.channelName, console.error(
`${msg.displayName}, the bot is probably in your chat, but can't speak because of phone number etc verification` `The bot can't speak in the newly joined channel! Error: ${err.message}`
) )
); );
}, },
}; };

View File

@ -17,7 +17,7 @@ const command = {
os.totalmem() / 1024 / 1024 os.totalmem() / 1024 / 1024
)}mb Joined channels count: ${ )}mb Joined channels count: ${
client.joinedChannels.size client.joinedChannels.size
} Megis drinkers count: ${await prisma.user.count()}` } Megis drinkers count: ${await prisma.megis.count()}`
); );
}, },
}; };

14
commands/repo.js Normal file
View File

@ -0,0 +1,14 @@
const command = {
name: "repo",
desc: "get the git repo of bot",
restricted: false,
mod: false,
run: async (client, msg) => {
await client.say(
msg.channelName,
`${msg.displayName}, https://git.disroot.org/qwertyasdfgh/twitch_bot Author: juuuuuuuuuuuuunas`
);
},
};
module.exports = { command };

View File

@ -0,0 +1,8 @@
-- CreateTable
CREATE TABLE "Channel" (
"id" TEXT NOT NULL PRIMARY KEY,
"name" TEXT NOT NULL
);
-- CreateIndex
CREATE UNIQUE INDEX "Channel_name_key" ON "Channel"("name");

View File

@ -10,6 +10,11 @@ datasource db {
url = env("DATABASE_URL") url = env("DATABASE_URL")
} }
model Channel {
id String @id @default(uuid())
name String @unique
}
model User { model User {
id String @id @default(uuid()) id String @id @default(uuid())
userId String @unique userId String @unique