Official Glitch Discord Bot Starter!

Hi everyone! We just released a an Official Glitch Discord Bot starter. It has an interactive install guide that will teach you what you need to know to get started with your first (or 100th) Discord Bot on Glitch:

It comes with a video that will help you get started!

Please check it out and we’d love your feedback. We’ve also created some remixes of it that provide demos of what you can do with it. We’re happy to create more if you have an example you’d like us to show you how to make:

4 Likes

Looks huge, great job :slight_smile:

What is the purpose of the bot being able to create monitors on uptime robot?

1 Like

the bot will be running forever (almost).

1 Like

Why expose

router.get("/createMonitor", function(request, response)

to everybody? Anybody can spawn monitors without a consent of the owner.

Also the code is, uh, weirdly done(?).

let sender = message.user.toString();

you don’t need to call toString explicitly, when using string interpolation JS will do it on it’s own.

let recipient = message.mentions.users.filter(user => user.bot === false).array()[0].username;

why so?

You’re right about createMonitor, it has been removed thanks!

The last one you mention is pretty awkward, but I wasn’t sure how else to get around this issue:


Suggestions appreciated!

yeah, discord gives mentions in wrong order, but that’s not my concern.

.array()[0]

just call first() on collection instead of calling the array method and accessing it’s first element.
imo looks nicer and probably is more performant(?).

but uh- if you want to get the correct mention you probably should just parse the message using provided regex in message.mention property

Ah yes I agree. I found https://discordjs.guide/miscellaneous/parsing-mention-arguments.html#using-regular-expressions and will implement it soon and also link to it.

2 Likes

I did a quick benchmark on this.
functions i’ve used were taken from that guide’s repo.
https://jsperf.com/regex-vs-default (don’t mind the name)

but tl;dr
native implementation happened to be fastest.

regex with length checking

/^<@!?(\d{18})>$/

was about 20% slower (but it’s pretty readable)

and regex from that guide

/^<@!?(\d+)>$/

happened to be slowest of all and it’ll be failing on edge cases like <@1>

Thanks! When I have time I’ll dive in but these are great leads.

BTW if anyone wants to contribute here is our official github repo:

2 Likes

Cool project & video. Just wondering why you chose to use Botkit instead of Discord.js, etc.

:slight_smile: Have a great day.

Botkit is just a wrapper for Discord.js

Yep, it has both Discord.js and Botkit (since the Botkit Discord depends on Discord.js). It’s possible I will refactor in the future as Botkit has a new version out that may not be as compatible with Discord.

There are a lot of things I like in Botkit like:

  • Storage connectors- makes it easier to swap out databases
  • Syntax - I like how readable the code is
  • Documentation- I think the documentation is easier to understand than the Discord.js is, but that’s just a personal opinion
2 Likes