[PYTHON] Implement large size stamp function with discordBOT

Introduction

You can use the "emoji" function that is originally provided in discord to exchange images that you have prepared in advance. The emoji function has a problem that the image becomes too small, so I thought about solving it.

solution

Create a BOT that sends images in response to specific keywords, making it easy for users to share large images.

environment

Python 3.6.8 discord.py 1.2.5

Actual code

import discord

TOKEN = 'hoge'  #Enter the token assigned to your BOT

#Processing at startup
@client.event
async def on_ready():
    print('We have logged in as %s' % client)

#Processing to send a stamp when a message is received
@client.event
async def on_message(message):

    if message.author == client.user:
        return

    if message.content == '/img':  #Keywords that you want to trigger image output
        await message.channel.send(file=discord.File('img.png'))  #Image path to output

client.run(TOKEN)

If you want to prepare multiple stamps,


if message.content == '/img':
    await message.channel.send(file=discord.File('img.png'))

repeat.

Recommended Posts

Implement large size stamp function with discordBOT
Implement login function with django-allauth
Easily implement login authentication function with Laravel
Implement FReLU with tf.keras
A4 size with python-pptx