Skip to content

tinspham209/discord-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mini Project: Discord Moderation & Music BOT

Date: 25 - Aug - 2020

Tech-Stack

  • NodeJS v14.7
  • Discord.js v12
  • dotenv : store variable process.env.variable_name
  • ytdl-core : Convert youtube link to audio
  • opusscript
  • ffmpeg-static : Need FFMPEG For Any Music Bot To Work
  • moment : time format
  • ms : convert string seconds to number: Input: 100s > numbers

Screenshot

Functions

MODERATION BOT:

  1. Kick : $kick @[user_name] [reason-reason]
  • $kick @Rafen spamming
  1. Ban : $ban @[user_name] [reason-reason]
  • $ban @Rafen spamming
  1. Soft ban : $softban @[user_name] [reason-reason] - default: 1 day
  • $softban @Rafen spamming
  1. Temp ban: $tempban @[user_name] [reason-reason] [seconds]s
  • $tempban @Rafen Breaking-rule 200s
  1. Mute : $mute @[user_name] [reason-reason] [seconds]s
  • $mute @Rafen spamming 100s
  1. UnMute: $unmute @[user_name] [reason-reason]
  • $unmute @Rafen ccc
  1. Reaction to set Role:
  • Reaction 🍉 icon to add Verified role
  1. Send text in bot-command channel, BOT send announcements to specify channel: $announce [text]
  • $announce Hello everybody

MUSIC BOT:

  1. Play: $play [youtube_url]
  1. Add music to queue: $play [youtube_url]
  1. Stop: $stop
  2. Skip: $skip
  3. Pause: $pause
  4. Resume: $resume
  5. change Volume : $volume [1-5] - default: 5
  • $volume 3
  1. Now Playing: $nowplaying
  2. check song queue: $queue

Plan Of Action

  • Project Setup
  • Creating Discord Application
  • Adding the Bot to our Discord Server
  • Logging the bot In Discord Server
  • Basic Events
  • Ready Event
  • Message Events
  • Bot Responses
  • Basic Chat Commands
  • Kick Command
  • Ban Command
  • Message Reactions & Reaction Roles
  • Announce command - Webhooks
  • Play command
  • Stop command
  • Create Queue system
  • Add song to queue
  • Skip command
  • Pause command
  • Resume command
  • change Volume command
  • NowPlaying command
  • check song queue command
  • Refactor
    • Kick with new logic
    • Ban with new logic
  • Soft Ban command
  • Mute command
  • UnMute command
  • Temp Ban command

After this project

Next Steps:

  • Music is playing but response too longgggg 😂
  • Add youtube search function
  • Add/Remove Role
  • Create/Delete Role
  • Create/Delete Channel
  • Refactor code by split specify function in specify folder

Directory Structure

.
├── package.json
├── package-lock.json
├── README.md
├── .env
└── src
    └── bot.js

Set up

  1. Clone repo to your computer:
git clone https://github.com/tinspham209/discord-bot.git
  1. Install dependencies.
npm install
  1. Adding the Bot to discord server
  1. Update variable in .env
// .env
DISCORDJS_BOT_TOKEN=
WEBHOOK_ID=
WEBHOOK_TOKEN=
REACTION_MESSAGE_ID=
ROLE_NAME=
ROLE_ID=
ROLE_MUTE_ID=
  • DISCORDJS_BOT_TOKEN:
  • Setting Webhooks in specify channel that you want BOT send announcements
  • REACTION_MESSAGE_ID : ID of comment that you want to set function reaction to set role
  • ROLE_NAME = icon that you want user react to set Role - example: :watermelon:
  • ROLE_ID = ID of roles that you want to set in server setting > roles
  • ROLE_MUTE_ID : Role ID that is already mute in server setting > roles
  1. If you want to add more reaction roles. You need to update code at src/bot.js in function messageReactionAdd &messageReactionRemove
  • Add new variable in .env. Example: ROLE_NAME_2 & ROLE_ID_2
  • Add more case at switch case on each functions
  1. Run in Production
npm start
  1. Or run in development: nodemon
npm run dev