mirror of
https://github.com/LukeHagar/toyo-discord-bot.git
synced 2025-12-06 04:21:49 +00:00
package update+more
npm update attempt to use discord.js to simply create a client and send messages
This commit is contained in:
5039
toyobot/package-lock.json
generated
5039
toyobot/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "awwbot",
|
||||
"version": "1.0.0",
|
||||
"description": "A simple discord bot that uses intents to post pictures from r/aww",
|
||||
"name": "toyobot",
|
||||
"version": "1.2.3",
|
||||
"description": "A discord bot designed for The Optimistic Yack Order (TOYO).",
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"main": "src/server.js",
|
||||
@@ -15,12 +15,13 @@
|
||||
"publish": "wrangler deploy"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "Justin Beckwith <justin.beckwith@gmail.com>",
|
||||
"license": "MIT",
|
||||
"author": "Chris Holt <holtcm01@gmail.com>",
|
||||
"license": "AGPL-3.0-only",
|
||||
"dependencies": {
|
||||
"@discordjs/rest": "^2.4.3",
|
||||
"axios": "^1.8.4",
|
||||
"discord-interactions": "^4.0.0",
|
||||
"discord.js": "^14.18.0",
|
||||
"itty-router": "^5.0.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -15,7 +15,26 @@ import { Routes } from 'discord-api-types/v10';
|
||||
|
||||
const MAX_LENGTH = 1950; // Discord's maximum message length is 2000 characters, but we leave some space for formatting
|
||||
|
||||
function getDiscordClient(token){
|
||||
const { Client, Events, GatewayIntentBits } = require('discord.js');
|
||||
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
|
||||
client.once(Events.ClientReady, readyClient => {
|
||||
console.log(`Ready! Logged in as ${readyClient.user.tag}`);
|
||||
});
|
||||
client.login(token);
|
||||
|
||||
return client;
|
||||
}
|
||||
|
||||
async function respondToInteraction(env, interaction) {
|
||||
const client = getDiscordClient(env.DISCORD_TOKEN);
|
||||
const channel = client.channels.cache.get(interaction.channel_id);
|
||||
if (!channel) {
|
||||
console.error('Channel not found');
|
||||
return;
|
||||
}
|
||||
channel.send('discord.js test seems to work?');
|
||||
|
||||
const rest = new REST({ version: '10' }).setToken(env.DISCORD_TOKEN); // Ensure your bot token is set in the environment
|
||||
const url = Routes.interactionCallback(interaction.id, interaction.token);
|
||||
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
# https://developers.cloudflare.com/workers/wrangler/configuration/
|
||||
name = "toyobot"
|
||||
main = "./src/server.js"
|
||||
compatibility_date = "2023-05-18"
|
||||
compatibility_date = "2024-09-23"
|
||||
compatibility_flags = ["nodejs_compat"]
|
||||
|
||||
[observability]
|
||||
enabled = true
|
||||
|
||||
Reference in New Issue
Block a user