feat: dev mode :D

This commit is contained in:
2022-11-24 17:19:03 +01:00
parent 96814b196f
commit 46ae4ffea9
15 changed files with 182 additions and 43 deletions

1
.gitignore vendored
View File

@@ -1,4 +1,5 @@
.env
.env.dev
node_modules/
json.sqlite
dist/

View File

@@ -38,8 +38,8 @@ export default commandModule({
.setLabel('0')
.setStyle(ButtonStyle.Danger),
)
const message1 = await (await modal.client.guilds.fetch('928018226330337280'))
.channels.fetch('1007269448140476436') as TextChannel;
const message1 = await (await modal.client.guilds.fetch(process.env.GUILDID!))
.channels.fetch(process.env.SUGGESTIONS_CHANNEL!) as TextChannel;
const message2 = await message1.send({ embeds: [embed], components: [buttons] });
message2.startThread({
name: `Sugerencia de ${modal.user.username}`,

View File

@@ -26,7 +26,7 @@ export default commandModule({
const userToBan = options[1].getMember('usuario') as GuildMember
const reason = options[1].getString('razon') as string
userToBan.ban({reason: reason})
const sendToMods = ctx.client.guilds.cache.get('928018226330337280')!.channels.cache.get('1004118323258208257') as TextChannel
const sendToMods = ctx.client.guilds.cache.get(process.env.GUILDID!)!.channels.cache.get(process.env.MODLOGS_CHANNEL!) as TextChannel
await sendToMods.send({content: `Se ha baneado a ${userToBan}.\nBan efectuado por ${ctx.user} con razón "${reason}."`})
await ctx.reply({content: 'Baneado correctamente!', ephemeral: true})
} catch (e) {

View File

@@ -28,7 +28,7 @@ export default commandModule({
const userToKick = options[1].getMember('usuario');
const reason = options[1].getString('razon') as string;
(userToKick as GuildMember).kick(reason)
const sendToMods = ctx.client.guilds.cache.get('928018226330337280')!.channels.cache.get('1004118323258208257') as TextChannel
const sendToMods = ctx.client.guilds.cache.get(process.env.GUILDID!)!.channels.cache.get(process.env.MODLOGS_CHANNEL!) as TextChannel
await sendToMods!.send({content: `Se ha expulsado a ${userToKick}.\nKick efectuado por ${ctx.user} con razón "${reason}."`})
await ctx.reply({content: 'Expulsado correctamente!'})
} catch (e) {

View File

@@ -24,7 +24,7 @@ export default commandModule({
console.error(err);
ctx.reply({content: 'Ha habido un error eliminando mensajes! (mira la consola, Sr Izan)', ephemeral: true});});
await ctx.reply({content: `Se han eliminado ${amount} mensajes.`})
const sendToMods = ctx.client.guilds.cache.get('928018226330337280')!.channels.cache.get('1004118323258208257') as TextChannel
const sendToMods = ctx.client.guilds.cache.get(process.env.GUILDID!)!.channels.cache.get(process.env.MODLOGS_CHANNEL!) as TextChannel
await sendToMods.send({content: `Se han eliminado ${amount} mensajes en ${ctx.channel}\nEfectuado por ${ctx.user}.`})
} catch (e){
ctx.reply({content: 'Ha habido un error eliminando mensajes! Error reportado automáticamente.', ephemeral: true})};

View File

@@ -31,7 +31,7 @@ export default commandModule({
(ctx.channel as TextChannel).setRateLimitPerUser(seconds, reason)
ctx.reply({content: `Se han añadido ${seconds} segundos de modo lento al canal de voz actual`})
const sendToMods = ctx.client.guilds.cache.get('928018226330337280')!.channels.cache.get('1004118323258208257') as TextChannel
const sendToMods = ctx.client.guilds.cache.get(process.env.GUILDID!)!.channels.cache.get(process.env.MODLOGS_CHANNEL!) as TextChannel
await sendToMods.send({content: `Se ha aplicado modo lento al canal ${ctx.channel}.\nEfectuado por ${ctx.user} con ${seconds} segundos de retardo.\nRazón: ${reason}`})
} catch (e) {
ctx.reply({content: `No se ha podido aplicar modo lento al canal.`})

View File

@@ -41,7 +41,7 @@ export default commandModule({
const razon = options[1].getString('razon', true);
const minutosToMilisegundos = minutos * 60 * 1000
usuario.timeout(minutosToMilisegundos, razon).then(() => {ctx.reply({content: `Se ha silenciado a ${usuario} correctamente.`, ephemeral: true})})
const sendToMods = ctx.client.guilds.cache.get('928018226330337280')!.channels.cache.get('1004118323258208257') as TextChannel
const sendToMods = ctx.client.guilds.cache.get(process.env.GUILDID!)!.channels.cache.get(process.env.MODLOGS_CHANNEL!) as TextChannel
await sendToMods.send({content: `Se ha silenciado a ${usuario}.\nSlencio efectuado por ${ctx.user} con ${minutos} minutos de duración.\nRazón: ${razon}`})
} catch (e) {
await ctx.reply({content: `ERROR: No puedo hacer este comando porque a lo mejor soy inferior que el rol de esa persona o estoy usándolo contra admins.`})

View File

@@ -13,7 +13,7 @@ export default eventModule({
.setThumbnail(member.user.displayAvatarURL())
.setTimestamp();
const channel = member.client.guilds.cache.get('928018226330337280')!.channels.cache.get('993599947364634694') as TextChannel
const channel = member.client.guilds.cache.get(process.env.GUILDID!)!.channels.cache.get(process.env.JOINSANDLEAVES_CHANNEL!) as TextChannel
channel.send({embeds: [newMemberEmbed]})
}
});

View File

@@ -14,7 +14,7 @@ export default eventModule({
.setThumbnail(member.user.displayAvatarURL())
.setTimestamp();
const channel = member.client.guilds.cache.get('928018226330337280')!.channels.cache.get('993599947364634694') as TextChannel
const channel = member.client.guilds.cache.get(process.env.GUILDID!)!.channels.cache.get(process.env.JOINSANDLEAVES_CHANNEL!) as TextChannel
channel.send({embeds: [leaveEmbed]})
}
});

View File

@@ -2,7 +2,14 @@ import { SernEmitter } from '@sern/handler';
import { ActivityType } from 'discord.js';
import { Client, GatewayIntentBits } from 'discord.js';
import { Sern } from '@sern/handler';
import 'dotenv/config';
import { config as dotenv } from 'dotenv';
let devMode
if (process.argv[2] === '--dev') {
devMode = true
dotenv({path: './.env.dev'})
} else {
dotenv()
}
import mongoose from 'mongoose';
import express from 'express';
import youtubenotifications from './util/youtubenotifications.js';
@@ -23,7 +30,7 @@ const client = new Client({
],
});
export const db = mongoose.connect(process.env.MONGODB as string).then(() => {
export const db = mongoose.connect(process.env.MONGODB!).then(() => {
console.log('Connected to MongoDB');
});
@@ -51,17 +58,21 @@ client.on('ready', async () => {
client.user!.setActivity(randomStatus);
}, 10000);
setIntervalAsync(async () => {
await youtubenotifications(client);
}, 120_000);
if (!devMode) {
setIntervalAsync(async () => {
await youtubenotifications(client);
}, 120_000);
setIntervalAsync(async () => {
await twitternotifications(client);
}, 120_000);
setIntervalAsync(async () => {
await twitternotifications(client);
}, 120_000);
setIntervalAsync(async () => {
await birthdays(client);
}, 3_600_000);
setIntervalAsync(async () => {
await birthdays(client);
}, 3_600_000);
} else {
console.log('DevMode got activated, there are no checkers in this version.')
}
});
client.on('rateLimit', async () => {

155
package-lock.json generated
View File

@@ -12,7 +12,6 @@
"@discordjs/opus": "^0.9.0",
"@discordjs/voice": "^0.13.0",
"@sern/handler": "^1.2.1",
"@xmldom/xmldom": "^0.8.5",
"axios": "^1.0.0",
"dayjs": "^1.11.6",
"discord-bot-youtube-notifications": "^1.1.4",
@@ -29,6 +28,7 @@
"tweetnacl": "^1.0.3"
},
"devDependencies": {
"@types/express": "^4.17.14",
"ts-node": "10.9.1",
"tsc-watch": "^5.0.3",
"typescript": "4.9.3"
@@ -352,6 +352,16 @@
"dev": true,
"license": "MIT"
},
"node_modules/@types/body-parser": {
"version": "1.19.2",
"resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.2.tgz",
"integrity": "sha512-ALYone6pm6QmwZoAgeyNksccT9Q4AWZQ6PvfwR37GT6r6FWUPguq6sUmNGSMV2Wr761oQoBxwGGa6DR5o1DC9g==",
"dev": true,
"dependencies": {
"@types/connect": "*",
"@types/node": "*"
}
},
"node_modules/@types/cacheable-request": {
"version": "6.0.2",
"license": "MIT",
@@ -362,6 +372,38 @@
"@types/responselike": "*"
}
},
"node_modules/@types/connect": {
"version": "3.4.35",
"resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.35.tgz",
"integrity": "sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ==",
"dev": true,
"dependencies": {
"@types/node": "*"
}
},
"node_modules/@types/express": {
"version": "4.17.14",
"resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.14.tgz",
"integrity": "sha512-TEbt+vaPFQ+xpxFLFssxUDXj5cWCxZJjIcB7Yg0k0GMHGtgtQgpvx/MUQUeAkNbA9AAGrwkAsoeItdTgS7FMyg==",
"dev": true,
"dependencies": {
"@types/body-parser": "*",
"@types/express-serve-static-core": "^4.17.18",
"@types/qs": "*",
"@types/serve-static": "*"
}
},
"node_modules/@types/express-serve-static-core": {
"version": "4.17.31",
"resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.31.tgz",
"integrity": "sha512-DxMhY+NAsTwMMFHBTtJFNp5qiHKJ7TeqOo23zVEM9alT1Ml27Q3xcTH0xwxn7Q0BbMcVEJOs/7aQtUWupUQN3Q==",
"dev": true,
"dependencies": {
"@types/node": "*",
"@types/qs": "*",
"@types/range-parser": "*"
}
},
"node_modules/@types/http-cache-semantics": {
"version": "4.0.1",
"license": "MIT"
@@ -373,10 +415,28 @@
"@types/node": "*"
}
},
"node_modules/@types/mime": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/@types/mime/-/mime-3.0.1.tgz",
"integrity": "sha512-Y4XFY5VJAuw0FgAqPNd6NNoV44jbq9Bz2L7Rh/J6jLTiHBSBJa9fxqQIvkIld4GsoDOcCbvzOUAbLPsSKKg+uA==",
"dev": true
},
"node_modules/@types/node": {
"version": "18.8.3",
"license": "MIT"
},
"node_modules/@types/qs": {
"version": "6.9.7",
"resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.7.tgz",
"integrity": "sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw==",
"dev": true
},
"node_modules/@types/range-parser": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.4.tgz",
"integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==",
"dev": true
},
"node_modules/@types/responselike": {
"version": "1.0.0",
"license": "MIT",
@@ -384,6 +444,16 @@
"@types/node": "*"
}
},
"node_modules/@types/serve-static": {
"version": "1.15.0",
"resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.0.tgz",
"integrity": "sha512-z5xyF6uh8CbjAu9760KDKsH2FcDxZ2tFCsA4HIMWE6IkiYMXfVoa+4f9KX+FN0ZLsaMw1WNG2ETLA6N+/YA+cg==",
"dev": true,
"dependencies": {
"@types/mime": "*",
"@types/node": "*"
}
},
"node_modules/@types/webidl-conversions": {
"version": "7.0.0",
"license": "MIT"
@@ -403,14 +473,6 @@
"@types/node": "*"
}
},
"node_modules/@xmldom/xmldom": {
"version": "0.8.5",
"resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.8.5.tgz",
"integrity": "sha512-0dpjDLeCXYThL2YhqZcd/spuwoH+dmnFoND9ZxZkAYxp1IJUB2GP16ow2MJRsjVxy8j1Qv8BJRmN5GKnbDKCmQ==",
"engines": {
"node": ">=10.0.0"
}
},
"node_modules/agent-base": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz",
@@ -3105,6 +3167,16 @@
"version": "1.0.3",
"dev": true
},
"@types/body-parser": {
"version": "1.19.2",
"resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.2.tgz",
"integrity": "sha512-ALYone6pm6QmwZoAgeyNksccT9Q4AWZQ6PvfwR37GT6r6FWUPguq6sUmNGSMV2Wr761oQoBxwGGa6DR5o1DC9g==",
"dev": true,
"requires": {
"@types/connect": "*",
"@types/node": "*"
}
},
"@types/cacheable-request": {
"version": "6.0.2",
"requires": {
@@ -3114,6 +3186,38 @@
"@types/responselike": "*"
}
},
"@types/connect": {
"version": "3.4.35",
"resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.35.tgz",
"integrity": "sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ==",
"dev": true,
"requires": {
"@types/node": "*"
}
},
"@types/express": {
"version": "4.17.14",
"resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.14.tgz",
"integrity": "sha512-TEbt+vaPFQ+xpxFLFssxUDXj5cWCxZJjIcB7Yg0k0GMHGtgtQgpvx/MUQUeAkNbA9AAGrwkAsoeItdTgS7FMyg==",
"dev": true,
"requires": {
"@types/body-parser": "*",
"@types/express-serve-static-core": "^4.17.18",
"@types/qs": "*",
"@types/serve-static": "*"
}
},
"@types/express-serve-static-core": {
"version": "4.17.31",
"resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.31.tgz",
"integrity": "sha512-DxMhY+NAsTwMMFHBTtJFNp5qiHKJ7TeqOo23zVEM9alT1Ml27Q3xcTH0xwxn7Q0BbMcVEJOs/7aQtUWupUQN3Q==",
"dev": true,
"requires": {
"@types/node": "*",
"@types/qs": "*",
"@types/range-parser": "*"
}
},
"@types/http-cache-semantics": {
"version": "4.0.1"
},
@@ -3123,15 +3227,43 @@
"@types/node": "*"
}
},
"@types/mime": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/@types/mime/-/mime-3.0.1.tgz",
"integrity": "sha512-Y4XFY5VJAuw0FgAqPNd6NNoV44jbq9Bz2L7Rh/J6jLTiHBSBJa9fxqQIvkIld4GsoDOcCbvzOUAbLPsSKKg+uA==",
"dev": true
},
"@types/node": {
"version": "18.8.3"
},
"@types/qs": {
"version": "6.9.7",
"resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.7.tgz",
"integrity": "sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw==",
"dev": true
},
"@types/range-parser": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.4.tgz",
"integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==",
"dev": true
},
"@types/responselike": {
"version": "1.0.0",
"requires": {
"@types/node": "*"
}
},
"@types/serve-static": {
"version": "1.15.0",
"resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.0.tgz",
"integrity": "sha512-z5xyF6uh8CbjAu9760KDKsH2FcDxZ2tFCsA4HIMWE6IkiYMXfVoa+4f9KX+FN0ZLsaMw1WNG2ETLA6N+/YA+cg==",
"dev": true,
"requires": {
"@types/mime": "*",
"@types/node": "*"
}
},
"@types/webidl-conversions": {
"version": "7.0.0"
},
@@ -3148,11 +3280,6 @@
"@types/node": "*"
}
},
"@xmldom/xmldom": {
"version": "0.8.5",
"resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.8.5.tgz",
"integrity": "sha512-0dpjDLeCXYThL2YhqZcd/spuwoH+dmnFoND9ZxZkAYxp1IJUB2GP16ow2MJRsjVxy8j1Qv8BJRmN5GKnbDKCmQ=="
},
"agent-base": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz",

