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
py -3 -m pip install -U discord.py
Python await – https://pypi.org/project/await/
pip install await
Python async – https://pypi.org/project/async/
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
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 ')