I way toying arround with Discord and Python because I wanted to record the messages and reactions of users.
Therefore I wrote a bot with the library discord.py My first attempts with Python…or let’s say a try and error session….
But in the end I was able toget the reactions and log messages.
below some good references and instructions and an example of my discord bot
Prerequisits:
Installation of Python 3.5<
Python Discord API – https://github.com/Rapptz/discord.py
1 |
py -3 -m pip install -U discord.py |
Python await – https://pypi.org/project/await/
1 |
pip install await |
Python async – https://pypi.org/project/async/
1 |
pip install async |
References:
Documentation
https://discordapp.com/developers/docs/intro
https://discordpy.readthedocs.io/en/latest/discord.html
https://discordpy.readthedocs.io/
Tutorial
https://realpython.com/how-to-make-a-discord-bot-python/
My own Bot
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
import discord from discord.ext import commands client = commands.Bot(command_prefix='.') @client.event async def on_ready(): #a = discord.utils.get(client.get_all_members(),name="Test-User", discriminator="9635").id #GetUserID print('Bot is ready.') """ crawl message @client.event async def on_message(message): if str(message.author) == 'Test-user#111': print(f'{message.content} RECEIVED!.') else: print(f'{message.content} wrong User!.') """ #get reaction an log it on another channel crawl message with some condition as an example @client.event async def on_reaction_add(reaction, user): channel = client.get_channel(6637461198) print(f'{reaction}') if str(reaction.message.author.id) == '579155970803': if str(user.id) != '57915597803': await channel.send('[{0.display_name}] - {0} has reacted with {1.emoji}!; ID = {1.message.id} '.format(user, reaction)) client.run(' some API-DiscordServer String here ') |