Git Product home page Git Product logo

databot's Introduction

DataBot

Want to track the time your members spend on your Discord server? Then look no further. With this Discord bot, you can track the talking time and the sent messages with an included leveling system. To see the users stat's, the bot provides an interactive leaderboard, which you can sort by different aspects. Also, the bot provides many other features, to handle operations for your server: Giving roles via reactions, make polls, dynamic voicechannels, โ€ฆ With the unique subserver feature of the bot, there is no need to split up the server into many other smaller ones. Instead, create a subserver to create individual spaces for many parts of your community, so that there can exist shielded from others parts of your server.

Features

Leveling system

  • Track the users time in voice channel.
  • Track how many messages a user has sent.
  • Channels are configurable if they should track the voice time or messages.
  • Interactive leaderboard to view your level and stats.
  • Levelcards for individual users.

Polls

  • Create polls in the dm with the bot and have a live view of the polls look.
  • Open your poll on your server to enabled users to vote on a topic via reactions. All anonymous.
  • Publish the results of a poll.
  • Possablity to edit the poll if any mistakes have been made.

Tables

  • Create a table for users to get roles via reactions.
  • Configure the table in the configs and post it into a channel.
  • Update the table without any loss of reactions.

Subserver

  • Easily create private parts of your server with subservers.
  • Invite people to a subserver or create an invitecode.
  • Switch to a subserver by joining a gateway channel or with a bot command.

Other stuff

  • Make voice channel dynamically expand by simply adding '#1' on its name.
  • Get inspirational quotes from 'inspirobot.me'.
  • Many command tools to manage the bot.

Requirements

You need Python Version 3.6 or newer. The requirements must be installed via pip3 install -r requirements.txt.
That's it.

Installation

Run git clone https://github.com/PantomInach/DataBot.git in your installation folder or download the repository manually.

Create a bot

Create a Discord Application on the site https://discord.com/developers/applications. Make sure "Presence Intent", "Server Members Intent" and "Message Content Intent" are enabled in Privileged Gateway Intents under the Bot tab. Then copy the token to the specified space in the data/config.json file. More to the config file in Configuration. Also add your guild in the "server" space and your Discord ID in "owner". Now you need to invite the Bot to your guild. Use https://discord.com/oauth2/authorize?client_id=INSERT_CLIENT_ID_HERE&scope=bot&permissions=2416143440 after replacing "INSERT_CLIENT_ID_HERE" with your Bots client ID under the tab OAuth2. The bot is now created and invited to your server.

Configuration

Bot config

The main config file can be found here config in the directory data.

{
      "token": "Your token",
      "command_prefix": "+",
      "log": "False",
      "logchannel": "",
      "levelchannel": "",
      "owner": "",
      "textCooldown": "75",
      "privilege": {
            "Your ID": "2",
            "Lower rank ID": "1"
      },
      "guild": "Your guild ID",
      "serverVoiceBlacklist": [
            "0"
      ],
      "serverTextWhitelist": [
            "0"
      ],
      "roles": ["rolename1", "rolename2", "rolename3"],
      "rolesXPNeed": ["1", "10", "20"],
      "needForSubServer": ["rolename"]
}
  • token contains your token from the step Create a bot
  • command_prefix is the symbol, which the bot listens to. If the prefix is +, then you can invoke a command via +help for example.
  • log describes if the bot should track your users voice time and sent messages. Can be set with a command.
  • logchannel is a channel, in which the bot sends welcome and goodbye messages.
  • levelchannel is a channel for the leveling related stuff.
  • owner should contain your discord id.
  • textCooldown describes how long a new message of a user doesn't give him exp, when he already got exp from an earlier message.
  • privilege describes the bot intern permissions hierarchy.
    • Enter a discord id and then the level.
    • The higher the level the more permissions a user gets when interacting with the bot.
    • Level 1 are moderator and Level 2 are admins.
  • guild should contain the discord server id, on which the bot should run.
  • serverVoiceBlacklist contains all voice channel, where the user time should not be collected. Channel can be added via commands or by hand.
  • serverTextWhitelist contains all text channel, where the users send messages should be collected. Channel can be added via commands or by hand.
  • roles contains the roles, which the bot should give a user, when he reached a level specified in rolesXPNeed. The order of the roles is important.
  • needForSubServer contains any role a user needs to use subserver. Only one role is needed.

Command config

The command config is for specifying what command should work in which text channel or be invokable by which user with certain roles. The config file commandRights.json can be found in the directory data. An entry contains the following:

"command name":
  {
    "roles":[
      "roles which are required",
      "id or name"
    ],
    "channel":[
      "in which channel is the command invokable",
      "id or name"
    ]
  } 

databot's People

Contributors

pantominach avatar johnzoki avatar

Stargazers

 avatar  avatar

Watchers

 avatar

databot's Issues

[REFACTOR] Split up file into dedicated files

Some python files server more purposes than they should. Therefore, split up these files into separated files.

  • data/Jsonhandle.py
    • Here manipulating the config and managing user data is handled by a single python file.
    • Split theses up into configHandle.py and userHandle.py

Counter

  • Create help class and data structure
  • Implement commands

