Skip to content

Instantly share code, notes, and snippets.

@qwertyad1
Last active June 8, 2023 16:03
Show Gist options
  • Save qwertyad1/c788354205b0025b88986de11016f08b to your computer and use it in GitHub Desktop.
Save qwertyad1/c788354205b0025b88986de11016f08b to your computer and use it in GitHub Desktop.
This is some code for the assyst discord bot.
function maxIdx(list) {
let maxNumber = -Infinity;
let maxIndex = -1;
for (let i = 0; i < list.length; i++) {
if (list[i] > maxNumber) {
maxNumber = list[i];
maxIndex = i;
}
}
return { max: maxNumber, index: maxIndex };
}
fetch( "https://arewepomeloyet.com/api/v1/pomelos" ).then(r => JSON.parse(r.text()).stats).then(function (data) {
let l = data.length
let a = []
let o = 0
let c = 0
while (l > 0) {
c = c + data[o].totalCount
a.push(data[o].totalCount)
o = o + 1
l = l - 1
}
let m = maxIdx(a)
return `
\`\`\`There are more than ${c} discord users with pomelo usernames.\`\`\`
\`\`\`The most common account date is ${data[m.index].date} with ${m.max} users with pomelo\`\`\`
\`\`\`if you have any suggestions, comment on my github gists page:\`\`\`
> <https://gist.github.com/qwertykid/c788354205b0025b88986de11016f08b>
`
})
@qwertyad1
Copy link
Author

qwertyad1 commented Jun 8, 2023

if you want to set this up in your server use the command

-t create pomelo-count {js:{download: https://gist.github.com/qwertykid/c788354205b0025b88986de11016f08b/raw }}

you can then use the command with
-t pomelo-count

if you dont have the bot click here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment