GithubHelp home page GithubHelp logo

codewars / discord-bot Goto Github PK

View Code? Open in Web Editor NEW
21.0 21.0 11.0 465 KB

Codewars Discord Bot

License: MIT License

TypeScript 94.65% Handlebars 1.37% JavaScript 2.55% Dockerfile 1.43%
discord discord-bot

discord-bot's People

Contributors

awesomead1 avatar b1tstm avatar dependabot[bot] avatar djacon avatar donaldkellett avatar eloiserosen avatar hobovsky avatar kacarott avatar kazk avatar madjosz avatar nuoliveira avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

discord-bot's Issues

Change the command '/info user'

At the moment, the command performs the simple function of showing the user name and ID on the server. I find the command not so useful. Instead, we can create a function that will show a little info about the Codewars user.
The information includes: username, rank, honor, leaderboard position, number of katas created, number of katas completed.

The information will be displayed like this:
info_user

Show help command in bot status

It seems quite common for bots to show their help command in the bot status. For example, here are a few bots from the Xena Discord server:

Screenshot from 2022-01-28 11-09-50

I think we should do this as well.

Handle basic natural language queries

As suggested on Discord, what if our bot had a command that could process basic natural language queries and maybe respond to them by quoting from the appropriate Codewars docs, and / or attempt to translate them into other standard commands? E.g. assuming my server nick matches my Codewars username, I could ask:

?ask How many 1 kyus do I need to complete to reach 2 dan?

30

Basically something similar to this assignment in an AI course, which doesn't seem too sophisticated, though perhaps a more complex approach is required for greater accuracy. Of course, there's also the question of whether such things are suitable in Node.js / TypeScript compared to Python.

What do you think?

/echo command freezes browser tab when echoing three backticks with format

Using the /echo to output three backticks ``` with optional format freezes the browser tab.

To reproduce
Type /echo, space, three backticks, tab and then click on the suggested additional format option.
image
This will freeze the current browser tab and keep your CPU very busy. Only option then is to close the browser tab.

Tested with

  • Windows 10 Pro 20H2 19042.1466
  • Opera Version: 83.0.4254.27
  • Firefox 96.0.3 (64-Bit)

Restrict ?rankup command to channel #bot-playground

The ?rankup command added in recent times (thanks @Kacarott !) has gained massive popularity within the Codewars Discord server and is invoked very often. However, doing so sometimes drowns various topic channels with noise, detracting from whatever conversation was happening beforehand. As a result, a dedicated channel #bot-playground was created for the purpose of invoking this command (and possibly other future popular recreational commands), though moderators still have to constantly remind newcomers to move over to that channel for invoking the command.

Perhaps instead of manual moderation, the ?rankup command itself should only work in #bot-playground ? It would still be helpful to print an informative message in other channels though, so it doesn't give the false impression that the bot is broken or not responding.

Mention user when trainer link is posted

The current message displayed when someone posts a link to the trainer is very short and concise, which minimizes the noise in the channel for all users. However, I think the bot is a bit too quiet, in that 99.9% of the time, the message from the bot is just ignored with no corrective action from the OP whatsoever (or even any indication that the OP noticed the bot at all).

This means that the trainer link is still there, often much more visible than the bot's message (especially with the link preview), making it very easy for other users (e.g. me) to accidentally click on the trainer link instead of the bot's corrected link, thus effectively rendering the bot's actions completely useless.

To fix this, maybe we should make the bot's message a reply to the OP or mention the OP, just so we can at least guarantee to catch the OP's attention? That way, it doesn't increase the noise for other users, but the OP is more likely to notice their error and hopefully more likely to take corrective action as suggested by the bot.

Enable ?introduce command for power-users

Currently the ?introduce command is only available to admin and mods but not power-users. Over time, this has proven to be an inconvenience as power-users may wish to tell newbies to format their code properly when asking Kata-related questions etc., but since the command is not available to them, they have to type the response manually. On the other hand, there are typically only 1 or 2 mods online at any given time and they may be too busy with other stuff to respond to newbies in a timely manner.

Since the ?introduce command is for informational purposes only, there is no reason to restrict its usage for power-users whom we expect to behave responsibly. We still do not want it to be available to any user though to prevent abuse. On the other hand, moderation tools such as ?warn should remain available only to admin and mods.

Introduce ?help command for listing existing bot commands

As seen in https://discord.com/channels/846624424199061524/846634002328715295/935805431660552212 and a few other places, newcomers to our server see our bot and expect to be able to summon a command like ?help to obtain usage information on it, but get disappointed when there is no reply. I assume such a command is a convention commonly employed by other bots on Discord, so it would make sense for us to implement such a command as well so newcomers don't have to guess what the bot is able to do - the bot should tell us.

[Discussion] How playful should our bot be?

Currently, our official bot has some basic moderation features built in, but should we limit our bot to just moderation features? As an example, the Xena Project Discord server (public invite not available) has some 12 bots, where one of them (lean-bot) is "homegrown" for running Lean code snippets, one of them (MEE6) is presumably used for moderation (though I've not seen it in action), but the other 10 are just bots "for fun", e.g. a counting bot for playing a game of taking turns counting upwards, some 2 bots related to chess, etc.

If we decide to add some "game" features to our bot, here are a few ideas (that should not require connecting to the code runner):

  • BF interpreter, possibly configurable with "command-line" options
  • Lambda calculus evaluator ( @Kacarott might be interested in this after learning TypeScript ;-)
  • Z3 automated theorem prover integration it doesn't have JavaScript bindings :-(

Some possible pros:

  • More banter
  • More community engagement
  • Attract more people to use Codewars, by using the Discord server as an entry point

Possible cons:

  • Interpreters built-in to the bot may stall bot for longer than desirable (what if there is an infinite loop?), and time limits only slightly alleviate this problem
  • Our bot becomes "bloated", depending on how you look at it
  • Too many "gaming features" in our bot (and the Codewars Discord server) may distract the community away from Codewars itself to the Discord server

What do you think? Feel free to leave your opinions below.

Adding Roles to the Discord server

At the moment there is no variety of roles on the codewars server as such. Now on the server there are roles only for administration. I would like to add roles for all users, as it is done on the site.

A possible list of what we would need to do:

  • Create new roles on the server (8kyu -> 2dan, and higher if necessary)
  • Implement command /verify to verify the user on the server
  • Implement command /roleup to promote the role

Task description:

  1. Create roles with colors corresponding to their ranks
  2. It is assumed that in order to get a role on the server, the user will have to write the command /verify key: "your key" to the bot in private messages.
  3. It is also assumed that in the case of increasing the rank of the user, the user will have to write to the bot in private messages with the command /roleup.

Problems and possible solutions:

In the case of the /verify command, it would be necessary to provide the bot with a key identifying the user. I think we need to create an individual key generator in the user's account settings on the site.

In the future, in case the user's rank is increased, we need to check this event in some way. I think that in order for the bot not to check in real time the change of rank, we should simply add a command /roleup, which, using the previously obtained key, make a check of the user's account for its promotion.

Bridge Discord and Gitter through #legacy Discord channel

While the vast majority of Codewars users have welcomed Discord with open arms, there are still a tiny percentage of users who refuse to switch to Discord for various reasons such as privacy concerns or usability, etc. While that percentage is tiny, it includes some of the best known power users on Codewars such as @Voileexperiments and @JohanWiltink . Nevertheless, without a proper bridging mechanism between Discord and legacy Gitter, the community remains split into two with no reliable method of inter-communication.

In the past few weeks, @XRFXLP has managed to relay Discord messages to Gitter and vice-versa through the use of two separate bots. He concluded that it could not be reliably achieved with a single bot due to race issues(?). This experiment demonstrates that such a bridge is feasible to implement.

The question now is: do we consider it worth the time and effort to create such a bridge? If so, perhaps we can build the Discord to Gitter relaying with this existing bot and create a separate Gitter bot for the reverse direction. What do you think?

Plop 3.x.x fails to recognize ".ts" extension

Likely caused by #45

When running npx plop command or npx plop message-handler, Plop no longer recognizes ".ts" as a valid file extension:

$ npx plop command
[PLOP] Something went wrong with reading your plop file TypeError: Unknown file extension ".ts" for /home/dsleung/discord-bot/plopfile.ts
    at new NodeError (node:internal/errors:371:5)
    at Object.file: (node:internal/modules/esm/get_format:72:15)
    at defaultGetFormat (node:internal/modules/esm/get_format:85:38)
    at defaultLoad (node:internal/modules/esm/load:13:42)
    at ESMLoader.load (node:internal/modules/esm/loader:303:26)
    at ESMLoader.moduleProvider (node:internal/modules/esm/loader:230:58)
    at new ModuleJob (node:internal/modules/esm/module_job:63:26)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:244:11)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Promise.all (index 0) {
  code: 'ERR_UNKNOWN_FILE_EXTENSION'
}

Make default prefix for commands more unique

Currently the default prefix for commands is ? which isn't exactly widely used among Discord bots, but also not particularly unique. I think it would be better if our default prefix is more unique, like cw!, to avoid clashing with prefixes used by other bots. Of course, our server does not currently intend to introduce bots other than our own CW Discord bot so there's not much practical motivation to change our prefix, but IMO doing so is still meaningful from a branding perspective. What do you think?

Migrating to slash commands

First mentioned in #36 (comment) , there are now concrete plans to migrate our bot to use slash commands in place of ad-hoc text-based commands in order to leverage features such as autocompletion, parameter and type checking; in fact, initial support for slash commands has been added in #41 , though the majority of text-based commands have yet to be migrated over.

This issue aims to list and keep track of the steps required to implement an incremental, smooth migration of our bot over to slash commands, minimizing impact on users in our Discord server. Feel free to suggest changes to the list below, and / or edit the list accordingly:

  1. Remove support for COMMAND_PREFIX; update README accordingly
  2. Update command and message-handler templates for new project structure
  3. Implement /link command; remove ?link
  4. Implement /introduce command; remove ?introduce
    1. (Optional) Use new permissions mechanism to disable /introduce for unauthorized users
  5. Implement /warn command; remove ?warn
  6. Implement /rankup command; remove ?rankup
  7. Remove legacy command support
  8. (Optional) Make slash command argument extraction fully declarative

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.