Coder Social home page Coder Social logo

mikhad / nfr-bot Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 0.0 2.85 MB

A utility discord bot for displaying information from the Wynncraft API, with some additional fun and QoL commands.

JavaScript 2.42% TypeScript 97.58%
nodejs discord discordjs bot wynncraft discord-bot typescript

nfr-bot's Introduction

logo

Proficiencies

TypeScript JavaScript Svelte title="DiscordJS Node HTML HTML CSS CSS SCSS Python Java AutoHotkey git GitHub Figma Visual Studio Code GitHub Actions

Currently learning

Dart + Flutter
Firebase
Docker

Things I want to learn

Go
Rust
Obsidian Plugin development
VSCode Extension development

nfr-bot's People

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

nfr-bot's Issues

Add category to commands

When commands are being read in from file on start add category property dynamically based on which folder the command was in.

Rename guild category to wynn

The guild category contains commands such as stats which is guild agnostic.
The category was originally called guild because it only contained the absences command for NFR, but that too has since become guild agnostic.

/playtimeInGuild command

Slash command with sub commands

Sub command Permission Parameters Functionality
track ADMINISTRATOR guild start or stop tracking the play time in guild for guild. Only one guild may be tracked per discord server. When run show ephemeral pop up letting them know that, asking them to confirm and telling them whether they are starting or stopping tracking
player anyone player-name show player-names playtime in guild since the date tracking started
list ADMINISTRATOR show a list of players play-times in guild since tracking started, and when the stats were last updated (update once or twice a day)

Store playtime data in database per guild, not server so as not to duplicate values if multiple servers track the same guild (for some reason)

  • database interaction
  • track
  • player
  • list

/treasury command

Slash command with sub commands.

  • Per server treasury.
Sub Command Parameters Functionality
start balance, channel Start keeping track of the guild treasury. Channel is an optional parameter, if specified treasury commands can only be run in that channel.
deposit amount Amount deposited. Stored in database with user who deposited it.
withdraw amount, reason Reason is required. Stored in db with user, and reason.
log entries, user Show withdrawal log, (with total balance at the top) optional parameter to show number of entries you'd like to see, optional parameter to see entries from a specific user
balance Show the current guild bank balance
channel channel set or unset the channel used for treasury commands
  • start
  • deposit
  • withdraw
  • log
  • balance
  • channel

Database & Cache

Database

  • Design database layout
  • Integrate database with API classes - No functions should interact directly with the database

Cache

  • Create cache class
  • Integrate cache with API classes

chat bot functionality

