実現したいこと
- PythonでDiscordのコマンドに反応するプログラムを書きたい
内容
PythonでDiscordのコマンドに反応するプログラムを書いています。
実行しようとしたら以下のエラーが出ました。
エラーメッセージ
Traceback (most recent call last): File "C:\Pytho\mikan.py", line 6, in <module> from discord_slash import SlashCommand, SlashContext ModuleNotFoundError: No module named 'discord_slash'
該当のソースコード
Python
1import discord 2import asyncio 3import random 4from discord.ext import tasks 5from discord.ext import commands 6from discord_slash import SlashCommand, SlashContext 7import os 8 9bot = discord.Client(intents_discord.Intents.all()) 10slash_client = SlashCommand(bot, sync_commands=True) 11client = discord.Client() 12TOKEN = '-トークン-' 13 14@client.event 15async def on_ready(): 16 print('HelloWorld') 17 18@client.event 19async def on_message(message): 20 if message.author == client.user: 21 return 22 23 if message.content.startswith('$hello'): 24 await message.channel.send('Hello!') 25 26@slash_client.slash(name="botsay", description="bot") 27 await ctx.send(content="こんにちは") 28 29 30client.run(TOKEN)
試したこと
モジュール名をpip installのときの名前にしてみましたがハイフンでエラーが出てダメでした。
補足情報
DiscordBotはすべての権限を付けています。
実行したものは
pip install discord-py-interactions
pip install discord
です。
このサイトでの質問が初めてなのでテンプレートに頼りっきりで変なところがあるかもしれませんがよろしくおねがいします。

回答1件
あなたの回答
tips
プレビュー
下記のような回答は推奨されていません。
このような回答には修正を依頼しましょう。
また依頼した内容が修正された場合は、修正依頼を取り消すようにしましょう。
2023/05/11 21:45
2023/05/11 22:23