[For beginners] How to use say command in python!

program

say.py


import discord
from discord.ext import commands


token = "" #Please specify the token
client = commands.Bot(command_prefix="!") #Set prefix(!Change the part to your liking(In the case of the example!say <Become a message>))
client.remove_command('help') #I don't need the help command, so delete it

@client.command()
async def say(ctx, *, message):
    await ctx.send(message)


@client.command()
async def channelsay(ctx, channelid, *, message):
    channel = await client.fetch_channel(channelid)
    await channel.send(message)


client.run(token)

the end

Maybe this should work ... (unconfirmed) With this program, you can (should) send a message with! Say or! Channelsay .

Recommended Posts

[For beginners] How to use say command in python!
How to use SQLite in Python
How to use Mysql in python
How to use ChemSpider in Python
How to use PubChem in Python
[Introduction to Python] How to use class in Python?
[python] How to use __command__, function explanation
[Python] Organizing how to use for statements
How to use __slots__ in Python class
How to use "deque" for Python data
How to use regular expressions in Python
How to use is and == in Python
[Introduction to Python] How to use the in operator in a for statement?
[For beginners] How to register a library created in Python in PyPI
How to use the C library in Python
How to receive command line arguments in Python
How to implement Discord Slash Command in Python
How to use Python Image Library in python3 series
Summary of how to use MNIST in Python
How to use data analysis tools for beginners
Try to calculate RPN in Python (for beginners)
How to use tkinter with python in pyenv
How to make Python faster for beginners [numpy]
python3: How to use bottle (2)
[Python] How to use list 1
How to use Python argparse
Python: How to use pydub
[Python] How to use checkio
How to develop in Python
~ Tips for beginners to Python ③ ~
[Python] How to use input ()
How to use Python lambda
[Python] How to use virtualenv
python3: How to use bottle (3)
python3: How to use bottle
How to use Python bytes
[BigQuery] How to use BigQuery API for Python -Table creation-
How to convert Python # type for Python super beginners: str
[For beginners] How to study Python3 data analysis exam
How to run python in virtual space (for MacOS)
I tried to summarize how to use pandas in python
How to use the model learned in Lobe in Python
Python # How to check type and type for super beginners
How to execute a command using subprocess in Python
Tips for those who are wondering how to use is and == in Python
[Python] How to do PCA in Python
Python: How to use async with
How to use classes in Theano
[Python] How to use Pandas Series
How to collect images in Python
How to use Requests (Python Library)
In the python command python points to python3.8
How to use MBDyn (command setting)
[Python] How to use list 3 Added
How to use OpenPose's Python API
How to wrap C in Python
How to use FTP with Python
Python: How to use pydub (playback)
Beginners use Python for web scraping (1)
How to use python zip function
Run unittests in Python (for beginners)