Update Bot to latest Discordeno Version 21.0.0 and add nsfw check for rule34 and yandere api calls
This commit is contained in:
@@ -14,10 +14,10 @@
|
||||
"admin": "deno -A --watch --check src/bot.ts"
|
||||
},
|
||||
"imports": {
|
||||
"@discordeno": "npm:@discordeno@18.0.1",
|
||||
"@discordeno": "npm:discordeno@21.0.0",
|
||||
"@melvdouc/xml-parser": "jsr:@melvdouc/xml-parser@^0.1.1",
|
||||
"@std/assert": "jsr:@std/assert@1",
|
||||
"@types/node": "npm:@types/node@^22.5.4",
|
||||
"@types/node": "npm:@types/node@^22.14.1",
|
||||
|
||||
"@root/" : "./src/"
|
||||
},
|
||||
|
||||
85
deno.lock
generated
85
deno.lock
generated
@@ -14,9 +14,10 @@
|
||||
"jsr:@std/log@*": "0.224.7",
|
||||
"npm:@discordeno/bot@*": "19.0.0-next.b1bfe94",
|
||||
"npm:@types/node@*": "18.16.19",
|
||||
"npm:@types/node@^22.5.4": "22.13.13",
|
||||
"npm:discordeno@*": "18.0.1",
|
||||
"npm:discordeno@18.0.1": "18.0.1",
|
||||
"npm:@types/node@^22.14.1": "22.14.1",
|
||||
"npm:discordeno@*": "21.0.0",
|
||||
"npm:discordeno@21.0.0": "21.0.0",
|
||||
"npm:discordeno@21.0.0": "21.0.0",
|
||||
"npm:gson@*": "0.1.5"
|
||||
},
|
||||
"jsr": {
|
||||
@@ -73,34 +74,68 @@
|
||||
"@discordeno/bot@19.0.0-next.b1bfe94": {
|
||||
"integrity": "sha512-ZaPDaPM6tuxpRZCyuNB2rzqz2WYHH20IQdutu87jffW2dV26D3Nw8SJCE1LNdXdu9akes3VMXolkNsLJ5MW2Hw==",
|
||||
"dependencies": [
|
||||
"@discordeno/gateway",
|
||||
"@discordeno/rest",
|
||||
"@discordeno/types",
|
||||
"@discordeno/utils"
|
||||
"@discordeno/gateway@19.0.0-next.b1bfe94",
|
||||
"@discordeno/rest@19.0.0-next.b1bfe94",
|
||||
"@discordeno/types@19.0.0-next.b1bfe94",
|
||||
"@discordeno/utils@19.0.0-next.b1bfe94"
|
||||
]
|
||||
},
|
||||
"@discordeno/bot@21.0.0": {
|
||||
"integrity": "sha512-x6EcVHBvWIhjY5/lcwgZzzCiqdpKFZqu2qUaZqKb7RYS8L8Q8zY40hCnbToVehLB8+BGcnHzxCeEvWWg8tnT/g==",
|
||||
"dependencies": [
|
||||
"@discordeno/gateway@21.0.0",
|
||||
"@discordeno/rest@21.0.0",
|
||||
"@discordeno/types@21.0.0",
|
||||
"@discordeno/utils@21.0.0"
|
||||
]
|
||||
},
|
||||
"@discordeno/gateway@19.0.0-next.b1bfe94": {
|
||||
"integrity": "sha512-rNkcCua4Inx8NkuCjbuRBAAg+AIg1qYb24Fq6/Y2+1s+iO0VSQ/ZK8PRNbI2gSpAtAbfndvxA9kyU1ggwwLjNw==",
|
||||
"dependencies": [
|
||||
"@discordeno/types",
|
||||
"@discordeno/utils",
|
||||
"@discordeno/types@19.0.0-next.b1bfe94",
|
||||
"@discordeno/utils@19.0.0-next.b1bfe94",
|
||||
"ws"
|
||||
]
|
||||
},
|
||||
"@discordeno/gateway@21.0.0": {
|
||||
"integrity": "sha512-ur5Hatd1x86PPI4UnXKghAWat3vS90NvLJcpOSu1B1gYSENRZow8dohZ8Ov58SXWq5nZVuBYDJNCR248pWJvrg==",
|
||||
"dependencies": [
|
||||
"@discordeno/types@21.0.0",
|
||||
"@discordeno/utils@21.0.0",
|
||||
"fzstd",
|
||||
"ws"
|
||||
]
|
||||
},
|
||||
"@discordeno/rest@19.0.0-next.b1bfe94": {
|
||||
"integrity": "sha512-lLeP3hmMM0GFsO+VA3f9EKOwfIo1HvG1hudtlC1Er6BFWgArpz0/VizHbOyOr5SzZuzrQyfcBJJfEhC+48TsRg==",
|
||||
"dependencies": [
|
||||
"@discordeno/types",
|
||||
"@discordeno/utils"
|
||||
"@discordeno/types@19.0.0-next.b1bfe94",
|
||||
"@discordeno/utils@19.0.0-next.b1bfe94"
|
||||
]
|
||||
},
|
||||
"@discordeno/rest@21.0.0": {
|
||||
"integrity": "sha512-ew5ddhUd7Qyv/GSzCy42bEmRv0yr2PspCMsLD/NeMiTLd3+OrVN5pAxBN9z+9JpS/daiiD/PVmvuUAVx/nXTEw==",
|
||||
"dependencies": [
|
||||
"@discordeno/types@21.0.0",
|
||||
"@discordeno/utils@21.0.0"
|
||||
]
|
||||
},
|
||||
"@discordeno/types@19.0.0-next.b1bfe94": {
|
||||
"integrity": "sha512-X1MmdPFMyzjxFEANEPrrBjdJDJBAz4RTa1vpVlMp46C3dPqTwjMwijaPhPgPnFiSwt01lJ8WaFDpMvfqOwpQNg=="
|
||||
},
|
||||
"@discordeno/types@21.0.0": {
|
||||
"integrity": "sha512-TUZAEqqlXRNQji+NCaQo8DruzI8rXbBvMaZYsZvN9f03PrdSddzMOy3cjs4eeL6ZMVocmMVRIaVnB713blylCw=="
|
||||
},
|
||||
"@discordeno/utils@19.0.0-next.b1bfe94": {
|
||||
"integrity": "sha512-Y+j3G83vCVXiNSEQlFR9WWJ6GZhvBmIfFjb03zFcmHa20nHExILJJBEyDpS+ptziEyF7jB+2hNw5I/SKn8Zm2w==",
|
||||
"dependencies": [
|
||||
"@discordeno/types"
|
||||
"@discordeno/types@19.0.0-next.b1bfe94"
|
||||
]
|
||||
},
|
||||
"@discordeno/utils@21.0.0": {
|
||||
"integrity": "sha512-I7I3Szlk+LkT/CRmJJiLPsjuBUjbuXUCvOzsgWCltkxDMIGmQeNoQtFK7t89V1Gcc4icsrnHVMho1BcaAITijg==",
|
||||
"dependencies": [
|
||||
"@discordeno/types@21.0.0"
|
||||
]
|
||||
},
|
||||
"@fastify/busboy@2.1.1": {
|
||||
@@ -109,8 +144,8 @@
|
||||
"@types/node@18.16.19": {
|
||||
"integrity": "sha512-IXl7o+R9iti9eBW4Wg2hx1xQDig183jj7YLn8F7udNceyfkbn1ZxmzZXuak20gR40D7pIkIY1kYGx5VIGbaHKA=="
|
||||
},
|
||||
"@types/node@22.13.13": {
|
||||
"integrity": "sha512-ClsL5nMwKaBRwPcCvH8E7+nU4GxHVx1axNvMZTFHMEfNI7oahimt26P5zjVCRrjiIWj6YFXfE1v3dEp94wLcGQ==",
|
||||
"@types/node@22.14.1": {
|
||||
"integrity": "sha512-u0HuPQwe/dHrItgHHpmw3N2fYCR6x4ivMNbPHRkBVP4CvN+kiRrKHWk3i8tXiO/joPwXLMYvF9TTF0eqgHIuOw==",
|
||||
"dependencies": [
|
||||
"undici-types"
|
||||
]
|
||||
@@ -121,7 +156,7 @@
|
||||
"underscore"
|
||||
]
|
||||
},
|
||||
"discordeno@18.0.1": {
|
||||
"discordeno@21.0.0": {
|
||||
"integrity": "sha512-d3D/HpC39YGInmxy2HK90kPpMMu2gYYsWuwtEEFPWpq2hlR9dvad4ihvLursPz5bj4Ob1NWOgPv3kz/bwMSIpw==",
|
||||
"dependencies": [
|
||||
"@deno/shim-deno",
|
||||
@@ -130,6 +165,19 @@
|
||||
"ws"
|
||||
]
|
||||
},
|
||||
"discordeno@21.0.0": {
|
||||
"integrity": "sha512-NX1x5GtHbrNhpeahfHw+2A6/3bpec2obNjIZ/mkBUGWcpLWG/ZgJSIkkdQIxcrnQ3loQooo/5IpBucnFTiGATA==",
|
||||
"dependencies": [
|
||||
"@discordeno/bot@21.0.0",
|
||||
"@discordeno/gateway@21.0.0",
|
||||
"@discordeno/rest@21.0.0",
|
||||
"@discordeno/types@21.0.0",
|
||||
"@discordeno/utils@21.0.0"
|
||||
]
|
||||
},
|
||||
"fzstd@0.1.1": {
|
||||
"integrity": "sha512-dkuVSOKKwh3eas5VkJy1AW1vFpet8TA/fGmVA5krThl8YcOVE/8ZIoEA1+U1vEn5ckxxhLirSdY837azmbaNHA=="
|
||||
},
|
||||
"gson@0.1.5": {
|
||||
"integrity": "sha512-EK+P+vGnmekaPMEg9qC23hTNgRaJ6GfQFS73sYgzvFoVYLMX7dVOUVDbPXRnNtnr99rf6DpOn4wlSbS0puN8AQ==",
|
||||
"dependencies": [
|
||||
@@ -142,8 +190,8 @@
|
||||
"underscore@1.6.0": {
|
||||
"integrity": "sha512-z4o1fvKUojIWh9XuaVLUDdf86RQiq13AC1dmHbTpoyuu+bquHms76v16CjycCbec87J7z0k//SiQVk0sMdFmpQ=="
|
||||
},
|
||||
"undici-types@6.20.0": {
|
||||
"integrity": "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg=="
|
||||
"undici-types@6.21.0": {
|
||||
"integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ=="
|
||||
},
|
||||
"undici@5.28.4": {
|
||||
"integrity": "sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g==",
|
||||
@@ -172,7 +220,8 @@
|
||||
"dependencies": [
|
||||
"jsr:@melvdouc/xml-parser@~0.1.1",
|
||||
"jsr:@std/assert@1",
|
||||
"npm:@types/node@^22.5.4"
|
||||
"npm:@types/node@^22.14.1",
|
||||
"npm:discordeno@21.0.0"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
13
src/bot.ts
13
src/bot.ts
@@ -1,4 +1,4 @@
|
||||
import { createBot, Intents, startBot } from "npm:discordeno@18.0.1";
|
||||
import { createBot, Intents, Message } from "@discordeno";
|
||||
import { messagehandler } from "./messages.ts";
|
||||
import { EnvConst, loadConfig } from "@root/core/configLoader.ts";
|
||||
|
||||
@@ -12,15 +12,14 @@ const bot = createBot({
|
||||
ready() {
|
||||
console.log("Bot is ready!");
|
||||
},
|
||||
async messageCreate(bot, message) {
|
||||
await messagehandler(bot, message);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
bot.events.messageCreate = async(message) => {
|
||||
await messagehandler(bot, message as Message)
|
||||
}
|
||||
|
||||
// Setup desired properties
|
||||
|
||||
|
||||
|
||||
await startBot(bot);
|
||||
|
||||
await bot.start()
|
||||
@@ -1,9 +1,9 @@
|
||||
import * as stdlogger from "jsr:@std/log";
|
||||
import { Message } from "npm:discordeno@18.0.1";
|
||||
import { Message } from "@discordeno";
|
||||
|
||||
export function logMessage(message: Message) {
|
||||
return stdlogger.info(
|
||||
`Message from ${message.tag} in ${message.guildId?? "Private"} ${message.channelId} Command:[${message.content}]`
|
||||
`Message from ${message.author} in ${message.guildId?? "Private"} ${message.channelId} Command:[${message.content}]`
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Bot, Message } from "npm:discordeno@18.0.1";
|
||||
import { Bot, Message, Channel } from "@discordeno";
|
||||
import { yandereMessageHandler } from "@root/plugins/yandere/messages.ts";
|
||||
import { rule34MessageHandler } from "@root/plugins/rule34/messages.ts";
|
||||
|
||||
@@ -10,14 +10,16 @@ if (!prefix) {
|
||||
|
||||
export async function messagehandler(bot: Bot, message: Message) {
|
||||
const command = message.content.split(" ")[0];
|
||||
// const args = message.content.split(" ").slice(1);
|
||||
switch (command) {
|
||||
case `${prefix}rule`:
|
||||
await rule34MessageHandler(bot, message)
|
||||
if (message.thread?.nsfw) {
|
||||
await rule34MessageHandler(bot, message)
|
||||
}
|
||||
break
|
||||
case `${prefix}yande`:
|
||||
await yandereMessageHandler(bot, message)
|
||||
if (message.thread?.nsfw) {
|
||||
await yandereMessageHandler(bot, message)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Bot, DiscordEmbedAuthor, Message } from "npm:discordeno@18.0.1";
|
||||
import { Bot, Message } from "@discordeno";
|
||||
import { drop, help, requestWorker } from "./plugin.ts";
|
||||
import { logMessage } from "@root/logging.ts";
|
||||
import { defaultString } from "@root/defaultString.ts";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { requestJSON } from "@root/structures/apiRequest.ts";
|
||||
import { DiscordEmbed } from "npm:discordeno@18.0.1";
|
||||
import { DiscordEmbed } from "npm:discordeno@21.0.0";
|
||||
|
||||
type PostResponse = {
|
||||
id: number;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { Bot, Message, transformEmbed } from "npm:discordeno@18.0.1";
|
||||
import { defaultString } from "@root/defaultString.ts";
|
||||
import { Bot, DiscordEmbed, Message} from "@discordeno";
|
||||
import { logMessage } from "@root/logging.ts";
|
||||
import { getPosts } from "@root/plugins/yandere/api/api.ts";
|
||||
|
||||
@@ -7,10 +6,10 @@ export async function yandereMessageHandler(bot: Bot, message: Message) {
|
||||
const command = message.content.split(" ").slice(1).join(" ");
|
||||
const args = command.match(/(\[.+\])/g)
|
||||
if (command === "drop") {
|
||||
const embed = (await getPosts("[limit: 1]"))[0]
|
||||
const embed: DiscordEmbed | undefined = (await getPosts("[limit: 1]"))[0]
|
||||
if (embed === undefined) throw Error("undefined embed")
|
||||
bot.helpers.sendMessage(message.channelId, {
|
||||
embeds: [transformEmbed(bot, embed)]
|
||||
embeds: [embed]
|
||||
})
|
||||
} else if (command.startsWith("drop [") && command.endsWith("]")) {
|
||||
logMessage(message);
|
||||
@@ -18,7 +17,7 @@ export async function yandereMessageHandler(bot: Bot, message: Message) {
|
||||
const generatedEmbeds = await getPosts(args[0]);
|
||||
for (const embed of generatedEmbeds) {
|
||||
bot.helpers.sendMessage(message.channelId, {
|
||||
embeds: [transformEmbed(bot, embed)],
|
||||
embeds: [embed],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { DiscordEmbed, DiscordEmbedAuthor, DiscordEmbedField, DiscordEmbedImage } from "npm:discordeno@18.0.1";
|
||||
import { DiscordEmbed, DiscordEmbedAuthor, DiscordEmbedField, DiscordEmbedImage } from "npm:discordeno@21.0.0";
|
||||
|
||||
export type Field = {name: string, value: string}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user