Uniform text commands

  • Come up with names and shortcuts for commands
  • Add command phrasing for bigger command groups

[BUG] Dynamic-Voice-Channel Bugs

  • When user is alone in channel and mutes or unmutes (Changes voice state) himself another channel is created.
  • When channels "xxxx 1" and "xxxx yyyy 1" exist, members joining "xxxx" will affect channels "xxxx yyyy"
  • Race condition when joining and leaving channels fast, which will result in a move operation without a target
  • Race condition when two people join numbered channel, resulting in two new empty channel

Unify "Note on dataprotection" and "Intrest Group" commands

Give roles per reaction command

The commands 'sendDPD' and 'sendGR' are to specific for one use-case and implement a part of this new commands function.
This new function can create a new message with reactions, which will give you role(s) specified in a config file. When removing the reaction multiple roles also can be removed.
Also it should be possible the add/remove further reactions and also edit the message itself.

Progress

  • Create config
    • Data pattern
    • Template config
  • Create commands
    • Posting
    • Edit/Update depending on config
    • Remove
    • List
  • Reactions
    • Give roles (Multiple roles should be supported)
    • Remove roles (Multiple roles should be supported)
  • Testing

Star of the week command

  • Create subroutine
    • Implement remove roll with timing possibilities
    • Implement give roll once with timing possibilities
    • Hook in subroutine into startup and shutdown
  • Add command to make a person "star of the week" when possible
  • Testing

Rigth checks of commands to discord predicate

Rewrite decorates not using the commands.check to use them when no alternative is already there.
Some checks have equivalent decorators, which will trigger another function when the check fails. Such function could be chained afterwards.

  • New hasAnyRole
  • Rewritten:
    • commandmod.py
    • commandmodserver.py
    • commandowner.py
    • commandpoll.py
    • commanduser.py

[REFACTOR] Update Bot Version

Currently discord.py version 1.7.3 is use while the current version is at >=2.0.0.

  • Update requirements.txt
  • Make code compatible with current version

Dynamic voice channel

Voice channels will be created, when no other of the same type is unoccupied.
Voice channels will be deleted, if it is no longer used and another one of the same type is unused.

Create guide

The guide should contain:

  1. How to start a bot
  2. How configure the bot
  3. All features
  4. All commands

datahandler better multi object support

Problem

Data can be lost when saving to file because of a race condition.
Especially when restarting the bot.

Fix:

Use the Singleton pattern

class SingletonClass(object):
  def __new__(cls):
    if not hasattr(cls, 'instance'):
      cls.instance = super(SingletonClass, cls).__new__(cls)
    return cls.instance

Refactor

  • Move folders into cogs and helping classes
  • Minimize and fix imports
  • helpfunc.py
    • Move specific functions into corresponding classes
    • Transform helpfunc to general purposes class
  • Cogs -> Extensions:
    • Reduce dependency on PASSED outside classes by making them static or creating them on the fly
    • Reprogram classes where one instance is passed to multiple objects to allow multiple instances of class
    • Make cogs -> Extensions
    • Program reload extensions
  • Use task.loop for subroutine
  • Move listeners from main.py into corresponding cog classes
  • Add better error message
  • Move logging of users into subroutine
  • Testing
    • Bot Mod Commands
    • Bot Owner Commands
    • Poll Commands
    • COO Commands
    • User Commands

Remove proprietary code

Proprietary Code

  1. Hard-coded roles/channel like 'rookie', 'etwasse', 'CEO', 'spam' ...
  2. Decorator of commands with hard-coded roles and/or channel

Solution

  1. Rewrite code fragments to not rely on these roles.
  2. Out source roles and channel to config-file depending on commands.

Progress

  • (1)
  • (2)

Uniform bot commands with subcommands

Instead of calling another function (#2) use subcommands implemented via groups.
Example from commanduser.py:

@commands.group(name='user')
async def userCommandsInterpretor(self, ctx):
    if ctx.invoked_subcommand is None:
        await ctx.send("No subcommand is called")
    else:
        await ctx.send("Invoking subcommand")

@userCommandsInterpretor.command(name='test')
async def secondCommand(self, ctx, *inputs):
    await ctx.send(f"Second command {inputs}")

The command test can be invoked via user test.

Changed for cogs/:

  • commandmods.py
  • commandpoll.py
  • commanduser.py

Replace roles for subserver

Following roles will be removed to allow better functionality for subserver #1.

  1. rookie
  2. etwasse

These roles where roles of a old design for subserver.

Subserver

  • Generate subserver command
    • Create new subserver roll
    • Create new text and voice channel with right permissions
  • Subserver commands
    • Invite to subserver
    • Join subserver per command
      • Create invite code
      • Redeem invite code
    • Leave permanently subserver
    • Change subserver
    • Leave subserver
  • Update channel-name depending on members
  • Implement Subway channel functions

Changes afterwards:

  • Remove "Sub-" from Subserver Gateway channel
  • Remove "Main Server"
  • Add option for roles, which is needed to use a subserver.

Start scripts

Create start scripts, which check if all requirements are meet, for different platforms.

  • Linux
  • Windows

Polls not working

Reactions of polls will vote for the wrong option and add unnecessary reactions with no function.

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.