pxlsspace / PxlsBot

Modular Discord bot
ISC License
4 stars 2 forks source link

Fix theoretical max size of a Discord Snowflake #25

Closed netux closed 3 years ago

netux commented 3 years ago

Snowflakes in Discord represent 64 bit numbers. The maximum unsigned 64 bit integer is 18446744073709552000, which as text contains 20 characters, more than 18.

This fixes the check in util.isSnowflake() and changes the types of database columns that previously assumed Discord IDs were at most 18 characters long.

Database changes

ALTER TABLE auditlog ALTER COLUMN guild_id TYPE VARCHAR(20);
ALTER TABLE auditlog ALTER COLUMN user_id TYPE VARCHAR(20);

ALTER TABLE config ALTER COLUMN guild_id TYPE VARCHAR(20);
ALTER TABLE config ALTER COLUMN starboard_channel TYPE VARCHAR(20);

ALTER TABLE starboard_messages ALTER COLUMN guild_id TYPE VARCHAR(20);
ALTER TABLE starboard_messages ALTER COLUMN source_message_id TYPE VARCHAR(20);
ALTER TABLE starboard_messages ALTER COLUMN board_message_id TYPE VARCHAR(20);