Yeah, I just read that error the “Discord Slash” isn’t something you can put in I believe. So if you remove it, and put in the code I send, it should work for you!
Sounds good, but I need an interaction. You know, that option that comes up after you select the slash command and you can enter text into it?
Also, learning to make the bot was not easy. There were no working online tutorials, the docs are quite vague, and I ended up asking a ton of questions in many places. Here is the Repl link. You can work off of that.
discord.py now supports interactions by default.
Instead of using @slash.slash, use @client.tree.command(name="", description="")
Put the on_ready() at the end of the file (or after you have declared all the commands anyways).
Try this, and see if it works
# Import various libraries.
import os, discord, urllib.request
from discord.ext import commands
# Set the token.
DISCORD_TOKEN = os.getenv("DISCORD_TOKEN")
# Define whatever this is.
intents = discord.Intents.default()
intents.message_content = True
client = commands.Bot(command_prefix='/', intents=intents)
# Message respondings.
@client.event
async def on_message(message):
print("message was: " + message.content)
if message.author == client.user:
return
if message.content == '!radar':
urllib.request.urlretrieve('https://radar.weather.gov/ridge/standard/CONUS_loop.gif', "rdr.gif")
await message.channel.send(file=discord.File('rdr.gif'))
#Commands
@client.tree.command(name="radar", description="Retrieves the live doppler radar for a station, if none given, gets CONUS.")
async def _space(ctx: discord.interactions.Interaction):
await ctx.response.send_message(file=discord.File('rdr.gif'))
@client.event
async def on_ready():
client.change_presence(status=discord.Status.online)
await client.tree.sync()
print(f'We have logged in as {client.user}')
# Command to start the bot.
def start():
client.run(DISCORD_TOKEN)
@client.event
async def on_ready():
client.change_presence(status=discord.Status.online)
print(f'We have logged in as {client.user}')
await client.tree.sync()