0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

[初心者向け]pythonでsayコマンドなどのやり方!

Last updated at Posted at 2020-02-26

#プログラム

say.py
import discord
from discord.ext import commands


token = "" #tokenを指定してね
client = commands.Bot(command_prefix="!") #prefixを設定(!の部分は好きに変えてね(例の場合は、!say <メッセージとなる>))
client.remove_command('help') #helpコマンドはいらないので削除

@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)

#終わり
多分これで行けるはず...(未確認)
このプログラムを使えば、!say <メッセージ>や、!channelsay <チャンネルid> <メッセージ>でメッセージを送信できる(はず)。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?