various fixes and refactorings
This commit is contained in:
parent
5a2dce2773
commit
d8c2513954
33
.eslintrc.js
33
.eslintrc.js
|
@ -1,21 +1,14 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
"env": {
|
env: {
|
||||||
"browser": true,
|
node: true,
|
||||||
"commonjs": true,
|
commonjs: true,
|
||||||
"es2021": true
|
es2021: true,
|
||||||
},
|
},
|
||||||
"extends": [
|
extends: ["eslint:recommended", "plugin:react/recommended"],
|
||||||
"eslint:recommended",
|
overrides: [],
|
||||||
"plugin:react/recommended"
|
parserOptions: {
|
||||||
],
|
ecmaVersion: "latest",
|
||||||
"overrides": [
|
},
|
||||||
],
|
plugins: ["react"],
|
||||||
"parserOptions": {
|
rules: {},
|
||||||
"ecmaVersion": "latest"
|
};
|
||||||
},
|
|
||||||
"plugins": [
|
|
||||||
"react"
|
|
||||||
],
|
|
||||||
"rules": {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -20,13 +20,17 @@ client.commands = getCommands();
|
||||||
console.log("Commands loaded");
|
console.log("Commands loaded");
|
||||||
|
|
||||||
client.on("ready", async () => {
|
client.on("ready", async () => {
|
||||||
console.log("connected to chat");
|
console.log("Connected to chat");
|
||||||
const channels = await prisma.channel.findMany();
|
|
||||||
|
console.log("Joining bots channel: " + process.env.TWITCH_USERNAME);
|
||||||
client.join(process.env.TWITCH_USERNAME);
|
client.join(process.env.TWITCH_USERNAME);
|
||||||
|
|
||||||
|
const channels = await prisma.channel.findMany();
|
||||||
for (let channel of channels) {
|
for (let channel of channels) {
|
||||||
console.log("Joining channel: " + channel.name);
|
console.log("Joining channel: " + channel.name);
|
||||||
client.join(channel.name);
|
client.join(channel.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("Joined channels");
|
console.log("Joined channels");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -48,7 +52,7 @@ client.on("PRIVMSG", async (msg) => {
|
||||||
|
|
||||||
if (splitted[0] === process.env.BOT_PREFIX) {
|
if (splitted[0] === process.env.BOT_PREFIX) {
|
||||||
try {
|
try {
|
||||||
if (!client.commands.hasOwnProperty(splitted[1])) {
|
if (!(splitted[1] in client.commands)) {
|
||||||
await client.say(msg.channelName, `${msg.displayName}, not a command`);
|
await client.say(msg.channelName, `${msg.displayName}, not a command`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ const command = {
|
||||||
mod: false,
|
mod: false,
|
||||||
run: async (client, msg, splitted) => {
|
run: async (client, msg, splitted) => {
|
||||||
const data = await fetch(
|
const data = await fetch(
|
||||||
`https://librex.nekus.gay/api.php?q="${encodeURIComponent(
|
`https://search.femboy.hu/api.php?q="${encodeURIComponent(
|
||||||
splitted.slice(2).join(" ")
|
splitted.slice(2).join(" ")
|
||||||
)}"`
|
)}"`
|
||||||
)
|
)
|
||||||
|
@ -29,7 +29,7 @@ const command = {
|
||||||
`${msg.displayName}, First result for query ${splitted
|
`${msg.displayName}, First result for query ${splitted
|
||||||
.slice(2)
|
.slice(2)
|
||||||
.join(" ")}: ${
|
.join(" ")}: ${
|
||||||
data.hasOwnProperty("special_response")
|
"special_response" in data
|
||||||
? `${data.special_response.response.replaceAll("\n", "")} - ${
|
? `${data.special_response.response.replaceAll("\n", "")} - ${
|
||||||
data.special_response.source
|
data.special_response.source
|
||||||
}`
|
}`
|
||||||
|
|
|
@ -6,6 +6,14 @@ const command = {
|
||||||
restricted: false,
|
restricted: false,
|
||||||
mod: false,
|
mod: false,
|
||||||
run: async (client, msg) => {
|
run: async (client, msg) => {
|
||||||
|
if (msg.channelName !== process.env.TWITCH_USERNAME) {
|
||||||
|
await client.say(
|
||||||
|
msg.channelName,
|
||||||
|
`${msg.displayName}, command only available in bot chat`
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!client.joinedChannels.has(msg.senderUsername)) {
|
if (!client.joinedChannels.has(msg.senderUsername)) {
|
||||||
await client.say(
|
await client.say(
|
||||||
msg.channelName,
|
msg.channelName,
|
||||||
|
|
Loading…
Reference in New Issue