YukiBot is a bot project based on discord.js
. Several features will be implemented for YukiBot such as restock tracking, currency converter, music player, mini-games etc.
-
Set up Discord Bot through Discord developer portal.
-
Create a
.env
file at the root directory.
YUKI_BOT_TOKEN=YOUR TOKEN
LOBBY_ID=YOUR THREAD ID FOR ITEM TRACKING
STOCK_ID=YOUR THREAD ID FOR 4090 TRACKING
SPOTIFY_TOKEN=YOUR SPOTIFY APPLICATION ID
SPOTIFY_SECRET=YOUR SPOTIFY APPLICATION SECRET
- Run node.js command to host the bot or use web host service like Heroku.
-
-
Bot will send an alert on any RTX 4090 available on Best Buy.
- I have already got one.
- Polling on every minute
-
You can modify it to any item from BestBuy
-
3080 Ti for demonstration as 4090s were rare to see.
-
-
-
Bot will send an alert on certain CNY-USD conversion rate
- Polling on every 6 hrs
-
User can use slash command to search a conversion rate between two currencies
-
-
- Use Spotify API to search a track by title and artist
- Song name is required, artist is optional.
- Use Spotify API to search a track by title and artist
-
- Randomly timeout a user for a random period of time.
- Like the one in MCU (Though it should be eliminate half of the population)
- Randomly timeout a user for a random period of time.
/src/utilities/4090_checker.js
On available item tracked, the bot will send a formatted message to the thread (STOCK_ID).
-
Interval: polling interval
-
Callback: user-defined function to handle tracked product.
-
product: JSON object
- name
- price
- model
- img
- url
-
To modify the items being tracked on Best Buy, modify the variable urls
in the checker
function. Note that this function only works with Best Buy links for now.
// code below set a tracker for RTX 4090 with 60s polling interval
// on available item tracked, the bot will send a message to a specified thread
const channel = client.channels.cache.get(process.env.STOCK_ID)
let message = {}
checker(60000, (product) => {
message = product
channel.send(
' :alarm_clock: *New Stock on Best Buy Now Available!*:alarm_clock:'
)
channel.send(
{ embeds: [formatter(message)] }
);
});
/src/utilities/currency_checker.js
On user-specified currency conversion rate found, the bot will send a formatted message to the thread (LOBBY_ID). By deafult, the currency checker will track the conversion rate between CNY and USD.
-
Interval: polling interval
-
Callback: user-defined function to handle conversion rate
- conversion rate:
- Float
- conversion rate:
To modify the tracked conversion rate, set the arguments in this line. r.start('USD', 'CNY')
//curr_1,curr_2,proxy,callback
//rate: conversion rate between curr_1 and curr_2
//Note: curr_1 and curr_2 should be in the form of 3 capital letter, e.g. USD, GBP, CNY, JPY.
checkRate(curr_1, curr_2, null, (err, rate) => {
if (err)
console.log(err);
else if (rate == null)
interaction.reply({ content: 'Not rate found, check with your input.' })
else {
interaction.reply({ content: 'Result:' })
channel.send(
`The rate from ${curr_1} to ${curr_2} is ${rate} at ${new Date()}`
)
}
})
/src/utilities/get_music_from_spotify.js
track_searcher
searches a track on user specified artist and song_name, returns a Spotify link. Since Spotify uses OAuth 2.0 for API authentication, a get_token
method is used to retrieve the access token from Spotify.
//track_searcher returns the link of the song
//token returns the access token
//Spotify clientID and clientSecret Required. (Specified .env file)
const music_player = Music_API_Controller
const token = await music_player.get_token()
const track = await music_player.track_searcher(token, song_name, artist_name)
- Unit testing
- Disable / Enable certain features by setting up config file
- Code Refactor
- Slash commands separately stored in files
- Use ChatGPT API to reply smartly
- Mini games implementation
- Host YukiBot on web service