Open eeropomell opened 8 months ago
I couldn't repro with the repro steps you provided. Can you provide additional repro steps to help us narrow this down?
Similar but not quite exact behavior for me with python 3.10 and pycord 2.4.1 using discord client Stable 256231 (96a39c5) Host 1.0.9028 x86 (41936) Windows 10 64-Bit (10.0.19045).
About 2 weeks ago using ctrl + v would work to paste images as attachments, but now it is being blocked as showcased by KuJu on discord api server.
Dragging the file in from a chrome browser window still works or selecting the file from explorer.
Code example that doesn't allow ctrl+v:
import discord
bot = discord.Bot(debug_guilds=[305380209366925312])
@bot.event
async def on_ready():
print(f"{bot.user} is online!")
@bot.slash_command(name="profile")
async def profile(ctx, attachment : discord.Attachment):
await ctx.respond("yo")
bot.run(token)
Description
I have a discord bot (discord.js) with a slash command that takes in an attachment option. Sometimes when I try to use the command and attach a file, the discord app acts as if no file has been attached.
The slash command is as simple as:
const { SlashCommandBuilder } = require('discord.js'); module.exports = { data: new SlashCommandBuilder() .setName('sdbattle_submit') .setDescription('submit!') .addAttachmentOption(option => option.setName('file') .setDescription('The file to upload') .setRequired(true)), async execute(interaction) { }, };
Intents:
const client = new Client({ intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.MessageContent, GatewayIntentBits.GuildPresences, GatewayIntentBits.GuildMembers] });
Interaction handling:
client.on(Events.InteractionCreate, async interaction => { if (!interaction.isChatInputCommand()) return; const command = interaction.client.commands.get(interaction.commandName); if (!command) { console.error(`No command matching ${interaction.commandName} was found.`); return; } try { await command.execute(interaction); } catch (error) { console.error(error); if (interaction.replied || interaction.deferred) { await interaction.followUp({ content: 'There was an error while executing this command!', ephemeral: true }); } else { await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true }); } } });
Versions
- Ubuntu 22.04 firefox
- stable 256231 (96a39c5)
- Node v21.5
Steps to Reproduce
Steps to reproduce:
- Create a Discordjs bot with a slash command builder that takes an attachment as an option:
.addAttachmentOption(option => option.setName('image').setDescription('The image file').setRequired(true))
- Call the slash command and try to paste a file into the image field
- Upon trying to send the message the attachment field will light up red and you will get an error saying "This option is required. Specify a value"
Expected Behavior
When selecting a file as an option to the slash command, the app should recognize that a file has been attached. Upon trying to call the command, the command should be sent to the bot.
Current Behavior
When trying to use a slash command that takes in an attachment option, the following bugs can occur:
- dragging and dropping a file into the selection doesn't attach it
- selecting a file from the file explorer attaches it, but when trying to send the command, the discord app acts as if no file has been attached. Gives the error "This option is required. Specify a value"
Screenshots/Videos
83ed85ad19def89300281443e540acab.mp4
Client and System Information
- Ubuntu 22.04 firefox
- discord.js 14.14.1
- Node v21.05
- stable 256231 (96a39c5)
I have similar issue. Funny thing is that Android app still works normally and adding attachments works. I think its an issue with web and desktop clients.
A similar issue happens for me too. It was the same for my bot as for OP, but a later update fixed it. But with the fix came a bug when trying to attach an image using CTRL+V. Dragging an image into the image field otherwise works, just not from the clipboard, but it's still an inconvenience. Issue has been ongoing for over a week, happens on two of our household computers:
https://github.com/discord/discord-api-docs/assets/141376657/26d9a58b-5cc2-445b-b3bc-8477049a4183
Using the following versions:
Also on a bot written with Discordjs, contacted their developers, they said that it's a Discord sided problem
Please keep this issue discussion related to the original post. If you're experiencing a different issue, feel free to open a new issue.
I couldn't repro with the repro steps you provided. Can you provide additional repro steps to help us narrow this down?
Issue seems to be happening only on forum channel threads (did not checked standard threads). Attached two videos showing the same exact command executed on threads and normal channel.
Issue persist in web and desktop client.
Electron 22.3.26
Chromium 108.0.5359.215
Host 1.0.9030 x86 (42484)
Windows 10 64-Bit (10.0.22621)
No issue when using the slash command (both forum channel thread or standard channel) on Android client (tested on 210.10 app version)
.addSubcommand((subcommand) =>
subcommand
.setName("banner")
.setDescription("Edytuj banner")
.addAttachmentOption((option) =>
option
.setName("banner")
.setDescription(
"Nowy banner twojej kampanii w formacie graficznym webp, png, jpeg (zaleca się korzystać z ratio 3:2)"
)
.setRequired(true)
)
)
https://github.com/discord/discord-api-docs/assets/33233389/ad49510c-f07a-4b45-94ca-83b788e83d1c
https://github.com/discord/discord-api-docs/assets/33233389/e2fe8f33-9211-409c-a36d-05c1393ebef8
@appellation
I was able to pinpoint the exact condition when the error occurs - when a post is displayed in split view - forum on left, post content on right. When you display a post in a full view, slash command is working properly (bot was offline during the recording, but the client launched the slash command).
https://github.com/discord/discord-api-docs/assets/33233389/3c353fb0-263b-4f5d-9938-eb8d6f0cb812
Thanks for the detailed repro steps! I was able to repro; I'll look into a fix.
Any luck with the issue ?
I just ran into this as well. Same command works fine in public channel but not in a thread.
One additional data point if it helps... I tried removing the setRequired(true)
from my command to see if that would help. It still doesn't accept the file upload but it shows a different error. Instead of This option is required. Specify a value
it now says Not a valid value
.
Edit to add: Discord desktop client 0.0.294 macOS 13.4.1
SOLVED....
i had solved it in Python:
import discord from discord.ext import commands
intents = discord.Intents.default() intents.message_content = True # Enable message content intent
bot = commands.Bot(command_prefix='!', intents=intents)
BASICALLY we are missing intents.message_content = True # Enable message content intent
then it will work
thanks me LATER ....
Any luck with the issue ?
FIXED
Any luck with the issue ?
FIXED check my reply
Any luck with the issue ?
FIXED check my reply
Already using MessageContent intents, without it commands doesn't work at all.
// Edit: please share a video with your command successfully processing attachment while executed on forum thread in split view.
i am seeing the same issue. adding MessageContent intent did not help.
Description
I have a discord bot (discord.js) with a slash command that takes in an attachment option. Sometimes when I try to use the command and attach a file, the discord app acts as if no file has been attached.
The slash command is as simple as:
Intents:
Interaction handling:
Versions
Steps to Reproduce
Steps to reproduce:
Create a Discordjs bot with a slash command builder that takes an attachment as an option:
.addAttachmentOption(option => option.setName('image').setDescription('The image file').setRequired(true))
Call the slash command and try to paste a file into the image field
Upon trying to send the message the attachment field will light up red and you will get an error saying "This option is required. Specify a value"
Expected Behavior
When selecting a file as an option to the slash command, the app should recognize that a file has been attached. Upon trying to call the command, the command should be sent to the bot.
Current Behavior
When trying to use a slash command that takes in an attachment option, the following bugs can occur:
Screenshots/Videos
https://github.com/discord/discord-api-docs/assets/97628152/98fcaee9-5953-40d6-be6c-a6fc7af9c58d
Client and System Information