Giter Site home page Giter Site logo

harrycgx / scrimbot Goto Github PK

View Code? Open in Web Editor NEW

This project forked from schwaindustries/scrimbot

0.0 0.0 0.0 1.93 MB

A Discord bot for organizing Valorant custom games.

Home Page: https://scrimbot.schwa.tech

License: MIT License

JavaScript 100.00%

scrimbot's Introduction

ScrimBot

Add ScrimBot to server

ScrimBot Support

ScrimBot is Discord bot meant to allow for the easy creation of VALORANT custom matches.

You tell the bot how many players per team, when the match will be and what map you would like and the bot will do the rest. Interested players can then react to the message to join a team, and once the match is complete you can add the final score and the match will be recorded for posterity.

Players can also tell the bot their competitive rank and it will automatically assign them a role in all servers that they share with the bot.

ScrimBot is based off Mountainz.

Running this yourself

Deploy

Requirements:

  1. MongoDB instance (https://www.mongodb.com/cloud/atlas)
  2. Discord Bot Token (https://discord.com/developers/applications)
  3. Node.js Version 12 or higher (https://nodejs.org/en/download/)

Instructions:

ScrimBot configuration is handled through environment variables. These can be set inside your terminal, on your hosting platform, or using a file named .env in the project directory.

Here's a helpful guide on how to set them up for your platform: https://www.twilio.com/blog/2017/01/how-to-set-environment-variables.html

For the purposes of this guide, we'll be using a .env file, which is the easiest option.


  1. Clone the repository
$ git clone https://github.com/SchwaIndustries/ScrimBot.git
$ cd ScrimBot
  1. Create a file named .env in the root directory of the bot with the following contents:
TOKEN=<discord bot token>
TIME_ZONE=<(OPTIONAL) desired time zone (https://en.wikipedia.org/wiki/List_of_tz_database_time_zones), default is America/Los_Angeles>
PREFIX=<(OPTIONAL) desired bot prefix, default is v!>
MONGO_URI=<mongo uri>
  1. Replace <discord bot token> with your bot token

  2. Replace <mongo uri> with your MongoDB connection string

  3. Run npm install to install bot dependencies

  4. Run npm start and the bot should be online!

  5. You can add yourself as a bot admin by modifying your user entry in the database. In the users collection, find your user ID and add a field named admin with the boolean value of true. This will allow you to access certain bot admin commands.

Migration from Cloud Firestore:

If you had previously ran an instance of ScrimBot before it migrated to MongoDB, this section will help you transition your data over.

  1. Use an existing Google Cloud service account or create a service account key for your project (https://cloud.google.com/iam/docs/creating-managing-service-account-keys#creating_service_account_keys)

  2. Install node-firestore-import-export

npm install -g node-firestore-import-export
  1. Export your data to a file
firestore-export --accountCredentials <service account key file> --backupFile firestore-dump.json --prettyPrint
  1. Execute the following Node script to clean up the data
const fs = require('fs')
const original = JSON.parse(fs.readFileSync('./firestore-dump.json', { encoding: 'utf8' }))

const converted = {
  guilds: [],
  matches: [],
  users: []
}

// parse guilds
for (const guildID in original.__collections__.guilds) {
  const guild = original.__collections__.guilds[guildID]

  delete guild.__collections__

  // some guilds only have linked matches and have never run v!server add
  if (guild.name) {
    converted.guilds.push({
      _id: guildID,
      ...guild
    })
  }
}

// parse matches
for (const matchID in original.__collections__.matches) {
  const match = original.__collections__.matches[matchID]

  delete match.__collections__
  match.timestamp = new Date(parseInt(match.timestamp.value._seconds + '' + match.timestamp.value._nanoseconds.toString().slice(0, 3)))
  if (match.date) match.date = new Date(parseInt(match.date.value._seconds + '000'))
  match.players.a = match.players.a.map(user => {
    if (!user.value) console.log(matchID)
    return user.value.split('/').pop()
  })
  match.players.b = match.players.b.map(user => {
    return user.value.split('/').pop()
  })
  if (match.spectators) {
    match.spectators = match.spectators.map(user => {
      return user.value.split('/').pop()
    })
  }

  converted.matches.push({
    _id: matchID,
    ...match
  })
}

// parse users
for (const userID in original.__collections__.users) {
  const user = original.__collections__.users[userID]

  delete user.__collections__
  user.timestamp = new Date(parseInt(user.timestamp.value._seconds + '' + user.timestamp.value._nanoseconds.toString().slice(0, 3)))
  user.matches = user.matches.map(match => {
    return match.value.split('/').pop()
  })

  converted.users.push({
    _id: userID,
    ...user
  })
}

fs.writeFileSync('./converted-guilds.json', JSON.stringify(converted.guilds))
fs.writeFileSync('./converted-matches.json', JSON.stringify(converted.matches))
fs.writeFileSync('./converted-users.json', JSON.stringify(converted.users))
  1. Log into your MongoDB instance and import your data!

Let us know if you run into any issues migrating your data.

scrimbot's People

Contributors

kalissaac avatar dependabot[bot] avatar thecodeweaver avatar

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.