tarolling / rps-bot-old Goto Github PK
View Code? Open in Web Editor NEWRPS Discord bot with a twist.
RPS Discord bot with a twist.
maybe discordjs has a format username thing i can use
in the foreseeable future, there may be a lot of players in a club, so we should probably limit it to like 25 per or sum
for new players, it's difficult to realize that /q
is the way to play ranked. would make more sense to make it a subcommand/option of /play
once we have enough guilds, we can capture true player count from db
these should not be front facing. maybe put functionality into another bot. will remedy the hotfix of a3825ae
once a user leaves all servers with the bot in it, should delete from db. might be tough to check if the user has the app added to their profile tho, will do some investigating
auto register someone when they queue
Output:
MongoServerError: $regex has to be a string
at Connection.sendCommand (/home/minecraft/multicraft/servers/server776960/node_modules/mongodb/lib/cmap/connection.js:290:27)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Connection.command (/home/minecraft/multicraft/servers/server776960/node_modules/mongodb/lib/cmap/connection.js:313:26)
at async Server.command (/home/minecraft/multicraft/servers/server776960/node_modules/mongodb/lib/sdam/server.js:167:29)
at async FindOperation.execute (/home/minecraft/multicraft/servers/server776960/node_modules/mongodb/lib/operations/find.js:34:16)
at async executeOperation (/home/minecraft/multicraft/servers/server776960/node_modules/mongodb/lib/operations/execute_operation.js:136:16)
at async FindCursor._initialize (/home/minecraft/multicraft/servers/server776960/node_modules/mongodb/lib/cursor/find_cursor.js:51:26)
at async FindCursor.cursorInit (/home/minecraft/multicraft/servers/server776960/node_modules/mongodb/lib/cursor/abstract_cursor.js:471:27)
at async FindCursor.fetchBatch (/home/minecraft/multicraft/servers/server776960/node_modules/mongodb/lib/cursor/abstract_cursor.js:503:13)
at async FindCursor.next (/home/minecraft/multicraft/servers/server776960/node_modules/mongodb/lib/cursor/abstract_cursor.js:228:13) {
errorResponse: {
ok: 0,
errmsg: '$regex has to be a string',
code: 2,
codeName: 'BadValue',
'$clusterTime': {
clusterTime: new Timestamp({ t: 1720432055, i: 6 }),
signature: [Object]
},
operationTime: new Timestamp({ t: 1720432055, i: 6 })
},
ok: 0,
code: 2,
codeName: 'BadValue',
'$clusterTime': {
clusterTime: new Timestamp({ t: 1720432055, i: 6 }),
signature: {
hash: Binary.createFromBase64('JEH/IP+fLbosKWK7KlNocULO8ZU=', 0),
keyId: new Long('7340730494826315786')
}
},
operationTime: new Timestamp({ t: 1720432055, i: 6 }),
[Symbol(errorLabels)]: Set(0) {}
}
logs
tevimzzz joined Lobby 9
COMMAND: q by tevimzzz (1234273267729305714 - Guild: 1160336554280099880) Locale: pt-BR, msecs: 1371
tevimzzz left Lobby 9
DiscordAPIError[50027]: Invalid Webhook Token
at handleErrors (/home/minecraft/multicraft/servers/server776960/node_modules/@discordjs/rest/dist/index.js:730:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (/home/minecraft/multicraft/servers/server776960/node_modules/@discordjs/rest/dist/index.js:1133:23)
at async SequentialHandler.queueRequest (/home/minecraft/multicraft/servers/server776960/node_modules/@discordjs/rest/dist/index.js:963:14)
at async _REST.request (/home/minecraft/multicraft/servers/server776960/node_modules/@discordjs/rest/dist/index.js:1278:22)
at async InteractionWebhook.send (/home/minecraft/multicraft/servers/server776960/node_modules/discord.js/src/structures/Webhook.js:224:15) {
requestBody: {
files: [],
json: {
content: undefined,
tts: false,
nonce: undefined,
enforce_nonce: false,
embeds: [Array],
components: undefined,
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: undefined,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined,
thread_name: undefined,
applied_tags: undefined,
poll: undefined
}
},
rawError: { message: 'Invalid Webhook Token', code: 50027 },
code: 50027,
status: 401,
method: 'POST',
url: 'https://discord.com/api/v10/webhooks/638351152131604521/aW50ZXJhY3Rpb246MTI2NTg2NDYyNTcwNzE1OTU3MzpId3Z2djZGWlBRcU96ME5GZ0xabDhmaTFWWklCYTNZNDNqSUtjSHpIWDZ3aVVzNEY0bE9aZ0RFTWFQakdGb00yZGRSY1k0TnU1b2pmNVZqOFVWM25yS09VNk9aQnR1WmkwcXhOZzBLczByRUpsZmVXMjJzbFFrd2s2VjU3ZEtUbg?wait=true'
}
Error log
/home/minecraft/multicraft/servers/server776960/node_modules/@discordjs/rest/dist/index.js:730
throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
^
DiscordAPIError[50001]: Missing Access
at handleErrors (/home/minecraft/multicraft/servers/server776960/node_modules/@discordjs/rest/dist/index.js:730:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (/home/minecraft/multicraft/servers/server776960/node_modules/@discordjs/rest/dist/index.js:1133:23)
at async SequentialHandler.queueRequest (/home/minecraft/multicraft/servers/server776960/node_modules/@discordjs/rest/dist/index.js:963:14)
at async _REST.request (/home/minecraft/multicraft/servers/server776960/node_modules/@discordjs/rest/dist/index.js:1278:22)
at async TextChannel.send (/home/minecraft/multicraft/servers/server776960/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:177:15)
at async Object.execute (/home/minecraft/multicraft/servers/server776960/commands/rps/leave.js:21:17)
at async Timeout.<anonymous> (/home/minecraft/multicraft/servers/server776960/commands/rps/queue.js:42:13) {
requestBody: {
files: [],
json: {
content: undefined,
tts: false,
nonce: undefined,
enforce_nonce: false,
embeds: [
{
title: '0 players are in the queue',
description: '**coffeee7217** has left.',
thumbnail: { url: 'https://cdn.discordapp.com/embed/avatars/4.png' },
footer: {
text: 'Powered by RPS',
icon_url: 'https://i.imgur.com/YODnmBn.png'
}
}
],
components: undefined,
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: undefined,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined,
thread_name: undefined,
applied_tags: undefined,
poll: undefined
}
},
rawError: { message: 'Missing Access', code: 50001 },
code: 50001,
status: 403,
method: 'POST',
url: 'https://discord.com/api/v10/channels/1260051499048763484/messages'
}
later down the line, add catch
statements to every message send/dm send and appropriately handle message error cases as stated in the docs
Consolidate
its messy and confusing
turn it into just a normal ping command bc why not
somehow that happened. error log
COMMAND: play by funtimefreddy5769 (1095436872597131376 - Guild: 1245466445777735761) Locale: en-GB, msecs: 1168
guma04's channel: <#768528007785611264>
guma04 joined Lobby challenge-1095436872597131376
Lobby challenge-1095436872597131376 | funtimefreddy5769 vs. guma04
COMMAND: q by guma04 (339802172604547072 - Guild: 768524687658844160) Locale: pl, msecs: 1268
Lchallenge-1095436872597131376-G1 | funtimefreddy5769: 0 (DNR) | guma04: 1 (Scissors)
Lchallenge-1095436872597131376-G2 | funtimefreddy5769: 0 (DNR) | guma04: 2 (Scissors)
Lchallenge-1095436872597131376-G3 | funtimefreddy5769: 0 (DNR) | guma04: 3 (Scissors)
Lchallenge-1095436872597131376-G4 | funtimefreddy5769: 0 (DNR) | guma04: 4 (Scissors)
Lobby challenge-1095436872597131376 Results | funtimefreddy5769: 0 | guma04: 4 | Games Played: 4
same logic as #6
also converting all raw embed payloads to `EmbedBuilder`s from discordjs. no need to reverse engineer discord API
Originally posted by @tarolling in #6 (comment)
currently tries to send embed in preset channel, make it so it replies to the user's command interaction
players can be in multiple challenges at once, is this a major issue?
currently, a player could potentially block the bot when they are about to lose and the lobby would be aborted. fix when exploit shows up
this would be a great use case for modals
no clue if they still function properly, so testing is needed
add back in localized commands/options
it's broken again somehow
like leaderboard
Error log
TypeError: Cannot destructure property 'players' of 'globalQueues[lobbyId]' as it is undefined.
at addPlayerToChallenge (/home/minecraft/multicraft/servers/server776960/src/game/manageQueues.js:55:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.execute (/home/minecraft/multicraft/servers/server776960/commands/rps/play.js:31:9)
at async Object.execute (/home/minecraft/multicraft/servers/server776960/events/interactionCreate.js:13:13)
forgot how to do them but yeah they would be nice for when bot has more users
this is a breaking error. error log:
COMMAND: q by sarker. (606459727429238785 - Guild: 938672929951076353) Locale: en-GB, msecs: 1125
/home/minecraft/multicraft/servers/server776960/node_modules/@discordjs/rest/dist/index.js:730
throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
^
DiscordAPIError[50007]: Cannot send messages to this user
at handleErrors (/home/minecraft/multicraft/servers/server776960/node_modules/@discordjs/rest/dist/index.js:730:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (/home/minecraft/multicraft/servers/server776960/node_modules/@discordjs/rest/dist/index.js:1133:23)
at async SequentialHandler.queueRequest (/home/minecraft/multicraft/servers/server776960/node_modules/@discordjs/rest/dist/index.js:963:14)
at async _REST.request (/home/minecraft/multicraft/servers/server776960/node_modules/@discordjs/rest/dist/index.js:1278:22)
at async DMChannel.send (/home/minecraft/multicraft/servers/server776960/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:177:15)
at async module.exports (/home/minecraft/multicraft/servers/server776960/src/game/playGame.js:33:20)
at async module.exports (/home/minecraft/multicraft/servers/server776960/src/game/playSeries.js:15:9) {
requestBody: {
files: [],
json: {
content: undefined,
tts: false,
nonce: undefined,
enforce_nonce: false,
embeds: [
{
color: 9125135,
title: 'Lobby #54 - Game 1',
description: 'Make your selection. You have 30 seconds! First to 4 wins.',
fields: [ [Object], [Object] ],
footer: {
text: 'Powered by RPS',
icon_url: 'https://i.imgur.com/YODnmBn.png'
}
}
],
components: [ { type: 1, components: [ [Object], [Object], [Object] ] } ],
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: undefined,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined,
thread_name: undefined,
applied_tags: undefined,
poll: undefined
}
},
rawError: { message: 'Cannot send messages to this user', code: 50007 },
code: 50007,
status: 403,
method: 'POST',
url: 'https://discord.com/api/v10/channels/1262019643434864651/messages'
}
sigh
Lobby 2 | _d13__ vs. mikesbooms4
COMMAND: q by mikesbooms4 (713524909699235882 - Guild: 1015702428814946455) Locale: en-US, msecs: 1677
guma04 | 1037 --> 1022
L2-G1 | _d13__: 0 (Scissors) | mikesbooms4: 1 (Rock)
L2-G2 | _d13__: 0 (DNR) | mikesbooms4: 2 (Scissors)
L2-G3 | _d13__: 0 (DNR) | mikesbooms4: 3 (Rock)
Unhandled promise rejection: DiscordAPIError[50007]: Cannot send messages to this user
at handleErrors (/home/minecraft/multicraft/servers/server776960/node_modules/@discordjs/rest/dist/index.js:730:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (/home/minecraft/multicraft/servers/server776960/node_modules/@discordjs/rest/dist/index.js:1133:23)
at async SequentialHandler.queueRequest (/home/minecraft/multicraft/servers/server776960/node_modules/@discordjs/rest/dist/index.js:963:14)
at async _REST.request (/home/minecraft/multicraft/servers/server776960/node_modules/@discordjs/rest/dist/index.js:1278:22)
at async DMChannel.send (/home/minecraft/multicraft/servers/server776960/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:177:15) {
requestBody: {
files: [],
json: {
content: undefined,
tts: false,
nonce: undefined,
enforce_nonce: false,
embeds: [Array],
components: undefined,
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: undefined,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined,
thread_name: undefined,
applied_tags: undefined,
poll: undefined
}
},
rawError: { message: 'Cannot send messages to this user', code: 50007 },
code: 50007,
status: 403,
method: 'POST',
url: 'https://discord.com/api/v10/channels/1262477138200629328/messages'
}
L2-G4 | _d13__: 0 (DNR) | mikesbooms4: 3 (DNR)
L2-G5 | _d13__: 0 (DNR) | mikesbooms4: 3 (DNR)
L2-G6 | _d13__: 0 (DNR) | mikesbooms4: 3 (DNR)
L2-G7 | _d13__: 0 (DNR) | mikesbooms4: 3 (DNR)
L2-G8 | _d13__: 0 (DNR) | mikesbooms4: 3 (DNR)
L2-G9 | _d13__: 0 (DNR) | mikesbooms4: 3 (DNR)
L2-G10 | _d13__: 0 (DNR) | mikesbooms4: 3 (DNR)
L2-G11 | _d13__: 0 (DNR) | mikesbooms4: 3 (DNR)
L2-G12 | _d13__: 0 (DNR) | mikesbooms4: 3 (DNR)
L2-G13 | _d13__: 0 (DNR) | mikesbooms4: 3 (DNR)
L2-G14 | _d13__: 0 (DNR) | mikesbooms4: 3 (DNR)
L2-G15 | _d13__: 0 (DNR) | mikesbooms4: 3 (DNR)
L2-G16 | _d13__: 0 (DNR) | mikesbooms4: 3 (DNR)
L2-G17 | _d13__: 0 (DNR) | mikesbooms4: 3 (DNR)
L2-G18 | _d13__: 0 (DNR) | mikesbooms4: 3 (DNR)
L2-G19 | _d13__: 0 (DNR) | mikesbooms4: 3 (DNR)
L2-G20 | _d13__: 0 (DNR) | mikesbooms4: 3 (DNR)
L2-G21 | _d13__: 0 (DNR) | mikesbooms4: 3 (DNR)
L2-G22 | _d13__: 0 (DNR) | mikesbooms4: 3 (DNR)
L2-G23 | _d13__: 0 (DNR) | mikesbooms4: 3 (DNR)
L2-G24 | _d13__: 0 (DNR) | mikesbooms4: 3 (DNR)
L2-G25 | _d13__: 0 (DNR) | mikesbooms4: 3 (DNR)
i found an algorithm that has a decent win rate and it could be cool to have a "play vs AI" mode
error log
COMMAND: lb by free309 (593750075763589120 - Guild: 1225118532128346193) Locale: en-US, msecs: 751
DiscordAPIError[10008]: Unknown Message
at handleErrors (/home/minecraft/multicraft/servers/server776960/node_modules/@discordjs/rest/dist/index.js:730:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (/home/minecraft/multicraft/servers/server776960/node_modules/@discordjs/rest/dist/index.js:1133:23)
at async SequentialHandler.queueRequest (/home/minecraft/multicraft/servers/server776960/node_modules/@discordjs/rest/dist/index.js:963:14)
at async _REST.request (/home/minecraft/multicraft/servers/server776960/node_modules/@discordjs/rest/dist/index.js:1278:22)
at async InteractionWebhook.editMessage (/home/minecraft/multicraft/servers/server776960/node_modules/discord.js/src/structures/Webhook.js:341:15)
at async ChatInputCommandInteraction.editReply (/home/minecraft/multicraft/servers/server776960/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:161:17) {
requestBody: {
files: [],
json: {
content: undefined,
tts: false,
nonce: undefined,
enforce_nonce: false,
embeds: undefined,
components: [],
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: undefined,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined,
thread_name: undefined,
applied_tags: undefined,
poll: undefined
}
},
rawError: { message: 'Unknown Message', code: 10008 },
code: 10008,
status: 404,
method: 'PATCH',
url: 'https://discord.com/api/v10/webhooks/638351152131604521/aW50ZXJhY3Rpb246MTI2MzE1NDUxNjIzMzAzMTc2MDpHckRaMDZBMFJtanBsdFFzcFROUWRlSGZ2UGdrUzhmY2pOU0RHMkVRMTM4OTJDNmRQRlJVdlN5cFZGcnUxR1ZTbVVYelV4RmdnTUlDRzBBczRhUVRua3JWVGJuYU5pN2JKTTFUUTlWYlZPaXdwWGMzdUNpN0VTY1FNVEtWY05zcA/messages/@original'
}
COMMAND: stats by free309 (593750075763589120 - Guild: 1225118532128346193) Locale: en-US, msecs: 821
Error logs for join
TypeError: Cannot read properties of null (reading 'value')
at module.exports (/home/minecraft/multicraft/servers/server776960/src/clubs/db/join.js:30:25)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.execute (/home/minecraft/multicraft/servers/server776960/commands/rps/club.js:75:39)
at async Object.execute (/home/minecraft/multicraft/servers/server776960/events/interactionCreate.js:13:13)
+
to positive elo gainerror log
COMMAND: q by guma04 (339802172604547072 - Guild: 768524687658844160) Locale: pl, msecs: 804
COMMAND: lb by guma04 (339802172604547072 - Guild: 768524687658844160) Locale: pl, msecs: 990
COMMAND: lb by blueprincerules0522 (1185957680272134190 - Guild: 768524687658844160) Locale: en-US, msecs: 1038
COMMAND: q by j.t.2.4_vr (1260774112846942292 - Guild: 1260791962404130816) Locale: en-US, msecs: 929
COMMAND: r by j.t.2.4_vr (1260774112846942292 - Guild: 1260791962404130816) Locale: en-US, msecs: 780
COMMAND: r by dominos7317 (1022308622614671441 - Guild: 1260791962404130816) Locale: en-US, msecs: 774
j.t.2.4_vr joined Lobby 23
Lobby 23 | guma04 vs. j.t.2.4_vr
COMMAND: q by j.t.2.4_vr (1260774112846942292 - Guild: 1260791962404130816) Locale: en-US, msecs: 784
dominos7317 joined Lobby 24
COMMAND: q by dominos7317 (1022308622614671441 - Guild: 1260791962404130816) Locale: en-US, msecs: 1073
aicovt joined Lobby 24
Lobby 24 | dominos7317 vs. aicovt
COMMAND: q by aicovt (109124650306396160 - Guild: 768524687658844160) Locale: en-US, msecs: 769
L23-G1 | guma04: 1 (Scissors) | j.t.2.4_vr: 0 (DNR)
COMMAND: play by j.t.2.4_vr (1260774112846942292 - Guild: 1260791962404130816) Locale: en-US, msecs: 333
COMMAND: play by seijiweiji (683744483405594640 - Guild: 1261803870863097948) Locale: en-US, msecs: 1141
dominos7317 joined Lobby challenge-683744483405594640
Lobby challenge-683744483405594640 | seijiweiji vs. dominos7317
COMMAND: q by dominos7317 (1022308622614671441 - Guild: 1260791962404130816) Locale: en-US, msecs: 767
/home/minecraft/multicraft/servers/server776960/src/game/manageQueues.js:80
let { players } = globalQueues[lobbyId];
^
TypeError: Cannot destructure property 'players' of 'globalQueues[lobbyId]' as it is undefined.
at addPlayerToChallenge (/home/minecraft/multicraft/servers/server776960/src/game/manageQueues.js:80:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async InteractionCollector.<anonymous> (/home/minecraft/multicraft/servers/server776960/commands/rps/play.js:63:31)
Insert a reply to user before challenge that bot cannot DM them
Add back in results that are sent to the channel(s) the players queue from
create club leaderboard
actually list out all clubs (like leaderboard command)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.