Universal Blue ChatOps
okay so I keep thinking about this bot thing. What if we had like:
Let’s make this a bot thread 🧵
50 Replies
What feature do we want/need in a bot?
ubluectl
makes it seem like a cli-thing
discord has the /slash
commands now
couldn't it be likeIt can’t be slash because it will conflict with discord stuff
/status
, /trigger-workflow
, /pr
slash commands are the new "correct" way to make discord bots, though
could have a prefix to prevent collisionsOh then I can do that but it would be
/ubluectl status
i guess
hold on, i'm googling how other bots do it
The one on fedora server uses
.command
yeah, a lot of bots use
.cmd
!cmd
etc too
but with slash commands we get that fancy autocomplete
no need for .help
https://discord.com/blog/slash-commands-are-herethe problem with that is that it seems very easy to create conflicts
other bots just have
/command
Eg:
/status
/status
there's no /status in discord by default
if we don't add other bots we can use /status
Yeah but if two bots implement /status I guess you get two responses
i'd guess discord would handle that better
because slash commands are a discord feature, not just parsing messages that people send
maybe in the dialog that opens when you type
/
you need to select the correct one?mm not sure what this discord commands feature actually does
I would prefer parsing messages because it is more flexible but need to see what the discord commands do
it's just like parsing messages, but you get autocomplete and descriptions of the different fields
multiple bots can have the same command name with slash commands, youre able to choose between what command you actually intend to use
There's limitations like this
mm need to see what it means
at least https://discordjs.guide/creating-your-bot/slash-commands.html in discord.js creating slash commands seems pretty easy
i don't think we'd cross 100, but this depends on if what we'd want is
CHAT_INPUT
or MESSAGE
Whats the difference?
no idea
slash commands have the advantages of 1. showing a little tooltip describing the command and 2. suggesting command completions
I’ll probably just use message parsing at least at the beginning because it’s very easy
heres what it looks like on mobile
i wouldn't go for worse UX because it's a bit easier to develop
Going from message parsing to slash commands is a lot easier than the reverse
CHAT_INPUT
is the one (https://discord.com/developers/docs/interactions/application-commands), the others are for context menusplus I need a working CLI anyway to test locally
usually people make personal discord servers for testing
you can test with a test discord server
do you have experience making discord bots?
I do have a testing server
It’s still not really ideal if I have to open my web browser to test stuff
i always just keep the web browser on the side, for googling stuff and such. you can just have the discord server open there and type in the commands you wanna test. i don't see the issue
To make a code change I would have to:
1. Make a code change, rebuild/reinstall application
2. Go to web browser and type on discord
vs:
npm build && npm run ubluectl
I prefer tight feedback loops
I guess I could automate something with the discord API itself to send the message
but this is more workif you do
npm build && npm run ubluectl
i presume that would connect to discord and host the bot temporarily on your local machine. with that, it's just the difference between writing the commands in the same textbox or writing them in a discord window on the side
plus if you want to have a cli for testing don't you need to build a cliyeah and it is very easy to do and very easy to reuse the work to implement other interfaces
and of course you can just use
console.log()
for debugging and the logs would just be in your console window
i don't see how using slash commands would be any more work for you (and other developers working on the project in the future) (unless you are already very familiar with the other ways of doing things), while not using slash commands makes the UX worseunless you are very familiar with the other ways of doing thingsYes.
so you have experience writing discord bots. i asked that earlier and thought you brushed it off.
I have experience writing software incrementally. Not discord bots specifically.
I build software to work on cloud different compute platforms (ECS/EC2/EKS/Lambda) transparently - I just build a CLI first for fast feedback loops and create interfaces for each compute platform so I can build core functionality first and focus on the interface later
For example it’s not really that important if the application is triggered by
ubluectl status
or
90% of the work will be the same so I’d rather start with the former so I don’t have to figure out how to test and interact with discord commands and I can just focus on interacting with GitHub, etc
Ultimately the code will run AWS lambda and needs to take in a post request so probably discord commands is totally the wayi don't have anything against you building a cli first, i was just arguing that you should use slash commands. but cool to hear that you weren't as against that as i read you as being.
You brought up good points! But at this stage I would like to focus more on the things we want to do vs implementation details
Just off the top of my head real quick:
kick off a build in any repo, with the ability to just rebuild everything in one go in order.
show any PRs older than X days
notify the dev channel if the build is broken for over X days
oh and a (useless) bonus feature, pretty complicated, if you've linked your github account to your discord account it could give CONTRIB if you have a commit in any ublue-os repository
What’s CONTRIB?
It's the discord role
Oh I see that’d be cool
I started work on this yesterday night, the end usage would be like
/status --issues --stale-pr --running-workflows
or maybe separate commands idk how discord commands are supposed to work yeti don't think you're supposed to do
--param
, i think all the params are positioned and given names and autocomplete values, so it'd probably be more like /status [type:][issues/pr/workflows]
with []
being hints discord gives to the user and the code just getting the value as {type: "issues"}
or {type: ["issues", "prs"]}
.
actually i'm not sure there's an autocomplete at allHow to pass parameters to a GitHub command?
Positional parameters are hard to remember for me
discord tells you the name of the positional parameter you are currently writing, for some things it might be more suited for named params and that might need to be a custom implementation which is not ideal