ytausch / serverless-discord-bot Goto Github PK
View Code? Open in Web Editor NEWA serverless Discord Bot template built for AWS Lambda based on Discord's slash commands and the slash-create library.
License: MIT License
A serverless Discord Bot template built for AWS Lambda based on Discord's slash commands and the slash-create library.
License: MIT License
I've noticed that sam deploy
hangs in this specific situation:
I do an unsuccessful deploy which has to be rolled back due to an error, which then puts the stack in state UPDATE_ROLLBACK_COMPLETE
.
When I subsequently correct the error and call sam deploy
again it hangs in this stage:
This is what I see in the stack:
Even deleting the stack becomes impossible after this because there's no way to stop the custom resource (at least I didn't find one), so I just have to wait for it to time out and delete it.
Any clue on how to fix this?
Hi thanks for this repo I'm trying to get it working.
After I've run sam deploy --guided
, I can see the new command /hello
shows up in my Discord with the correct description. When I hit enter it just stucks at "Sending Command...".
I can see the request actually gets sent to Lambda and the CloudWatch log shows:
Running command: hello (1049129300865065071, guild 740092388915019796)
Do you know why is it just stuck at "Sending Command..."?
Thanks!
I'm attempting a very basic Redis integration in the file getBeastCommand.js. I replaced the original helloCommand.js file with it. The original hello deployment worked great, but when I changed the file to this and renamed it, the deployment hung on the step where it creates the 'Custom:CreateCommandsInvoker' resource, pictured here:
When I abort, it leaves me with an incomplete set of resources that interfere with further deployments, so I have to keep deleting them manually in all the different AWS services in order to try again, but it keeps failing at the same step. What am I doing wrong here?
const {SlashCommand, CommandOptionType} = require('slash-create');
const {createClient} = require('redis')
const host = 'MY_CLOUD_HOST'
const port = PORT_NUMBER
const username = 'MY_USERNAME'
const password = 'MY_DB_PASSWORD'
const client = createClient({
url: `redis://${username}:${password}@${host}:${port}`
})
module.exports = class GetBeastCommand extends SlashCommand {
constructor(creator) {
super(creator, {
name: 'get_beast',
description: 'Grab a beast!',
guildIDs: ['1054498243100295170'],
options: [
{
name: 'name',
description: 'The name of the beast you want to get.',
type: CommandOptionType.STRING
}
]
});
this.filePath = __filename;
}
async run(ctx) {
let name = ctx.options.name;
const dbReply = await client.sendCommand('JSON.GET', 'beasts', '$.beasts')
const beastList = JSON.parse(dbReply.value()?.valueOf())[0]
const beast = beastList.map((beast)=>{
if(beast['Name']==name){
console.log('Found a match!')
return beast
}
})[0]
if(beast){
ctx.send(`Here is the data for ${name}`, {
embeds: [
{
title: beast['Name'],
fields: [
{name: 'Description', value: beast['Description']},
{name: 'Rarity', value: beast['Rarity']},
{name: 'Biome', value: beast['Biome']},
{name: 'HP', value: beast['HP'].toString()},
{name: 'DEF', value: beast['DEF'].toString()},
{name: 'SPD', value: beast['SPD'].toString()},
{name: 'Ability', value: beast['Ability']['Name']},
{name: 'Ability Power', value: beast['Ability']['Power'].toString()}
],
image: {
url: beast['Image'],
height: 200,
width: 200
}
}
]
})
} else return "Sorry, I couldn't find that beast."
}
};
See #33.
I'm trying to deploy initially and am trying to get helloCommand to work. I've placed all 3 secrets to /dev/serverless_discord_bot/discord
, installed command_layer/nodejs
packages, built then deployed. Also used my guildID in guildIDs string[] in the command file.
Slash commands aren't being created. The /event interaction endpoint is valid and verified but I can't see any slash commands in my server/guild. For OAuth I've selected bot
and application.commands
as scopes.
Application Commands permission enabled for everyone and bot roles:
Integration settings for bot in my server:
Permissions:
Interestingly, if I tried to do a slash command in a direct message, I can see there are commands associated with the bot in the UI but I don't have permissions to see them:
As oppose to in my server, where I do have the permissions but it shows there app has no commands.
After running sam build
and then sam deploy --guided
my stack creation gets stuck in CREATE_IN_PROGRESS.
In the stack resources everything succeeds to create, except CreateCommandsInvoker, which is stuck. I have no idea how to debug this, any suggestions?
Edit:
Upon closer inspection figured that the lambda CreateCommands isn't finding the slash-create
dependency but still haven't managed to solve it. Here's what I see in CloudWatch:
{
"errorType": "Runtime.ImportModuleError",
"errorMessage": "Error: Cannot find module 'slash-create'\nRequire stack:\n- /var/task/index.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js",
"stack": [
"Runtime.ImportModuleError: Error: Cannot find module 'slash-create'",
"Require stack:",
"- /var/task/index.js",
"- /var/runtime/UserFunction.js",
"- /var/runtime/index.js",
" at _loadUserApp (/var/runtime/UserFunction.js:100:13)",
" at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)",
" at Object.<anonymous> (/var/runtime/index.js:43:30)",
" at Module._compile (internal/modules/cjs/loader.js:1072:14)",
" at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)",
" at Module.load (internal/modules/cjs/loader.js:937:32)",
" at Function.Module._load (internal/modules/cjs/loader.js:778:12)",
" at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)",
" at internal/main/run_main_module.js:17:47"
]
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.