0

My code:

import nextcord
from nextcord.ext import commands
from nextcord import Interaction, VoiceChannel, Member
from nextcord.utils import get

from dotenv import load_dotenv
import os

import asyncpraw
import random
import asyncio

load_dotenv()

TOKEN = os.getenv('TOKEN')
CLIENT_ID = os.getenv('REDDIT_PERSONAL_USE_SCRIPT')
CLIENT_SECRET = os.getenv('REDDIT_SECRET')
REDDIT_PASSWORD = os.getenv('REDDIT_PASSWORD')

reddit = asyncpraw.Reddit(
    client_id=CLIENT_ID,
    client_secret=CLIENT_SECRET,
    password=REDDIT_PASSWORD,
    user_agent="idk",
    username="Itachi_my_fav",
)

intents = nextcord.Intents.default()
intents.message_content = True


bot = commands.Bot(command_prefix='-', intents=intents)
testingServerIDs = [846702055061454849]


@bot.event
async def on_ready():
    print('Bot is online!')


@bot.slash_command(name="ping", description="Check the latency of the bot.", guild_ids=testingServerIDs)
async def ping(interaction: Interaction):
    await interaction.response.send_message(f"Pong! {round(bot.latency*1000, 1)}ms")


@bot.slash_command(name="meme", description="get juicy memes from reddit", guild_ids=testingServerIDs)
async def meme(interaction: Interaction):
    subreddit = await reddit.subreddit("memes")
    all_subs = []
    async for submission in subreddit.hot(limit=200):
        all_subs.append(submission)
    random_sub = random.choice(all_subs)

    embed = nextcord.Embed(colour=None,
                           title=random_sub.title, type="rich").set_image(random_sub.url)

    await interaction.response.send_message(embed=embed)
bot.run(TOKEN)

Error:

Ignoring exception in command <nextcord.application_command.SlashApplicationCommand object at 0x000002715BEEC580>:
Traceback (most recent call last):
  File "C:\Users\Prisha\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\application_command.py", line 890, in invoke_callback_with_hooks
    await self(interaction, *args, **kwargs)
  File "D:\NISHIL\discord bot (JS)\main.py", line 57, in meme
    await interaction.response.send_message(embed=embed)
  File "C:\Users\Prisha\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\interactions.py", line 896, in send_message
    await adapter.create_interaction_response(
  File "C:\Users\Prisha\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\webhook\async_.py", line 190, in request
    raise NotFound(response, data)
nextcord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction   

The above exception was the direct cause of the following exception:

nextcord.errors.ApplicationInvokeError: Command raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction

I am trying to create a meme command using asyncpraw by fetching memes from reddit. Ii have no idea why this error occured and how to solve it. Is it because the embed is sent before the image is fetched? Or am i fetching the data in a wrong way? I am new to making discord bots so any help is appreciated.

Nishil Sheth
  • 155
  • 1
  • 10

0 Answers0