I have some interaction that returns an ephemeral message with components. From those components, I want to be able to reply with a non ephemeral message (replacing the ephemeral message). I know it used to be possible, because many times while I was coding my application, I forgot to set the options flag in some replies, and that made the message turns to visible for all. But now, when I try to reply with a message without specifying the flag, it doesn't change and still display the reply in a ephemeral message.
I have heard that Discord added a new parameter about ephemerality in the interaction format to have a proper support. I think my issue is linked to that, and even tho flags options still work, I must use that parameter for my needs. However, the documentation is not updated yet.
Is it still possible to do that, and is there somewhere I can find information about the said parameter?
You cannot change a reply from ephemeral to public. A suggestion I have would be to simply follow up with a new message. If you are trying to make it public to ephemeral, you can delete the original reply. You can't however do it the other way around, since the user has to manually delete it
interaction.reply({
content: "ephemeral message",
ephemeral: true
}
// you can use any event, but I am using setTimeout
setTimeout(() => {
// interaction.deleteReply() --- only use if it starts out public
interaction.followUp({
content: "public message",
ephemeral: false
})
}, 3000)
Related
I am currently writing a Discord bot.
If it doesn't exist, it is supposed to create a thread in a given channel and write some messages there.
My current way of checking is
private SocketThreadChannel ThreadIfExists(string id, SocketGuildChannel channel)
{
return Context.Guild.ThreadChannels.Where(t => t.ParentChannel == channel)
.FirstOrDefault(t => t.Name.Contains(id));
}
where id is a unique id given to each thread.
Most of the time, it works fine; if the thread doesn't exist, the function returns null, and I can create the thread myself later, and if it does, it just gets returned to me.
My problem is that if I manually delete one of said threads in discord later, the bot has them saved in cache, and it will still try to write in an unexistent thread.
The only function I could find to refresh the cache is Context.Client.PurgeChannelCache();, but it throws Object reference not set to an instance of an object, even if I check the client for null.
Restarting the bot does fix it, but that's clearly not viable after it gets released.
Is there something else I could try?
For now, I have just made a workaround with a try/catch, where I check if sending the message throws an Unknown Channel error and force the creation once again.
I am pretty sure that this is one of the worst ways of doing it, but it does work, I guess
Do we have a way to differentiate between a dismissed ephemeral message and a non-dismissed one In discord?
do we have a special property in the message object ? some API to fetch this info ?
There is no possible way to get ephemeral messages.
I ended up by removing all the content of last message so the user won't give a big attention and simply will dismiss it by clicking or ignore it.
This is my code
activity=discord.Game(name="Padamine", type=1)
Don’t worry, I put it in a #bot.event function. The problem is that my bot don’t put the custom status in his status. Can you help me?
Use change_presence() method to change bot status:
await bot.change_presence(activity=discord.Game("Padamine"))
If it's a static status (a status that won't change), it is recommended to use the activity keyword argument inside the bot constructor. If you want to make a dynamic status (a status that changes every now and then), use #tasks.loop of discord.ext.tasks (you can find more about tasks here)
# depending on what you name your variable, client/bot
client/bot = commands.Bot(command_prefix="yourprefix", activity=discord.Game("Padamine")) # removed type because there is no such key word argument
Also, it is recommended to not use await bot.change_presence() inside your on_ready event, I am mentioning this because many people do it and it's not good:
Discord has a high chance to completely disconnect you during the READY or GUILD_CREATE events (1006 close code) and there is nothing you can do to prevent it. As noted in the docs, on_ready is also triggered multiple times, not just once.
Basically: don't do anything in on_ready. (except printing that it came online obviously)
I have been trying to make a quick bot for a friend, however I have come across something I cant fix. Whenever I try to access the member from the message it returns null. I am trying to find the users roles so I can check if they have a certain one.
The root of this problem that member is null inside the message. Therefor I cannot read from a null value.
client.on('message', message => {
This is how I am declaring message, and here is a console log of message. https://pastebin.com/vrdg9Wvu
So please can someone help me find a way to compare the command users roles.
Which version of dicord.js are you using?
I don't know where this may come from, maybe if the user who sent the message has left the guild while sending, otherwise I don't know what's wrong. If it's still not working, consider using message.guild.members.cache.get(message.author.id).then(user => {}), that may work.
I know you can detect the addition of a new reaction but using a ReactionCollector. But is it possible to detect the removal of a reaction?
I know i could keeping track of all reactions in a DB, and continuously poll the discord api and compare the DB version to the live version. But I'd rather not do this if there's a better solution out there.
Yes, the discord.js API has an event you can listen for: messageReactionRemove. You have to maintain a message cache, because it only fires for messages in your cache. You fill out your cache using fetchMessages.
You can make a event for this, called 'messageReactionRemove' to see if someone removes a reaction.
This is a simple example for a reaction role bot i have:
const events = {
MESSAGE_REACTION_REMOVE: 'messageReactionRemove',
};
Then you can make for instance an if statement, and ask for the MESSAGE_REACTION_REMOVE
if (event.t === "MESSAGE_REACTION_REMOVE") member.addRole(guildRole.id);