Git Product home page Git Product logo

rocketspot / heroku-bot Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bng94/heroku-bot

0.0 0.0 0.0 341 KB

An discord bot that is hosted on heroku and is a generic bot for anyone to fork and use. Also please check out the gitbook link for further documentation if you want to use this bot!

Home Page: https://bng94.gitbook.io/heroku-bot/

License: MIT License

JavaScript 99.97% Procfile 0.03%

heroku-bot's Introduction

Heroku Discord Bot

A discord.js backup bot of my backup bot. Originally was planning to create one bot but ended up creating another bot then this one. This bot is hosted on heroku for free and as such will run 24/7 for 23 days a month.

Description

This is primarily a backup bot of a bot called "Doctor" on my server and will be planning to make this bot called "Master" in references to the BBC TV Show Doctor Who. This is a generic bot for everyone to download and use. As this is one of my first early JavaScript Projects I though it would be nice to share for those interested in creating their own discord.js bots. If there is an handful of people whom fork or give an input to this project, will expand and present more generic features that aren't used in this backup bot that may or is being used in my other bots.

Configuration

You need to install the following packages:

  • npm install discord.js@latest
  • npm install module-alias@latest
  • npm install dotenv@latest
  • npm install moment
  • npm install moment-duration-format
  • npm install ms

or if you forked the repository then just run:

  • npm install

Create an .env file for your Environment variables

โš  Warning: This .env file is a file that you MUST never be shared with anyone and never be uploaded to your public repository and/or you should use a .gitignore file so you don't accident upload the file to github!

  • TOKEN = your bot token
  • ownerID = your own discord user ID
  • serverLink = your own discord server invite link
  • serverID = your own discord server invite link

Usage

You can run the bot using command line with one of the two commands listed:

  • Node index.js
  • pm2 start index.js

Recommended to use pm2 start if you want the bot to run 24/7, and restart if it crashes or encounters a bug. Also able to restarts upon using the restart command

Creating Commands

Every command contains the following:

  • name - name of the command.
  • description - description of the command
  • aliases - for command aliases, If none define it as: aliases: [],
  • (OPTIONAL) guildOnly - set true if its an guild only command.
  • permission - the defined permission level to use the command.
    • check config.js file for more details
  • minArgs - defines the minimum number of arguments required for the command.
    • If no args: minArgs: 0
  • (OPTIONAL) maxArgs - define the maximum number of arguments required.
    • leave blank if unlimited arguments or is a sentence length answer
  • usage - define what the arguments should be if any. If none define it as: usage: ''
  • execute - the functionality and response of the command call.

Example:

module.exports = {
	name: 'ping',
	description: 'Ping Pong Command!',
	aliases: ['p'],
	guildOnly: true,
	permissions: 0,
	minArgs: 0, 
	usage: '',
	execute(message, args, client) {
		return message.channel.send('Pong.');
	},
};

Creating Slash Commands

You can create slash commands by adding these objects to your the command file that you want to change into a slash command.

Objects:

slash: true,
async interactionReply(interaction) {},

Example:

module.exports = {
	name: 'ping',
	description: 'Ping Pong Command!',
	aliases: ['p'],
	guildOnly: true,
	permissions: 0,
	minArgs: 0, 
	usage: '',
	slash: true,
	execute(message, args, client) {
		return message.channel.send('Pong.');
	},
	async interactionReply(interaction) {
		await interaction.reply({
			content: 'Pong!'
		});
	}
};

If you want to use slash command options then add this into your command file: slashOptions:

Example:

If the slash command requires you to mention someone then set this option

slash: true,
slashOptions: [{ 
    name: 'someone', 
    description: 'Mention Someone', 
    required: true, 
    type: 6 
}],
async interactionReply(interaction) {
	const { options } = interaction;
    const user = await options.getUser('someone');
	await interaction.reply({
		content: `Hello ${user.username}!`
	});
}

You can learn more by reading the Discord Dev Docs about Slash Commands.

Bugs / Support / Suggestions

If you find a problem with the bot, please file an issue.

Please also state how the issue can be reproduced and the expected and unexpected behavior of the bot. If any screenshots please feel free to show it, so the issue can be solved as quickly as possible.

Report an Issue

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.