Skip to content

RizkyRajitha/appwritediscorddemo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Discord crypto price alert bot powered by Appwrite

This Appwrite function will send scheduled crypto price alerts to a discord channel
using the appwrite functions feature.

discord

Appwrite function overview

Appwrite Functions allow you to extend and customize your Appwrite server functionality by executing your custom code. Appwrite can execute your custom code in response to any Appwrite system event like account creation, user login, or document update. You can also schedule your functions to run according to a CRON schedule or start them manually by triggering your function from an HTTP endpoint using the Appwrite client or server APIs. (Appwrite docs)

This appwrite function uses CoinMarketCap API to get crypto prices and send embedded messages to the discord channel. discord.js npm package to interact with discord API. This Function uses nodejs 18 runtime and is triggered on scheduled cron every 10 minutes. API keys and tokens are set in appwrite function variables for security.

Setup

Set up appwrite on your server. i won't go into detail about this step since it is out of the scope of this demo.

for this function node version should be higher than 16.9 since that is the supported version by the discord.js npm package. so i modified docker-compose .env variables to add node 18 runtime

docker-compose.yml and .env files are available in appwrite directory.

appwrite function code is available in bot directory.

Install appwrite cli

npm install -g appwrite-cli

appwritecli

Login to appwrite cli and init project

appwrite login

appwrite init project

clilogin

Create a function using appwrite cli

appwrite init function

functioncreate

Deploy function

appwrite functions createDeployment --functionId=63412e0ba31cca95593c --activate=true --entrypoint="discord-bot.js" --code="./cryptobotcode"

make sure you have the code in the specified directory. for node js dont include node_modules folder since appwrite will automatically do it for you in the function build process.

createdeployment

now login to appwrite dashboard dashbaordfunction

add function variables

varibles

update function schedule in function settings. here */10 * * * * is used to trigger function every 10 minutes

cron

view function logs

functionlogs

About

Discord crypto price alert bot Powered by Appwrite

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published