Add chatbot functionality when the bot is @mentioned
(source)[https://towardsdatascience.com/how-to-build-your-own-ai-chatbot-on-discord-c6b3468189f4]

seperate utils.js

Seperate the functions in utils.js into smaller, more relevant and cohesive categories of utility functions.
Files for:

  • Formatting and or Embeds
  • Image Processing
  • Fetching from database
  • Fetching from apis

Multiple page support for embeds

Ability to easily add multiple pages to embeds, reachable via button interactions (buttons might need to expire after a given amount of time).

Dev command features

Simplify dev command system by making a dev commands folder, rather than a file name prefix. Any special treatment of dev commands in other commands like reload and help that I still wish to keep will need to be based on the folder being dev instead of the dev property being true.

  • Command to see which servers bot has been added to
  • Make dev command feedback ephemeral

3.0.0 changelog from before git

The following changes are what I recorded before I started properly using git and GitHub to track my changes:

23/07/2021

  • Changed highlight color of changelog embed to default color
  • Changed stats command second paramter from plaintext to formatted. It now needs to be true instead of false to show formatted
    24/07/2021
  • Made multi word arguments into single words with underscores min days -> min_days
  • Removed commas sperating optional parameters in command help as they were misleading
  • Made command parameters a different font in help commands
  • Specified that <> is a required parameter and [] are optional parameters in the base help command
    25/07/2021
  • Changed cooldown to only be shown in help commands if it is greater than zero
  • Updated command template to include a dev boolean
  • Modified help command to exclude dev commands from the help list
  • Created new reload dev command
  • Fixed \help for an unknown command saying \undefined is not a valid command
  • Added createSuccessEmbed to utility and replaced instances of success embeds being made from scratch with this command
    28/07/2021
  • Made absences command faster by generating banner image and fetching player data in parallel
    29/07/2021
  • Added abs as an alias for absences because people can't spell
    30/07/2021
  • Updated to discord.js version 13 (dev release)
  • Fixed embeds for v13
    04/08/2021
  • Modified command handler to accept slash commands
  • Modified reload command to work with slash commands (but not for the execute parameter yet)
  • Added channel partial to enable recieving of dms in v13
  • Added a flip slash command
  • Added new custom permission DEV that only accepts me
    05/08/2021
  • Fixed crash error if fetchPlayerFace returns null in stats command
  • Created prefix: guild name reference map
    06/08/2021
  • Updated to discord.js version 13 full release
  • Changed to semver versioning system instead of my own bespoke system
  • Added repository, keywords and private keys to package.json
  • Moved all items from to do.md to notion board and deleted it

Make create embed functions into classes that extend MessageEmbed

  • Extend MessageEmbed
  • Constructor with parameters like title, description, color
  • Built in multi page functionality reachable via button interactions, with functions to create additional pages (may need to expire after a length of time)
  • Choose now embed colors, the old new ones look shit
  • support non first page having multiple internal pages
  • Think about having next buttons for internal pages on a separate action row
  • Try having the buttons for the sub pages of sub pages on a separate row (/guild command ranks โ†’ recruit, recruiter, captain, strategist, chief)
  • If next buttons for internal pages are on a different row disable the button for the current page instead of hiding.
  • Always keep the same bar of buttons (with different ones disabled) and put the row for the sub pages of sub pages below, with next buttons for internal pages at the bottom.
  • Use buttons for the pages of the absences command as a demo

Console control

Add the ability to message a given channel in a given server with a given message from the server console.

website

Learn express and make a dynamic website (on the same host?) to reflect some of the data about the bot, commands, servers etc. Invite link and other info from the README.
Idea

Panel like that of tickettool.xyz which will allow you to log in via discord, select a server you are admin of and contains the bot and configure the default parameters of commands that have them, and modify the settings of complex commands like trackterritores, as well as set up and create polls and send them to a channel/ store them.

Add /lore command

Add an NFR server specific /lore command based of this bot to send an embed book of the pages of the nfr lore book.

Implement cooldowns for slash commands

  • Implement cool-downs in slash command handler (use same map as regular commands)
  • Display ephemeral message to user if a command is on cool-down and they attempt to use it, with how long the cool-down is and how long they have left to go.

Guild prefix to name hashmap

  • If someone inputs a name that is 3/4 letters that is not in the api, check the hashmap
  • Cache the prefixes of the 100 guilds on the leader-board in memory
  • Write function to update guild prefix lookup table. Last entry was Admiral, the 11979th guild

/trackTerritories command

Slash command with sub commands. To avoid extra set up run when you hold all the territories you want to track.

Sub Command Parameters Functionality
track guild Open a thread with the set up editor
ping role role is an optional parameter telling the bot which role to ping if a territory is taken, leave blank for no ping
channel channel The channel to send territory alerts to
  • track

  • ping

  • channel

  • Set up editor in new thread where messages from anyone other than command user are ignored, with ephemeral pointing to thread. Options include ping, channel, territories, alert for terrs being attacked (won't always happen for ter being attacked by nature of how often updates happen).

  • Divide territories up based on rough area, so gavel, rol, ocean, corkus, wynn, se.

  • Give user an embed listing all terrs currently owned by guild, along with a map.
    Have recommendation to have a map of wynn open while doing this, with links to different wynn maps like official, wynndata, avacia etc.

  • Store settings for tracked guild in database on a per server basis

Buttons for confirm, add, remove and add & remove.

  • Remove:
    Give user a drop-down of all currently owned terrs and ask them to check all that you don't want to track.

  • Add:
    Give user a drop down of the rough areas and ask them to select which areas they want to add territories in, then give them a drop down or multiple drop downs to select which territories to track additionally.

  • Add & remove:
    Give add, then give remove.

convert all commands to slash commands

  • flip
  • roll
  • choose
  • absences
  • stats
  • changelog
  • purge
  • Upgrade reload command to support live reloading of slash commands

EDIT: Moved help command for slash commands to a separate issue.

Add ability to set commands to be server specific

A servers property in the command with an array of server IDs as its value. During the command parsing step the code for these commands will be added to slash commands but they will only be registered to the given servers.

  • Add server property to command
  • Account for server property in command parsing
  • Register server specific commands to their specific server(s)

API class

  • Validate user input like guild and player names based on criteria for guild name and mojang player names.

WynnAPI class that extends API class

  • Built in rate limiting to not exceed 1200 calls every 20 mins (track calls per minute in queue, with property for total calls in the last 20 mins)
  • All calls to wynncraft api go through this class
  • Check cache then API
    .
  • MojangAPI class that extends API class

/vote command

Utility slash command with sub commands, with different perms for different sub commands. Take a look at how DYNO implements its /vote command.

# Sub Command Permission Parameters Functionality
1 Channel ADMINISTRATOR #channel Set a channel in which all (non bot) messages will receive ๐Ÿ‘ and ๐Ÿ‘Ž reactions. Do it again to disable
2 On everyone message-text Add ๐Ÿ‘ and ๐Ÿ‘Ž to this message, which will contain message-text
3 Message ADMINISTRATOR channel id, message id Add ๐Ÿ‘ and ๐Ÿ‘Ž to a message
4 Builder ADMINISTRATOR Create a thread where the vote set up will be done & link it in an ephemeral. All messages in the thread by anyone other than the person who ran the command will be deleted. In the thread go through choosing: List of things being voted for (max 25); number of people voting (or specific people, or a specific rank); Desired majority, if any. If specified voting will end when that majority is reached (rounded to the nearest possible with the number of people voting); duration of poll (default of a day, max of one month); should people be able to change their vote; should people be able to see the results before voting.
5 Complex ADMINISTRATOR ... Shorthand for the builder command, all done in one command
  • Channel
  • On
  • Message
  • Builder
  • Complex
  • Database

Ongoing votes need to be stored in the database on a per server basis

/help command

Add a help command function for slash commands to parse and display the information already present in the slash commands.

/guild command

Slash command with sub commands for the various options that moto-bot provides with its arrows.

  • The embed should have emoji button arrows to go to the next page, but using sub command is quicker.

guild parameter, optional sub command parameter

Sub command Functionality
Info General guild info like owner, members & online, created, terrs. This is the default if no sub command is specified
Online Table of online members in order of rank, sub ordered alphabetically
Chiefs Table of chiefs with world if online
Strategists Table of strategists with world if online
Captains Table of captains with world if online
Recruiters Table of recruiters with world if online
Recruits Table of recruits with world if online
xp Table of members and their xp contributions, in order of most donated
  • Info
  • Online
  • Chiefs
  • Strategists
  • Captains
  • Recruiters
  • Recruits
  • xp
    .
  • Stars next to name based on level
  • Banner as embed thumbnail

Guild activity graph

Add a command to show a graph of player activity for a guild, similar to this.
(Maybe add to the guild command?)

/deathroll

When called like roll, it'll say something like
Rolled d20: 13
Or you can reply to the output of someone else's deathroll command and it will automatically use the result of their roll as the number of sides for the new roll.

Implement command return codes

Change all commands to return a code after execution representing what happened. If command executed successfully, or made api calls and failed put command on cool-down.

  • Implement return codes on all commands

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.