Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$roll conversion error #1

Open
celeste-42bit opened this issue May 22, 2024 · 1 comment
Open

$roll conversion error #1

celeste-42bit opened this issue May 22, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@celeste-42bit
Copy link
Owner

Parsing out all the numbers from the argument using re.findall(r'\d+', die) returns a list, which can't be converted into an integer with int().
I assume joining the characters together would return a String of numbers, which can be cast into an integer to then do the comparison later in the code.

async def roll(ctx, die: str, amount: int):
    number_characters = re.findall(r'\d+', die)

    if not number_characters or number_characters < 2:  # Comparison only works between congruent types!!! (Error: list < int)
        await ctx.send(f'"{die}" is not a valid dice.')
        return
@celeste-42bit celeste-42bit added the bug Something isn't working label May 22, 2024
@celeste-42bit celeste-42bit self-assigned this May 22, 2024
@celeste-42bit
Copy link
Owner Author

I fixed the issue by joining the list into a string of numbers and then casting that into an integer.
This led to another issue.

If the list is empty, int() will error out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant