krishsharma0413 / DiscordLevelingCard

A library with leveling cards for your discord bot.
MIT License
45 stars 6 forks source link

Crashing without error #15

Closed Melmacker closed 7 months ago

Melmacker commented 7 months ago

Since I switched to a new host and installed the newest version through pip it crashes when using the following: image = await card.card1() or image = await card.card2() or image = await card.card3() The problem Im facing now is that I can not even debug the issue because it also crashes in debug mode without any error or warning. After a week of trying and no results I hope someone here can help me.

krishsharma411 commented 7 months ago

I tried using the library myself and it seems to work for me. can you give me some reproducible code. where exactly are you using the library?

Melmacker commented 7 months ago

Sry for my late reply I refreshed my browser every day but it didnt show your comment. Below you can see the image Im using: background

import discord
from discord.ext import commands
from DiscordLevelingCard import RankCard, Settings

bot = commands.Bot(command_prefix="/", intents=discord.Intents.all())

@bot.event
async def on_ready():
    await bot.tree.sync()

@bot.tree.command(name="level", description="Shows you your level")
async def level(interaction:discord.Interaction):
    await interaction.response.defer(thinking=True)
    level = 1
    xp = 0
    maxxp = 100
    card_tpye = 1
    card_settings = Settings(
        background="C:/Users/Administrator/Documents/background.png",
        text_color="#FFFFFF",
        bar_color="#FFFFFF",
        background_color="#36393F"
    )

    card = RankCard(
        settings=card_settings,
        avatar=interaction.user.display_avatar.url,
        level=level,
        current_exp=xp,
        max_exp=maxxp,
        username=interaction.user.display_name
    )
    if card_tpye == 1:
        image = await card.card1()
    elif card_tpye == 2:
        image = await card.card2()
    elif card_tpye == 3:
        image = await card.card3()
    await interaction.followup.send(file=discord.File(image, filename="rank.png"))

bot.run("TOKEN")
krishsharma0413 commented 7 months ago

since you said that you are using a host then it somewhat makes sense that the line background="C:/Users/Administrator/Documents/background.png", won't actually work. try giving it a relative path than the absolute path and save the background image in your project folder.

If the error still persists then please do let me know

Melmacker commented 7 months ago

It still crashes. I also have other resources that I use in the documents folder, which all can be found.

krishsharma0413 commented 7 months ago

try running the code on your local laptop/PC and check if the error still exists. I still don't truly understand the error since the library works properly for me. It could be a version mismatch as well (library is created for 3.9x and not for anything >3.10). There isn't an error message which is weird as well.

Melmacker commented 7 months ago

Thank you. It was a version mismatch, I used 3.12 on the new host machine and it works now after I switched back to 3.9. Could you please add a quick version check with an error message to it?

Keep up the amazing work :D

krishsharma0413 commented 7 months ago

I will definitely add the version check. If you have any other feature you want me to add or implement please do tell.

Thank you!