A
A
ArtemPaw2020-09-13 08:35:23
Python
ArtemPaw, 2020-09-13 08:35:23

How to make a system of achievements with pictures, auto-assignment of a role and mini-games like "Guess the number" in a Python discord bot?

I have a discord bot which I made using the guides of one youtuber, but the youtuber made a bot without a function, and I wanted to make it functional, but I didn’t find youtubers doing a normal explanation of functions and events. Can you please give me events/codes for the functionality of the bot? (Which functions are said at the top).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2020-09-13
@ArtemPaw

Personally, I implemented all this by entering certain commands into the chat. It can be done like this. Let's say you write a certain command to the chat, for example "/start-game". The bot reads this and performs your function on the game itself.
Statistics can be stored using the sqlite3 standard library , and when certain parameters are reached, issue an achievement.
Pictures can be sent like this:

image = Image.open('your\\path\\to\\image.jpg') # открытие картинки
with io.BytesIO() as image_binary:
    # перевод картинки в байтовый формат
    image.save(image_binary, format="JPEG", quality=95) 
    image_binary.seek(0)
    # отправка картинки
    await channel.send(file=discord.File(fp=image_binary, filename="image.jpeg"))

It uses PIL.Image to open and work with images, and io.BytesIO to convert the image to byte format to send the image in a message.
To understand how roles work, I advise you to watch this video: https://youtu.be/87_3zcv8q5I
And finally, I’ll say that you need to get used to reading the documentation - you can’t do without it. Discord.py documentation: https://discordpy.readthedocs.io/en/latest/api.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question