#dev-contrib
1 messages Β· Page 137 of 1
I think most of the wrong hints were from when the project started and the code quality was significantly lower because there weren't many people to review things
Beginners are also the ones who benefit the most from typehints
It shouldn't be something that errors in the pre-commit
But I think it could be added as CI that will show up errors and then someone can give the user a human-readable version of what needs changing
!ext r help_channels
:ok_hand: Extension successfully reloaded: bot.exts.help_channels.
there was only 2 available for some reason
discord api struggles probably
yea seems like it, saw some 504s from the help channel cog in sentry
Sounds good
There should be a review guide though because I have to say it's much nicer to get reviews in the beginning about the logic and how it works rather than nitpicks
(Not talking about these reviews specifically, jsut in gneeral)
An introduction and guide to the world of code reviews!
nitpicks are important too if they influence code quality
Ahh, that exists
True, it's just that opening the editor just to edit this tiny mistake and just multiple reviews of tiny mistakes just makes you lose motivation in the PRs, rather changes like logic keep you engaged cause you're actually doing somthing
you can put it off for a bit if you're not feeling motivated, the PRs aren't critical to need immediate attention
You can wait a bit, those aren't critical and doesn't need immediate fixing. Do them in batch.
If anything it is simply a sign that the PR is about to be merged, because all logic issues are fixed and now it is about making sure it meets the quality of the rest of the bot.
Ah alright
In batch means make multiple commits, but one push right?
I'm really bad about pushing singular small commits
No, I am saying that you wait it off until all comments have gathered and then commit all fixes one time instead of opening your editor to make a small typo fix.
Ah
Ohhh gotcha. Let the PR marinate a little bit and build up suggestions, then make all the changes at once with one commit
I have a question - should I implement a change if it virtually does the same thing but it just takes a bit more time out of working on my other PRs?
Like changing from a link system to a local file system
Is this in reference to the Hangman thing?
I think it is fine there, we have imgur links at other parts of the bot. I realize now that I probably should've commented that to make it clear
alr
That should be very easy! We use Python 3.9 so take a look at await asyncio.to_thread().
Yeah it's new in 3.9 and so much better
You used to do the executor stuff which was annoying
@vale ibex Your changes are implemented
Are you sure you pushed you changes?
Ah cool, I'll look
Just one of my comments to be looked at now π
oh wait, it was in a commit with the wrong name
How do these sound for python related words
snake
python
github
cpython?
programming
antigravity
Hmm, antigravity?
easter egg
not sure many people would know what antigravity is
ooh, how about
bytecode
Snake isn't technically related to python
Fair
I'll take out snake
cool, maybe these too π ```py
lambda
class
print
function
Guido
Python Discord
dictionary
True
False
import
return
yield
no problem with more words
No capitalization though
π
'hashmap' maybe?
no wait theyw ouldn't
How about PyDis?
pydis sounds good
Actually that's an abbreviation technically not sure if that will work
Do you think I should keep it in alphabetical order or just so I don't have to look through the entire list for each word, add it to the ned
Yeah
Sounds good
maybe binary too
or `hexadecimal
binary, hexadecimal, octal
Yeah that works
is this nim highlighting btw π
nvm lol
it's osmehting else
It was in alphabetical order to begin with so I think it should stay that way
Use Python to sort it
Great idea!
cat file.txt | sort -u > output.txt 
Add them to the end then have some script that does like ```py
with open('hangman_words.txt', 'rw') as f:
lines = f.readlines().sort()
f.seek(0)
f.write(lines)
I want to learn pipes better, it looks so cool
I didn't see this till now, I already sorted them by hand lol
just used regex search
Ah lol
@brisk brook You mentioned to_thread, I have that setup, but is there a blocking HTTP session?
Where would there be a blocking HTTP session?
so i can take it in a thread
since its' blocking
I use the async with self.bot.http_session
Aren't you using HTTPx or Aiohttp?
Yeah, notice the async with?
That is not blocking
Yeah ik
So do i just not convert it to a thread?
If it isn't blocking
the blocking time really isn't that much though
@brisk brook ^^
sorry for the ping, just that i'm using aiohttp yet people want it to be in the executor?
No that does not need to be in a thread, sorry for the delay.
No worries! and alright, sounds good
so mostly little grammatical rrors to fix
Also - should I use RGB or pure hex for the KYU colors?
I prefer HEX than color tuples
You can just format the number as hex. The format specifier would be 02x (the 0 for padding).
For instance, (18, 98, 227) is 1262e3:
!e
print(f"{18:02x}{98:02x}{227:02x}")```
Eval wanna work?
It has to be first yeah?
!e
print(f"{18:02x}{98:02x}{227:02x}")```
@gritty wind :white_check_mark: Your eval job has completed with return code 0.
1262e3
In case you're curious, that's some shade of blue
and does discord.py want it as 0x1262e3 or just 1262e3?
Umm, which function?
th color.from_hex i think
doesn't exist
ohh i'ts just normal
it' sthe color argument
discord.Color(color=...)
Both seem to work
0x1262e3 is preferred
!e ```py
print(0x1262e3)
@brisk brook :white_check_mark: Your eval job has completed with return code 0.
1204963
Yeah see, that's just special Python syntax. It becomes the number it represents
Does discord.Colour actually take in a hex? It seems to expect an rgb tuple
Ah, nvm
It's just the bad docs
Righto, so you'd probably want to actually convert it first
It takes in an int, string of hex characters, and a color tuple yeah
To go from what I had to a valid value, wrap it in int(<formated string>, 16)
That'll just convert it to an int from a base 16 string
Or just... use the discord builtin method and avoid the trouble π€‘
Yeah....the color command I'm working on expects some wild stuff for embed color
Yeah.. should I just switch back to RGB?
much less complicated lol
What are you working on?
sir-lancebot#860
I take a rgb tuple for the color of the embed to represent KYU colors
If you still want to set your own colors, you can do that, just saying to use the discord method for it so you donβt have to implement it yourself
what's the discord method?
^
Discord.py rather
sir-lancebot#842 if you were asking me
@trail pilot I think you ended up committing the opposite of this
. It's not a big deal though eitherway
Oh, oop
@static canyon Fixed
yes
how do you get pre-commit to work?
i had to remove the vscode section, it breaks the .gitpod.yml for some reason
(sir-lancebot-7VoPu34x-py3.9) gitpod /workspace/sir-lancebot $ pre-commit install-hooks
[INFO] Installing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('/home/gitpod/.cache/pre-commit/repo3u60y7x8/py_env-python3.9/bin/python', '-mpip', 'install', '.')
return code: 1
expected return code: 0
stdout: (none)
stderr:
ERROR: Can not perform a '--user' install. User site-packages are not visible in this virtualenv.
Check the log at /home/gitpod/.cache/pre-commit/pre-commit.log
(sir-lancebot-7VoPu34x-py3.9) gitpod /workspace/sir-lancebot $ poetry run precommit
FileNotFoundError
[Errno 2] No such file or directory: b'/home/gitpod/.nvm/versions/node/v14.17.5/bin/precommit'
at ~/.pyenv/versions/3.9.6/lib/python3.9/os.py:607 in _execvpe
603β path_list = map(fsencode, path_list)
604β for dir in path_list:
605β fullname = path.join(dir, file)
606β try:
β 607β exec_func(fullname, *argrest)
608β except (FileNotFoundError, NotADirectoryError) as e:
609β last_exc = e
610β except OSError as e:
611β last_exc = e
(sir-lancebot-7VoPu34x-py3.9) gitpod /workspace/sir-lancebot $
did you do this yourself?
you need to set PIP_USER to false
the hooks themselves have to install to be able to use pre-commit
tasks:
- name: "Python Environment"
before: "pyenv install 3.9.6 && pyenv global 3.9.6"
init: "pip install poetry && export PIP_USER=false"
command: "poetry install && poetry run pre-commit install"
gitpod doesnt allow user site packages
pre-commit has installed
ill see if i can get vscode extensions to work, but no promises unfortunately
aight
here's a minor change:
tasks:
- name: "Python Environment"
before: "pyenv install 3.9.6 && pyenv global 3.9.6"
init: "pip install poetry && export PIP_USER=false"
command: "poetry install && export PIP_USER=false && poetry run pre-commit install --install-hooks"
for some reason
you only need to export once
and removing that second PIP_USER export breaks the whole thing π
also in that same thing, I've added the --install-hooks flag which means when it installs the hook it also installs the environments so rather than having to wait for them to install on the first commit they install with everything else
i dont like how long that line gets
#dev-contrib message
@celest charm@tawdry vapor someone just pointed out something extremely important concerning this.
pipx.
Rather than installing poetry to the same env, install pipx and then install poetry with pipx. 
discord-modmail/modmail#74
lol
shh don't tell anyone
Installing in a venv is trivial enough to not warrant introducing a new tool. In fact, it's poetry's default behaviour, but it was disabled because a venv was perceived to be redundant. I'm sure pipx has its uses but not really for this case.
Well yes, but also no
A good portion of poetry installs were installed with pipx. Imo it's a reliable tool which has less problems than poetry.
Using pipx to install poetry puts poetry in the venv and allows the project to be installed to site packages.
So poetry can be in a venv and our dependencies can be global, OR poetry can be global and our dependencies in a venv. I don't see a practical difference, except for the former requiring an extra tool (in fact, the venv could just as easily be created manually I suppose).
Keep in mind poetry is the only thing that needs to get installed besides what's in the lock file (and the usual setuptools).
yeah. You could make a venv and install poetry there with pip , then invoke the venv poetry to install the dependencies to the current pip
I believe that poetry actually just installs by invoking the current pip on the path, so even just resetting that to the system pip in the dockerfile would work
@fallen patrol I think we came to the conclusion that the proper way to resolve the conflict was to create a requirements.txt using poetry and then use it instead of poetry in docker
Ah in my case I could not do that, and that's not a feasible solution
yeah i've seen that done before
Why would it not be a feasible solution?
yeah it's generally pretty alright to do, poetry has a command https://python-poetry.org/docs/cli/#export
Commands Youβve already learned how to use the command-line interface to do some things. This chapter documents all the available commands.
To get help from the command-line, simply call poetry to see the complete list of commands, then --help combined with any of those can give you more information.
Global options --verbose (-v|vv|vvv): Increa...
!d importlib.metadata
New in version 3.8.
Changed in version 3.10: importlib.metadata is no longer provisional.
Source code: Lib/importlib/metadata.py
importlib.metadata is a library that provides for access to installed package metadata. Built in part on Pythonβs import system, this library intends to replace similar functionality in the entry point API and metadata API of pkg_resources. Along with importlib.resources in Python 3.7 and newer (backported as importlib_resources for older versions of Python), this can eliminate the need to use the older and less efficient pkg_resources package.
I have to have my package installed, so I can get its version from site packages
I mean I could use read the toml key from pyproject.toml but I would rather not do that even in the docker containers
Here's your reminder: Forms stuff ^
[Jump back to when you created the reminder](#dev-contrib message)
To be fair, I'd probably do this for local non-docker or non-pypi installs
So when the user has installed a tar but not installed the project or something. Check that the pyproject.toml file references the right project, and then use the version in it.
But in docker, I would like it to work the same way as pypi, which will be importlib.metadata.
This is why it has to be installed in docker π
Hey could some take a look at sir-lancebot#857 ? π
@vale ibex What do you think of this?
Yea, looks good π
Oh, that's cute π
though a space between the lines would probably be helpful
Agreed.
so
_ _ _ _?
yeah
That would be nice, you can tell the number of letters more easily.
if need help implementing that feel free to ping me
Alright, it's working now!
@vale ibex I added all your changes, feel free to review anything more if you want
ok i was bored
heres a helper class:```py
import string
class AlreadyGuessedError(Exception):
pass
class WrongGuessError(Exception):
pass
class InvalidGuessError(Exception):
pass
class Word:
def __init__(self, word: str):
self._word = word
self._letters = set(word.lower())
self._guessed_letters = set()
def guess(self, guess: str):
if len(guess) != 1:
raise InvalidGuessError()
normalised_guess = guess.lower()
if normalised_guess not in string.ascii_lowercase:
raise InvalidGuessError()
if normalised_guess in self._guessed_letters:
raise AlreadyGuessedError()
if normalised_guess not in self._letters:
raise WrongGuessError()
self._guessed_letters.add(normalised_guess)
@property
def guessed(self):
return self._letters == self._guessed_letters
def __repr__(self):
return " ".join(character if character in self._guessed_letters else "_" for character in self._word)
def __str__(self):
return self.__repr__()```
One note --
why do you use __repr__ as a fallback for __str__?
__str__ is the first method, then __repr__ is the fallback, why not just add the __repr__ code to __str__
true, anyways that code is pretty cool nevertheless
def __str__(self):
return " ".join(character if character in self._guessed_letters else "_" for character in self._word)
def __repr__(self):
sclass = self.__class__
return f"<class '{sclass.__name__}'>: {self.__str__()}"```
maybe thats cleaner
ab_c_ _fg a b _ c _ _ f g
The game board is deleted when I win/lose now
rather than showing how many tries I had left
Ah, so I should send a different embed saying you lost/won?
and keep the gameboard?
Yea, wasn't it doing that before?
It was only doing that for winning
Ah right, yea I think it would make sense to send it separately
so that users can see how they did
Alright, I'll push it in a minute or so, just testing it out
alright, ti works
Pushed it!
Thanks for the approval! @vale ibex
π
@remote wigeon I added your changes
changed to delete_after
and I also changed to a variable instead of editing the varibale directly
this is gonna error
Fixed
π
@static canyon Good PR, thank you for creating it.
Any other opinions on this? https://github.com/python-discord/sir-lancebot/pull/859#issuecomment-920407469
@vale ibex in bot/bot.py of https://github.com/python-discord/bot/pull/1820, is it converted from a set to a list to remove duplicates?
yupyup
ty
Yea, I'll sort out the commits
can't merge because we're waiting on another PR, yeah?
yea, the site one
oh they're both approved once
Sorry, just updated the branch on the bot repo
might wanna pull
oh lol
I just force pushed it anyway
I try to avoid updating branches if I intend to squash
since that brings public commits into the branch
I just rebased and squashed instead
rebased both, gonna merge
dew it
once site ci finishes π
Nice
Chris and Xith =
& π§
Is there a process for assigning an issue from github to yourself ? I think i asked this once but the response was to just comment it there
Is there a process for assigning an issue from github to yourself?
There isn't, you're correct in that you should comment that you'd like to work on an issue and we'll assign it to you
Okay then, thanks !
Yeah there really isn't a better reliable way. It should still serve its purpose.
sir-lancebot#849
Please
Yes I am gonna have some fun with that today and hopefully leave my last comments!
Could you please move the error_embed creation under the if condition, as discussed before? I believe you might've forgotten.
That- and some hangman playing :3
Sounds good, should have just removed it all
Your belief is correct, oops
what about hanging a ducky π
an analysis of the two player asymmetric adversarial pencil and paper word guessing game hangman
http://patreon.com/hbmmaster
http://twitter.com/hbmmaster
http://conlangcritic.bandcamp.com
http://janmisali.tumblr.com
0:00 intro
0:18 part one: what hangman is
2:33 part two: winning at hangman
9:10 part three: cheating at hangman
13:03 part four:...
That sounds awfully wrong lol
but hanging a human is alright?
πhail satan

petition to rename it to hangperson, we don't want to single out males in execution
βThis represents the hung manβ sounds like Iβm a murderer lmao
Equality is great - letβs just execute everyone tbh

i mean its still mankind Β―_(γ)_/Β―
#dev-contrib got pretty heavy and dark
Yeah lmao
Dun dun dunnnnn.....
I agree
as in what does it do?
it manages nominations - we don't actually have a pool anymore
How we do recruitment and nominations for helpers
:x: Nominating staff members, eh? Here's a cookie :cookie:
It's a little bit depressing that I recognize my own ID now -_-
lol
The pool is in our hearts
Submitting coverage to coveralls.io...
Could not submit coverage: 405 Client Error: Not Allowed for url: https://coveralls.io/api/v1/jobs
Traceback (most recent call last):
File "/home/runner/work/bot/bot/.cache/py-user-base/lib/python3.9/site-packages/coveralls/api.py", line 237, in wear
response.raise_for_status()
File "/home/runner/work/bot/bot/.cache/py-user-base/lib/python3.9/site-packages/requests/models.py", line 953, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 405 Client Error: Not Allowed for url: https://coveralls.io/api/v1/jobs
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/runner/work/bot/bot/.cache/py-user-base/lib/python3.9/site-packages/coveralls/cli.py", line 85, in main
result = coverallz.wear()
File "/home/runner/work/bot/bot/.cache/py-user-base/lib/python3.9/site-packages/coveralls/api.py", line 240, in wear
raise CoverallsException('Could not submit coverage: {}'.format(e))
coveralls.exception.CoverallsException: Could not submit coverage: 405 Client Error: Not Allowed for url: https://coveralls.io/api/v1/jobs
Error: Process completed with exit code 1.```Err I think something's wrong with the bot checks? <https://github.com/python-discord/bot/pull/1831/checks?check_run_id=3639273246>
That seems like an issue in the check code rather than from my PR
Don't worry about it right now
They can be reran later
Preferably to rerun them when the api is back
Ah, I see
Do you know how I can force-rerun the check once the maintenance has finished? @fallen patrol
Button on the checks, probably
This link, upper right iirc
Just saw this, ty
Is anyone else getting 404s whenever they click on commits in a PR on github?
ok, not just me, https://github.community/t/bug-clicking-on-pr-commit-links-causes-404/201684, sigh
I assume @dusky shore doesnβt have access to some dedicated GPU?
It doesn't no, what sort of thing are you thinking of?
I was thinking if Iβd continue making the lemon beard text command some day, if a GPU for quickly rendering the image would be available
hmmm no GPU compute as of now - will have to see if we could fit it into our budget
But itβs not an issue without it. Just wouldβve been a bit fun to use if we already had it
lol, minimum for a GPU instance is $1,000/month, and our yearly budget is $2,000
Why does it require a GPU?
I don't think the speed difference is noticable for an image this size with that amount of operations. GPUs are good for very particular operations.
You'll also need certain frameworks to communicate with it that would probably be too heavy for a project like lancebot
If we use SIMD instructions with that Pillow fork we can basically do it on CPU and do it fast
Why GPU instance is so expensive?
Because everyone wants them
But people don't actually hold a GPU instance for an entire month like that
It's worth getting it because they only need it for relatively short periods of time
If you want a GPU instance for a long time you'll get a spot instance which is considerably cheaper
There are entire enterprises revolving around managing spot instances with GPUs for training machine learning models
Hey all, can we get some general feedback on sir-lancebot#842 if you get a chance? Still working through some implementation decisions
Feedback on what in particular?
The user input is an open point for me
What about the user input are you not sure about?
I actually watched a talk about using GPUs on EuroPython, which is why I even had it in my mind
I was just thinking if we already had a GPU, it would be fun to try it out with that command
Yeah no worries, I'm just saying that working with a GPU requires a whole other setup
Yep
Also @dim pelican would you like feedback about the code itself, or do you want to wait until the PR is ready?
How many cases should the command handle?
https://github.com/python-discord/sir-lancebot/pull/842#issuecomment-921862584
Also I'm good with feedback as we go
I think all of those cases are fine and doable with a bit of regex
Replied in the PR
Basically what toxic said
Ugh, I made it in single comments instead of starting a review
funnily enough, this 404ed
works fine for me
def wookie(x, y):
@cold island Could you please review sir-lancebot#843 when you have a moment? Thanks!
Thanks @sleek steppe for your review on Hangman!
@sleek steppe Implemented your suggestions for sir-lancebot#843
oops lol
Haha
!tags
Β» args-kwargs
Β» async-await
Β» blocking
Β» botvar
Β» class
Β» classmethod
Β» codeblock
Β» comparison
Β» customchecks
Β» customcooldown
Β» customhelp
Β» decorators
Β» defaultdict
Β» dict-get
Β» dictcomps
!args-kwargs
*args and **kwargs
These special parameters allow functions to take arbitrary amounts of positional and keyword arguments. The names args and kwargs are purely convention, and could be named any other valid variable name. The special functionality comes from the single and double asterisks (*). If both are used in a function signature, *args must appear before **kwargs.
Single asterisk
*args will ingest an arbitrary amount of positional arguments, and store it in a tuple. If there are parameters after *args in the parameter list with no default value, they will become required keyword arguments by default.
Double asterisk
**kwargs will ingest an arbitrary amount of keyword arguments, and store it in a dictionary. There can be no additional parameters after **kwargs in the parameter list.
Use cases
β’ Decorators (see !tags decorators)
β’ Inheritance (overriding methods)
β’ Future proofing (in the case of the first two bullet points, if the parameters change, your code won't break)
β’ Flexibility (writing functions that behave like dict() or print())
See !tags positional-keyword for information about positional and keyword arguments
just realised this isn't #bot-commands
I was gonna say
which issues can i start working on? most issues don't have up-for-grabs so if the author has not said that they are working on it can i work on it? i want to start contributing but dont know which issues i can start filtering out
Which repo?
bot
It doesn't need to say up for grabs. If it's open and approved you can request working on it.
If it's not clear if it's approved but it interests you, request anyway and we'll tell you if it can be worked on
Given it's not assigned already of course
If you're looking at sir-lancebot after all, then it should say approved and that the author doesn't mind others working on it (the checkmark at the end of the issue description)
Kind of a random question, but why does #dev-voice have a 99 member limit? I just don't understand the point of that
You cant see how many people are in a vc without a user limit
Ok I see. But do we need to see how many people are in a vc in this case?
It's also pretty healthy to have a limit, even if it isn't used
Sometimes #voice-chat-text-0's limit is close to being hit, and that's when you start to go "Ah, let's separate"
@clever wraith I left some suggestions, you should just be able to commit those without dealing with your editor.
Other than that, it works nicely
Makes sense ig
Question to the audience:
If I gave you the following instructions for the Python bot config: https://gist.github.com/mbaruh/4398f6fba9ef5a1c208bb8a4f2e809a9
Along with the test server template: https://discord.new/zmHtscpYN9E3
Do you think this would make it easier for you to set up the bot?
I think you should remove the IDs that should be replace. But some invalid character so that the editor will complain
That will make it obvious from a contributors perspective thanks to their editor what needs changing
Yeah that's possible
On the other hand, this means the bot won't run until you have setup everything, so use that sparingly (maybe not for channels for example)
Maybe a bunch of β‘ in places that need to be changed
The issue is that for example Pycharm won't really complain about yaml errors
The only thing I found that makes it mark a line with red is an invalid anchor reference
Would <> even be invalid yaml?
I don't think so, but it doesn't make pycharm complain
Like if I did voice-verification: &DEV_VOICE_VER <replace with channel id> then yaml wouldn't error, it would make it a string
yeah
If you add for example *lskjaghlksaj instead
it will error
Because there is no anchor with that name
I feel like it would be easier to pre-fill all the places that need changing with a defined char
So we can just say, change all places with this char
And say you can ctrl+f to find places you missed
Any funky char you have in mind?
This one?
π€
\u25a1 : WHITE SQUARE - β‘
Maybe οΏ½
That would be better
!charinfo οΏ½
\ufffd : REPLACEMENT CHARACTER - οΏ½
name checks out
Lol yea
That's good
I'm more hoping for this to be a temp measure
Is there an issue for having the bot auto-detecting the channels at least?
Actually would need to be in constants.py but yea
Until we get the auto config stuff going
Yea that's what we're gonna do with auto config
I feel like since we know the bot template, we an have the bot match channels by name?
This is a stop gap
yeah
It should be pretty easy to iterate through the channels when an incomplete config is found
It should, but at that point I'd rather whoever does it work on the app we want to make
Yeah true
Ok, replaced it
That's great
I would maybe use multiple, because an ID is multiple characters (could become too much though). But that is a big improvement
@cold island I have one concern: trashcan: ":trashcan:
the trashcan specific emoji is pretty important and can result in unexplainable bugs since there's decorators, methods, paginator, etc that all use it
the paginator ceases to work with out it, and other commands will throw errors, or not throw them and silently fail-- it seems important enough to me that it should be documented that that emoji should be filled out
inversely, the config.py file could have a check for if the emoji there is in a server the bot is in and default to ποΈ if it doesn't π
Added οΏ½ to the emojis too
I don't understand though, why does one need to change the trashcan emoji?
It's a Discord emoji
Because the default emoji looks more like a basketball hoop than a trashcan
ποΈ
Lmao
!charinfo \u200b
You are not allowed to use that command here. Please use the #bot-commands channel instead.
@trail pilot Did you disable DMs by any chance? I can't DM you anymore for some reason
Ah
Says you're not accepting frs
Thx
What does everyone think of a bytecode command?
Gets information from the bytecode name
like
.bytecode LOAD_NAME
the docs should already handle that
they don't for some reason
!d LOAD_NAME
LOAD_NAME(namei)```
Pushes the value associated with `co_names[namei]` onto the stack.
LOAD_FAST(var_num)```
Pushes a reference to the local `co_varnames[var_num]` onto the stack.
I can't get sir-lancebot#860 to work, even after running docker-compose down to delete the containers
bs4 doesn't get installed
@patent pivot site#590 is open
... what?
coveralls api is under maintenance
@brisk brook lmao, you'd think I'd get the theme right 
Hm, did you just try poetry install itself?
Actually idek if thatβll fix it lol
Yay! After a week or two sir-lancebot#843 is about to be merged! (All checks have passed) Thank you to everyone who reviewed it!
To be exact, 2 weeks and 1 day
Haha
((it got merged now, yay!
I apologise but I just found a bug
What's the bug?
basically if i have an active game
it will still count messages in another channel
which seems not intentional
i mean
it does redirect the error message to #sir-lancebot-playground 
it's cause I do the on_message event for the user itself, not checking the hcannel too
I shouldn't need to do that though, Docker does it. Hmmm
But what happens when you have multiplayer mode?
You need to add --build to your compose command
So that it rebuilds the image
Ah, alright
We have a volume setup so that code changes don't need a rebuild
But any changes to the dockerfile, or the deps need a rebuild
Anyone with some HTML/JS knowledge wants to help me for like 10 minutes?
and django templates
I don't know too much about it, but may be able to do something π . What issue/PR is this about?
Actually have to go for a while, will come back later
Hey everyone, so I have coded one of the issues for Sirlancebot an anagram command, and when i tried running flake8 it showed a lot of errors for lot of files which i hadnt worked on, i made sure that my file is in accordance with the guidelines
Other files having issues shouldn't be a problem right ?
Can you open an issue first about this command so that it can get fully approved before you spend more time on it?
issue is already present
Can you give me one example of a line and the error it causes?
i already commented on the issue i would like to work on it, it has already been approved, i dont think its assigned to me yet
Ah, I see your comment now! Great
Ah, Isort. Python Discord has a bit different style guide than Isort follows.
I can help you setup flake8 in your editor so that you get red squiggly lines, that way it's easier to ignore those Isort errors.
Press Ctrl + Shift + P (that will open the command pallette). Then type "Select linter".
That should give you "Python: Select Linter". After selecting that you'll get a menu with different linters, there you can select "flake8" and it should be set up.
Oh, was doing "flake8 anagrams.py" the wrong way to do that
Not at all, that works too. Personally I prefer to have it in my editor but doing it like that should work nicely as well!
i did that i can see the squiggly lines now
You can hover over those and get the error flake8 says, as well as there being a Problems tab where console it where you can read them.
all flake8 errors are resolved, but isort is complaining about some issues
I don't think lancebot uses isort, make sure to run with the right flake8
im not sure what im supposed to do here, it just says in wrong order ? any ideas i tried running isort anagram.py it spit out some error
I think Colours comes before negative replies from bot.constants
Huh, it popped up 2 more issues, 2 for wrong position and one unexpected missing import, it would be really helpful if it said what position would be correct and what was missing
Your imports are in the wrong order
The order should be```
builtin libraries
external libraries
project modules```
You currently have an external library under the project modules
And then it's alphabetical within those sections (capital coming before lowercase) so Colours and NEGATIVE_REPLIES need to be switched
If you were using PyCharm it has a button which sorts all the imports for you (don't know if VSC has this)
i switched these i saw some documentation in isort, could you point me in direction on how to differentiate which libraries are which builtin, external or project
VSC has something like this but the imports were already sorted through the VSC, dont think it worked the way it was supposed to
Builtin = in stdlib (comes with Python)
External = installed with pip
Project = any file made in the project that you import (e.g. the from bot.bot import Bot)
That did it, its resolved
You can find all the stdlib libraries here btw https://docs.python.org/3/library/
Any objections to sir-lancebot#871? I would like to get hangman loaded back into the bot
Do I need some form of approval for this?
You can go for it @brisk brook
Alright!
Guys, so I just committed my code to my repo which I forked and I had configured precommit so I think its all good, how does one go about creating a PR ?
Check out the main page of your fork on GitHub, it should show you a button to create a PR from that branch
GitHub has a picture guide on this
Does someone need to assign the issue to me to proceed with this ?
We require that you have the issue assigned to you to avoid confusion, and two people doing the same work. You technically don't need that to open the PR, but it's part of our contributing rules
I commented a week ago on this issue, it was unassigned from the last person, I don't think anyone was working on it
Usually, we get around to assignments quicker than that, if it happens again, feel free to bump the issue π
Nah no problem ! I thought there would be more important things going on than game commands so it was on hold
Added 2 files
anagram.py - Has the code for anagram command
anagram.json - Contains all the words for anagram command
## Relevant Issues
<!--
It is mandatory to link to an issue that has been approved by a Core Developer, indicated by an "approved" label.
Issues can be skipped with explicit core dev approval, but you have to link the discussion.
-->
<!-- Link the issue by typing: "Closes #<number>" (Closes #0 to close issue 0 for example). -->
## Description
<!-- Describe what changes you made, and how you've implemented them. -->
## Did you:
<!-- These are required when contributing. -->
<!-- Replace [ ] with [x] to mark items as done. -->
- [x] Join the [**Python Discord Community**](https://discord.gg/python)?
- [x] Read all the comments in this template?
- [x] Ensure there is an issue open, or link relevant discord discussions?
- [x] Read and agree to the [contributing guidelines](https://pythondiscord.com/pages/contributing/contributing-guidelines/)?
So this block, can someone guide me through this I had some questions about this
Anything in particular?
Do i need to remove all the <!-- from the block > ?
They're comments, so they won't show up in the end product
So it's up to you
(You can also see what the end product will look like in the preview tab)
Oh didnt notice that before, that will cover all my doubts !
I just created the PR sir-lancebot#874 , do I need to notify anyone for review or its automated workflow
If you have anyone in particular you think should be reviewing this (for instance they said they will, or it's related to other work they are doing), you can ping them on the issue
Otherwise
People look through all the open PRs for things that need reviewing
So now, your next step is to kick back and relax while the reviews come in
yay my first PR to an actual open source project ! I originally wanted to work on Hangman but when I started to work on that and looked at issue it was assigned and someone already had coded that
Where can I find on the site repo the code for the top bar with all the buttons?
Ah found it
Ok, looking for help with CSS and/or JS in django templates
I must be missing something simple
Basically I want to have an element that can be collapsed.
Bulma has a bulma-collapsible extension that should make it painless https://bulma-collapsible.netlify.app/usage/#collapsible-card
But if I dump this code into one of the pages on the site, it appears collapsed but the action of expanding it doesn't work (made sure that the extension is loaded).
So I tried to tinker with more "self-reliant" code. So I tried to add parts of this to see what would happen https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_collapsible_animate
It works when I place it in its own file, but when I place it into one of our pages the page is blank. It appears again when I remove the styling
If I try to only take the JS from the second link, basically the same thing happens as in the first instance
I've found that with django templates, it's never simple
Appears collapsed, because that's the styling, but the button doesn't work
Yeah, unfortunately every single page is loaded via templates for the navbar at the top
Can you also share the template you're editing?
I'm not editing a template
It's inserted into a template automatically
This makes the content of your HTML/MD under the site navbar
My best guess is the styles are being applied in a larger scope than you're intending
If you can share the page or the product html, I may be able to give more helpful advice
For the sake of the demo I took the bot guides and changed them to: https://paste.pythondiscord.com/pezadozilo.md
The style works, the JS doesn't
This is the same JS from the w3 link which I confirmed to be working in a standalone page
Alternatively making the bulma-collapsible snippet linked work will be even better
@brisk brook Should I make a new PR to fix the messages in all channels thing
And only lock it to a channel
and remove multiplayer?
Ah wait, I just saw your issue
sir-lancebot#873
^^ important issue that reintroduces hangman but removes not checking the channel only
coveralls is still down?
Maybe itβs gone forever and we never have to worry about coverage again
I can only hope
@patent pivot is it possible to disable coveralls for now? just makes tests fail atm
I can probably make the check unenforced, yeah, I'm in the canteen right now though, so will be a bit
no rush
(Sorry for not catching these bugs earlier)
Also to be clear @trail pilot, this is not your fault. Don't worry about it. Your PR received so many reviews and during the whole window of it being opened nobody noticed, the blame can't be put on you
I suppose, I'll be more cautious in the future with bugs nevertheless
I'll trya nd test out some edge cases for .challengse
challenges
hey guys, I wanted to contribute to some open source projects. Do you guys have any projects that would be suitable for me to tackle? I have a pretty basic / intermediate level of understanding. I know recursion, some basic coding principles like OOP, etc. I also coded several full stack projects.
You haven't caused the bot to crash loop on start yet, so don't worry π
Someone referred me to here from the general thread
I can't even remember how I did it
Just the fallout π
I'm sure if you go searching enough in this channel you'll find it lol
Yeah we have several projects you can contribute to. @dusky shore is most likely the one you want to play around with, maybe adding a fun little game or interesting command to it!
Here are the current open issues (but you can open another one if you want to suggest something): https://github.com/python-discord/sir-lancebot/issues
Hey! Could someone take a look at sir-lancebot#857 ? π
Otherwise you can check @stable mountain for more issues: https://github.com/python-discord/bot/issues
Though that bot has more to do with managing the server, rather than fun games
It's on my list of things, I'll get to that soon
Do you guys do pair programming on prs?
Sure, depends on the person and if they are willing to work with each other
I think this is a copy paste from a sir lancebot decorator
]e
You can only use this command in the following channel(s): #878695047112040448, #878694844212592670, #878694948810137621, #878694991784972309, #476196062214750219, #310-release-stream, #bot-commands
Yeah I agree, this shouldn't show hidden channels
Itβs just a hard coded string
They're not deleted yet fwiw
Ah
I mean, someone wanna PR it?
If they arenβt deleted, idk what to tell you
Itβs just ID mentions
Its a closed source bot since it was just from @stable mountain, is it not?
It isnβt
It isnβt
Also definitely not a one line change
I basically rewrote half the docker file
It should be fairly simple, update a couple constants, but now that I think about it, it may be an environment variable
you missed the perfect opportunity for snekbot
I've updated the variable now
]e
You can only use this command in the following channel(s): #878695047112040448, #476196062214750219, #310-release-stream, #bot-commands
we'll bump snekbox to 3.10 on release, as soon as there is a docker image
Why⦠would we do that
@gritty wind @cold island since we talked about it earlier bot#1834
π π
FWIW @clever wraith I think this is what's causing issues with @slow bone too
π
Yknow, issues with modmail will never be fixed if they aren't reported upstream
this be why I'm making a PR π
lol
IG this is useful for you to know for your bot too, if you're not already doing this
You can also dm the modmail bot @hollow dagger to report a bug
I'm staff on kyb3r's modmail
conflict of interest eh?
my bot pushes to ghcr docker on every commit to main rn
yea, that's the way to do it
also will have support for pypi installation soon
as long as you're tagging with a commit hash too, so people can pin
forbiddenfruit :)
That seems like a very niche scenario thatβs not worth the infra hit
idk, i only merged someone else's pr to add which was probably taken from pydis workflows
lol
ours does iirc
yes
!e import forbiddenfruit
@fervent sage :warning: Your eval job has completed with return code 0.
[No output]
just modify the dict object with your own bitwise ops 
@vale ibex so right now I'm not waiting for the guild to be ready before loading anything, because for the most part, I've been skipping the cache when possible. Could you give some tracebacks from @stable mountain not having the member cache so I can try to plan for something which I can't particulary test for given I'm not on a huge guild? π
it's mostly just when doing get_member we assume if it's None, then that user isn't in the guild
when actually it could be that they're just not in the cache
ah
smh
so
tldr not something that affects me
since I've been fetching the user if it is none
Sure, that works
hmmm
how long does a guild.chunk() take?

if you were to int e it right now
i'm curious if that is worth the time that it takes to chunk the whole guild
!d discord.Guild.chunk
await chunk(*, cache=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Requests all members that belong to this guild. In order to use this, [`Intents.members()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Intents.members "discord.Intents.members") must be enabled.
This is a websocket operation and can be slow.
New in version 1.5.
import time
start = time.perf_counter()
await guild.chunk()
print(f"Took {time.perf_counter()-start} seconds")
!int e...
shhh let him figure it out
lol
oh he just did that elsewhere
yup, it's running lol
for pydis it may be useful but it does not seem particularly useful for a bot which mainly replies to users who just sent a message and are therefore mostly in the cache
This is a websocket operation and can be slow.
It's not wrong
still running lol
50 people or so dm it a day
idk how many actually use the modmail here...
how many use modmail? π
!ping
69.226 ms
Healthy
100.671 ms
ok it's not killed the bot, it's doing it in the background
lol
22 today
async ^ tm
that's what await does
true
i think its actually a subprocess or a thread in this case
idk
oh
what's the server member count
!guild
Created: <t:1483877013:R>
Voice region: europe
Features: THREE_DAY_THREAD_ARCHIVE, WELCOME_SCREEN_ENABLED, INVITE_SPLASH, ANIMATED_ICON, PARTNERED, NEW_THREAD_PERMISSIONS, VIP_REGIONS, PREVIEW_ENABLED, THREADS_ENABLED, SEVEN_DAY_THREAD_ARCHIVE, MEMBER_VERIFICATION_GATE_ENABLED, NEWS, ROLE_ICONS, RELAY_ENABLED, COMMUNITY, DISCOVERABLE, VANITY_URL, PRIVATE_THREADS, BANNER
Roles: 88
Member status:
48,649
206,738
Helpers: 43
Moderation Team: 19
Admins: 12
Owners: 3
Contributors: 18
Leads: 11
Category: 30
News: 8
Staff: 63
Stage_Voice: 2
Text: 122
Voice: 9
A lot
255,387
well uh
please ping me when its done π
!remind 15m chunking done yet?
Your reminder will arrive on <t:1671484017:F>!
related
bot#1834 -- don't merge yet. Because of how long it takes, it could have problems with where that event is waited for. In addition, that event is called every time this guild comes up after an outage. This could be problematic because it would be calling await guild.chunk() multiple times while the other ones are still running. I think this pr could be a major source of problems and should be investigated further
luckily within d.py it checks if there's a request already for the given guild id
but yea, I think depending on how long it takes, this might not be the way to go
we might need to do a get_or_fetch approach
discord/guild.py lines 884 to 886
@property
def chunked(self) -> bool:
""":class:`βbool`β: Returns a boolean indicating if the guild is "chunked".```
await guild.chunk() doesn't actually check this property i believe
yeah, doesn't seem to be checking that variable
discord/state.py lines 1051 to 1060
async def chunk_guild(self, guild, *, wait=True, cache=None):
cache = cache or self.member_cache_flags.joined
request = self._chunk_requests.get(guild.id)
if request is None:
self._chunk_requests[guild.id] = request = ChunkRequest(guild.id, self.loop, self._get_guild, cache=cache)
await self.chunker(guild.id, nonce=request.nonce)
if wait:
return await request.wait()
return request.get_future()```
yea
that will run if there is not a request.
yea, so it won't duplicate chunk requests
however there's guild.chunked which checks if the list is the same
if there is already one for that guild id
I was referring to your point of
This could be problematic because it would be calling await guild.chunk() multiple times while the other ones are still running
ah, I moved past that π
if the guild is already chunked, I do not see code in state that checks if the guild is already chunked
which would be as simple as if not guild.chunked:
Ah right, we do that within our on guild available
since we set a _guild_available flag
is the chunker still running?
no, so the idea is once the chunker finishes, we would set that flag
so if the event fires again while the bot is still running, we won't re-chunk
er, the int e command, has it finished yet?
but since the fact that this chunk still hasn't finished, I don't think we're gonna go with this approach anyway
@fervent sage ^
Yea, I've been running ```py
import time
start = time.perf_counter()
await guild.chunk()
print(f"Took {time.perf_counter()-start} seconds")
in another channel
Since
!sf 889254608852094996
889254608852094996
Created at 2021-09-19 21:00:20.302000 (<t:1632085220:R>).
lmao
unless I'm doing something stupid
!int e print(guild.chunked)
In [9]: print(guild.chunked)
False```
discord/guild.py lines 894 to 897
count = getattr(self, '_member_count', None)
if count is None:
return False
return count == len(self._members)```
curious how off they are
since that is likely to always be false on a guild this big
!server
Created: <t:1483877013:R>
Voice region: europe
Features: THREE_DAY_THREAD_ARCHIVE, WELCOME_SCREEN_ENABLED, INVITE_SPLASH, ANIMATED_ICON, PARTNERED, NEW_THREAD_PERMISSIONS, VIP_REGIONS, PREVIEW_ENABLED, THREADS_ENABLED, SEVEN_DAY_THREAD_ARCHIVE, MEMBER_VERIFICATION_GATE_ENABLED, NEWS, ROLE_ICONS, RELAY_ENABLED, COMMUNITY, DISCOVERABLE, VANITY_URL, PRIVATE_THREADS, BANNER
Roles: 88
Member status:
46,840
208,553
Helpers: 43
Moderation Team: 19
Admins: 12
Owners: 3
Contributors: 18
Leads: 11
Category: 30
News: 8
Staff: 63
Stage_Voice: 2
Text: 122
Voice: 9
print(len(guild._members))
print(getattr(guild, '_member_count', None))
π₯Ί
!int e ```py
print(len(guild._members))
print(getattr(guild, '_member_count', None))
In [10]: print(len(guild._members))
...: print(getattr(guild, '_member_count', None))
...:
8241
255392```
lol
hang on jesus christ i've just looked at the chunking code for discord.py
its uh
a mess
dude the chunk request code is something
but it doesnt look efficient
so only 8k of us are in cache
this is probably entirely not feasible
do we have a bot in here that can be quickly tested with something
@brisk belfry?
depends on the test lol
^
I want to try explicitly enabling the chunk_guilds_at_startup=True in the bot's constructor
i think its called that
hmmmm
chunk_guilds_at_startup (bool)
indicates if on_ready() should be delayed to chunk all guilds at start-up if necessary. This operation is incredibly slow for large amounts of guilds. The default is True if Intents.members is True.
!d discord.Client
class discord.Client(*, loop=None, **options)```
Represents a client connection that connects to Discord. This class is used to interact with the Discord WebSocket and API.
A number of options can be passed to the [`Client`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Client "discord.Client").
I have chunk_guilds_at_startup enabled for GTA Online's bots, and they are online within about ~5 seconds of running the file
try:
chunk_guilds = options['fetch_offline_members']
except KeyError:
chunk_guilds = options.get('chunk_guilds_at_startup', intents.members)
this is in state.ConnectionState
they renamed it and wanted backwards compat iirc
yea, so if it's not explicitly set, it'll use the member intent anyway
hmmm
This has its issues, for example keeping up to date with users who joined/left while the bot was down
just have a task that continually runs chunking, ez /s
frankly what I'd say at this point is just accept that state is not something that can be handled at this scale with the discord api and make resilient commands
or better yet don't rely on the member cache-- if a user isn't in the member cache ^^ then fetch them
they get added to the cache anyhow if using bot.fetch_member/user
yea, probably just gonna do get_or_fetch everywhere
though, again, i find it really really strange we're having this issue here, since on a server with 100K more members all works fine

I wonder
!raw 563594791770914816-889254608852094996
== Raw message ==
!int e `β`β`βpy
import time
start = time.perf_counter()
await guild.chunk()
print(f"Took {time.perf_counter()-start} seconds")
`β`β`β
this isn't broken right?
@fervent sage can you int e these on the gta bots?
i wonder if its actually caching the entire server
the only thing i can imagine affecting it is stuff like RELAY_ENABLED stuff in guild features, but relay is a message and event distribution thing, it should affect members
and discord even said that they don't use that anymore 
If you want to toss it into a bot here, could try 3.10
Not critical and will auto deploy
But like to do that youβd have to do it now cuz I need to approve before I sleep
That command is just jishaku tho right?
jishaku shouldnt modify anything that would affect the output of that
lol
smh
yea, I was more referring to arl possibly wondering what that syntax was
arthur jsk py ```py
(len(_guild._members),
getattr(_guild, "_member_count", None))
(7, 255040)
i copied the message from here then modified it until it was jishaku compatible 
what in the fucking world
no member intent lol
ah..... okay.
@stable mountain is the only one with member intent afaik
don't think @radiant merlin has it yet
may be wrong
so the 7 users are the 7 users who interacted with the bot
wouldnt @viscid badge have it too
yah
this is true
and @slow bone
arthur
arthur doesn't lol
arthur help
that should have cached me lol
yeah same here
even just saying arthur
if you need me to look at things on gtao and see if they line up please ping me, its fun to solve scaling issues 
I'm guessing if you run this, it doesn't finish in 3s lol
or does it?
if it does, then this is a discord problem probably lmao
Since it's still running in Python
no it makes the bot cry and stop responding to gateway heartbeats
lol
did I mention I'm building a whole api to my modmail bot so ppl can add stuff to all features? π eg you could add a stats counter to modmail and get all of the info for metricity
offtopic flex
nice
So ooi, what do you do to ensure the member cache is populated?
or is gtao not in d.py?
It's running dpy2.0
hmmm
does that change things?
hm actually
lester may still be on 1.7.3
please
yeah its still on 1.7.3
damn
Big Changes
- Performance of the library has improved significantly (all times with 1 process and 1 AutoShardedBot):
- 735 guilds boot up time (with chunking): 57s/1.7 GiB RAM -> 42s/1.4 GiB RAM
- 27k guilds boot up time (with chunking): 477s/8 GiB RAM -> 303s/7.2 GiB RAM
- 48k guilds boot up time (without chunking): 109s -> 67s
- 106k guilds boot up time (without chunking): 3300s -> 3090s
thats guilds not members per guild btw
I mean we're way beyond those times already, for 1 guild
so not representative of our issue
hang on
what I can do is boot up a test bot on gtao using dpy2.0
see how that changes things
There's a decent chance there's a bug in there
Especially since dpy2.0 was never officially released
...
what even is this https://github.com/python-discord/sir-lancebot/commit/3f90389d76b4666868cbb24e7958d5cf236207c5
@stable mountain is still on 1.7.3
Mostly so it appears in the member list
π
not necessary but w/e
hell, for a while, bots on gateway v7 and so forth were getting thread events when they weren't supposed to
I have a feeling all bots + all threads events is not likely to remain the case in the future
!int e print(bot.is_ws_ratelimited())
In [11]: print(bot.is_ws_ratelimited())
False```
π€
wdym
because of the changes to get us off the gateways?
Discord will limit thread events so bots not in the thread won't see them for one reason or another, perhaps behind another intents change
Pure speculation but it's a very low hanging performance fruit for them
true
i mean, python is on 1.7.3 right now, yet takes 20 minutes to chunk
er, 30 minutes, I don't think its stopped yet
dpy 1.7.3 on top, 2.0 on bottom
!snf 889254608852094996
You are not allowed to use that command here. Please use the #bot-commands channel instead.
!snf 889254608852094996
889254608852094996
Created at 2021-09-19 21:00:20.302000 (<t:1632085220:R>).
47 minutes ago sheesh
lmao I just realised, I only asked you to run that for information which is useful towards modmail π
hmmm, I wonder what's causing @stable mountain's caches not to be populated then
at this point im just gonna attribute it to "discord randomly hates pydis" since other things have broken just here too
bot/bot.py line 203
_intents = discord.Intents.default() # Default is all intents except for privileged ones (Members, Presences, ...)```
I wonder if it's because the MemberCacheFlags are inferred from intents
TBH I wonder if this has to do with https://github.com/python-discord/bot/blob/ec8e3e3f69e9c9b938929efece487b229fc1dd9c/bot/bot.py#L47-L48
bot/bot.py lines 47 to 48
self._connector = None
self._resolver = None```
Is it typing events 2: electric bugaloo type of scenario?
and we disable some intents
the fact that the bot is making its own connector... i wonder if that has any cause
those get set on login
!int e print(bot._get_state()._chunk_requests)
In [12]: print(bot._get_state()._chunk_requests)
{}```
π€
i think its worth trying to test those since they're different from the one's that alec is using
could you run this again?
It's possible that we sent a chunk request and discord simply hasn't responded to it
we're on 1.7.3 still?
Getting a 422 error from github trying to resolve this convo

