#Can someone review my code please?

1 messages · Page 1 of 1 (latest)

covert basaltBOT
#

Hey! Once your issue is solved, press the button below to close this thread!

summer spear
#

i feel like i could handle the startup tasks better but cant think of a way

main walrus
#

You should be testing little bits of code each time. If you haven't done that yet, you are in for one hell of a debugging session.

summer spear
#

if it was a full featured bot i would do that, but its basically a single feature in a more advanced bot so im less afraid to just code away and test later

swift thicket
#

My suggestion is try looking to aiofiles for async File read/ write

swift thicket
#

I always do that to avoid Like too many unknown bugs Popping out

#

Something like Don't try to Run , if you haven't learn to Crawl As Codes are built upwards gradually

summer spear
#

well ive been coding for over a decade and have made 5 discord bots before

#

granted, it was when the discord api was a lot more simple. pre custom user statuses

summer spear
#

also wait im not actually writing to a file, its staying bytes

swift thicket
#

Tbh it will matter as I dealt with it b4 by writing a whole Robotic System with Asyncio So my juniors will be able to scale on the functions
As Reading and writing files are considered Blockking it won't matter if it is a few smallchars but when it became bigger it will

summer spear
#

oh true that was in the context of a config

swift thicket
#

Also maybe you would want to look at Regular Expressions on the valid chars part

summer spear
#

couldnt be faster than list comprehension and join

#

but rly im mostly looking for critique on how im using interactions.py itself

swift thicket
#

If that's the case maybe try using Extensions to help scale up the code

summer spear
#

thats planned

#

I am planning on adding a config file, logging, and splitting this up into modules later.

#

im like

#

do i really have to do this or am i missing something

#
channel = ctx.channel
if isinstance(channel, GuildText):
#

this too

async for message in history:
    assert isinstance(message, Message)
    if message.type == MessageType.DEFAULT:
#

not sure how to deal with all these extra types

#

and discord.py was lenient and would return an empty string if a topic was empty, for instance

swift thicket
#

I would suggest to use a db to do the stroing of your channel , message and stuff

summer spear
#

im not storing anything

#

like the open() part is purely just for uploading, not saving to a file

#

its how ModMail works so i figured id just keep it like that, since i basically want ModMail with a few extra features

#

though i have been toying with the idea of writing to a temp file and saving in chunks just in case of the api messing up or something