View File

@@ -5,11 +5,10 @@
"main": "index.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "tsc-watch --onSuccess \"node ./dist/index.js\"",
"dev": "tsc-watch --onSuccess \"node ./dist/index.js --dev\"",
"compile": "tsc --build",
"build": "tsc --build",
"web": "node webserver.js",
"start": "ts-node index.ts"
"web": "node webserver.js"
},
"repository": {
"type": "git",
@@ -45,6 +44,7 @@
"tweetnacl": "^1.0.3"
},
"devDependencies": {
"@types/express": "^4.17.14",
"ts-node": "10.9.1",
"tsc-watch": "^5.0.3",
"typescript": "4.9.3"

View File

@@ -15,8 +15,8 @@ db.find({}, (err, user) => {
if (finduser!.alreadysent === true && dayjs().format('D-M') !== finduser!.date) return saveit()
if (finduser!.alreadysent === true) return
const sendtochannel = (await (
await client.guilds.fetch("928018226330337280")
).channels.fetch("1039613653269352449")) as TextChannel;
await client.guilds.fetch(process.env.GUILDID!)
).channels.fetch(process.env.BIRTHDAYS_CHANNEL!)) as TextChannel;
const message = await sendtochannel.send({ content: `Hola <@&1039613683422208020>!\nHoy es el cumpleaños de <@${finduser!.id}> 🎉🎉🎉\nMuchas felicidades!` })
message.react('🎉')
message.react('<:Pog:1030169609178976346>')

View File

@@ -17,8 +17,8 @@ export default async function twitternotifications(client: Client) {
.then((res) => res.data)
).data[0].id;
const fetchTextChannel = (await (
await client.guilds.fetch('928018226330337280')
).channels.fetch('948690278498320404')) as TextChannel;
await client.guilds.fetch(process.env.GUILDID!)
).channels.fetch(process.env.SOCIALS_CHANNEL!)) as TextChannel;
if (request === db?.id) return;
else {
db!.id = request;

View File

@@ -15,8 +15,8 @@ export default async function youtubenotifications(client: Client) {
)
.then((res) => res.data);
const fetchTextChannel = (await (
await client.guilds.fetch('928018226330337280')
).channels.fetch('948690278498320404')) as TextChannel;
await client.guilds.fetch(process.env.GUILDID!)
).channels.fetch(process.env.SOCIALS_CHANNEL!)) as TextChannel;
if (request === db!.id) return;
else {
db!.id = request;