I was in a scenario where a channel I mod for is doing a giveaway via Gleam.
We have a simple !giveaway command that spits out a Gleam link with all the details surrounding the giveaway.
Despite this a common question popping up in chat constantly from new viewers is something along the lines of:
- when are you doing the giveaway?
- when is the giveaway happening?
- how long until the giveaway starts?
The giveaway registration period is a month long. I thought, okay it’s super easy to throw together a command to spit out how many days until the giveaway happens since I know when it started.
So I minified
(() => {
const ends = new Date('2024-05-22T15:27:02.000Z');
ends.setDate(ends.getDate() + 30);
const diffMs = ends.getTime() - new Date().getTime();
const days = Math.ceil(diffMs / 1000 / 3600 / 24);
return `${days} day${days === 1 ? '' : 's'}`;
})();
And set up
The giveaway will occur in $(eval (()=>{let e=new Date("2024-05-22T15:27:02.000Z");e.setDate(e.getDate()+30);let $=e.getTime()-new Date().getTime(),t=Math.ceil($/1e3/3600/24);return`${t} day${1===t?"":"s"}`})();)
This command spits out the desired string content, but it doesn’t fix the issue of the streamer or us mods having to direct viewers to use a specific command.
I was googling around and it doesn’t seem like it’s currently possible, but it’d be great if the command name could be a regex pattern.
Then I could set it to something like /^.*(when|how\slong).*giveaway.*$/gi
That way when a viewer’s comment hits this threshold of keywords the NightBot chat bot could automatically answer them so the streamer/mods don’t have to.