Skip to content

Saizuo/xtrike-bot

 
 

Repository files navigation

Xtrike Bot

A multi-purpose Discord bot written in Discord.js that does all sorts of bot stuff.

Status License JavaScript Style Guide Current Version

Features

Search for text in images!

Can't find that one image your friend sent that got buried by a day's worth of messages? Well, you can now search for them! Powered by OCRSpace and Fuse.js. (Enter ;image for more info.)

Extract the raw video from external links!

It's a real inconvenience when you need to open links just to watch epic fails or low quality memes. So now, the bot will automatically extract and send the video whenever someone sends a link! Powered by youtube-dl.1

And more in the future!

Hang tight.

Add the bot to your server

The invite link will be available once the bot gets out of beta.

Versions

0.3.1

New commands, new year bug fixes and updated discord.js to v13.5.1

Breaking changes

  • updated discord.js to v13.5.1
  • moved the SendMsg class to its own folder
  • new config entry for Oxford Dictionaries API

Other stuff

  • fixed extractVids autoresponse not working
  • updated the user command to include the presence status and server timeout
  • added the server command to get all available info on the current server
  • forgot to remove the isBeta status on the image command, command should work now
  • added the define command which gives word definitions (powered by Oxford Dictionaries)
  • recategorized some commands

You can see past changelogs in the CHANGELOG.md file.

Endpoints

You can either use GET or POST.

Endpoint url for Xtrike Bot: https://xtrike-bot.xyr11.repl.co

Endpoint Description Returns
/stats Get all bot statistics Object
/stats/keys Get the different statistics keys Array
/stats/commandName
/stats/key
Get the individual values of the given command name or property String

Sample code

Check if bot is up

const isUp = await fetch('https://xtrike-bot.xyr11.repl.co').then(res => res.text()).catch(console.error)
console.log('The bot is up:', !!isUp)

Get all statistics

const stats = await fetch('http://localhost:3000/stats').then(res => res.json()).catch(console.error)
console.log(stats)

Develop

Prerequisites

Configure repository

If you're using Replit, click: Run on Replit.

If not, then clone the repository via Git by opening your console and entering the following commands:

cd "C:/path/of/repo/folder"
git clone https://github.com/xyr11/xtrike-bot.git && cd xtrike-bot
npm i

Set up the bot account

On https://discord.com/developers/applications, click "New Application". Add your application name and press "Create" to create a new application. You can set your bot description in this page.

After that, go to the "Bot" tab. Click the "Add Bot" button and press the confirmation button. After that, enable all privileged intents in the "Privileged Gateway Intents" tab so that the bot can properly fetch data. You can also set a custom bot name and bot avatar in this page.

Add config variables

After that, rename the example-config.js file to config.js and replace the values of all the required variables to configure your bot. There are comments to help you out.

Run repository

If you're on Replit, press the big "Run" button.

If not, open your console and enter the following command to start your bot:

npm start

If no errors are encountered, you should be able to see the following message:

Ready as <Bot username>! 🤖 (<Date and time>)

Customizing the bot

You can customize the bot by replacing the default value of the optional variables on your config.js file.

Documentation
Variable Default value Description
botPrefix ";" You can use more than 1 character here and any character except a space. This will have no effect if user used slash commands (if slash commands are deployed).
botName "Xtrike Bot" Name of the bot.
botDescription "Xtrike Bot is a multi-purpose bot." Description of the bot. It can have multiple lines and Discord embed formatting.
botColor "#E3E5E8" Used for the color of embeds sent by the bot. Use a hex color value like "#RRGGBB".
infoFields Check file Info fields. This is an array of fields that will be shown in the ;info embed. Fields needs a name and value property, and they support Discord embed formatting too.
botSupport N/A User IDs of people that has the 'Bot Support' role. Right now they don't do anything but in the future this may change.
errorLogging N/A Channel ID for error logging. All errors caught will be send in the specified channel. Note that the error message may include personal info such as folder names.
status "online" Presence status: online/idle/dnd/invisible.
actType "playing" Activity type: playing/watching/listening/competing.
actName ";info" Activity name, the text that will show up in "Playing..."
isMobile false If you want to set the status to "Online in mobile device". If true, this will ignore actType.

Updating the cloned repository (for Git)

To update the code, enter:

git fetch --all && git reset --hard origin/main && npm i

NOTE: This will overwrite all files that you have modified, so you will lose them. If you want it to be saved permanently then I suggest forking the repository instead and doing git merge with your own version every time there is a new update.

Roadmap

To-do's for future versions
  • Command that temporarily disables other commands
  • Use a unified class for commands
  • Get the total number of messages the bot has sent
  • Endpoint will cache results every 30 seconds instead of requesting data every time someone visits
  • More probably...

License

The code is licensed under MIT License.

Contact

Join the official support and dev Discord server!

Credits

Huge thank you to Worn Off Keys's discord.js playlist, to the An Idiot's Guide guide, and finally to Discord.js Guide, especially with the new and spicy v13 stuff. A huge thank also to Replit for the bot hosting.

Footnotes

  1. Supported sites: Facebook, Twitter, Tiktok. DISCLAIMER: The bot only temporarily saves the videos generated from this feature so that it can be send on Discord. You are entirely responsible for any and all content generated from these links.

About

A multi-purpose Discord bot.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%