Is it possible to mention someone in an embed so that they receive a notification?
When I try this code:
message.channel.send({ embed: { fields: [
{
name: "test",
value: args[0]
}
]}});
with args[0] being a mention, the mention in the embed is well displayed (clickable, ...) but the user mentioned doesn't get pinged.
If I ping myself using the command (and mentioning myself in the argument) I'm not pinged and the message isn't displayed as usual when being mentioned (yellow background, ...) but I get my profile info if I click on the #... in the message.
Sadly you can't make a mention notify the mentioned user by using an Embed, a possible workaround is by having the mention in the message content, instead of the embed. For example:
message.channel.send(args[0], { embed: { fields: [
{
name: "test",
value: args[0]
}
]}});
This is a limitation of the Discord API itself.
Related
What I'm trying to achieve is simple:
send a message like links: [link1](https://example.com/1), [link1](https://example.com/2) via a bot
get it displayed as "links: link1, link1"
In a ephemeral follow up, it works as expected:
const content = "links: [link1](https://example.com/1), [link1](https://example.com/2)"
await interaction.followUp({
ephemeral: true,
content,
})
But when I send this to a public channel like this:
await channel.send(content)
I'm getting it as plain text (links: [link1](https://example.com/1), [link1](https://example.com/2)) except the links are clickable.
Is it possible to get the same result as in an ephemeral message?
I've checked the permissions, there's only "embed" links (which sounds like "allow links in embeds", and not "allow links in messages) and it is enabled anyway on server for everyone, for the bot and in the channel. So what am I missing here?
PS Here they say that "it's only possible if the message was sent with webhook though", but I'm not quite sure what does this mean (can this be different for a public and an ephemeral message?)
You cannot use hyper links in normal messages sent by a bot. You need to use a Webhook. Considering you're using discord.js, see this guide on their documentation. When using something like that it will work as expected
const { WebhookClient } = require('discord.js');
const webhookClient = new WebhookClient({ url: "WEBHOOK_URL" });
webhookClient.send({
content: "[Hello world](https://github.com)",
username: "Webhook Username",
});
Otherwise you may use embeds and send one of these with your bot and the content you wish to have.
Right, so I've found a solution based on suggestion by Krypton. As an embed doesn't look nice and manual creation of a webhook is not an option for me, I've found that I can create a webhook on the go and use it.
After some testing, I've figured that such webhooks are also permanent (although they can be found in another part of settings than the manually created ones); they should be deleted as there's a limit of 15 webhooks – an attempt to create more fails (with DiscordAPIError[30007]: Maximum number of webhooks reached (15)).
Instead of doing
await channel.send(content)
I've put
// a guard, TypeScript requires us to be sure
if(channel instanceof TextChannel) {
const webhook = await channel.createWebhook({
// a message from a webhook has a different sender, here we set its name,
// for instance the same as the name of our bot (likewise, we can set an avatar)
name: "MyBot",
})
await webhook.send(content)
await webhook.delete()
}
This seems to be a minimal code change to get the links working.
Is there anyway to make the selfbot response 'hello' if 'hi' is in someone message?
Like
A: hi? Anyone here?
The bot: hello
The bot response because 'hi' is in A's message.
I think it's not possible because i tried many Discord selfbot library and none of library work (Python)
Which library are you using?
I made a discord bot with discord.js (Javascript), and with that you can receive an event every time someone talks in your discord server and then respond depending on the contents of the message.
First you start your discord client (the Intents may vary depending on what you want to do):
const discordClient = new Client({ intents: [Intents.FLAGS.DIRECT_MESSAGES, Intents.FLAGS.GUILD_MESSAGES] })
Then the idea is to get the content of every new message and answer properly, once you have created your discord client, you will need to set up an event listener like this one:
discordClient.on('messageCreate', message => {
const content = messageReceived.content.toLocaleLowerCase()
if (content === 'hi') {
messageReceived.channel.send("hello, I'm a bot!")
}
})
And don't forget to login with your discord bot key
const discordKey = "YOUR DISCORD BOT KEY"
discordClient.login(discordKey)
You can also see the repository for my bot here.
And for your use case you would want to mainly focus on some parts insid discord.ts.
Hopefully this helps.
Here are some basic examples using discord.js within node.js.
Simple Response
To send a response, simply check if the user's message contains the desired input you want your bot to respond to.
if(message.content.toLowerCase().includes("ping") {
message.reply("Pong!")
}
Multiple Responses
This is a much more efficient method of responding to multiple inputs. This includes using an array.
const array = [
"hello",
"hola",
"bonjour"
]
if(array.some(word => message.content.toLowerCase().includes(`${word}`)) {
message.reply("Hello!")
}
Here's the code
---Starts From Here:---
// type `await lib.` to display API autocomplete
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
// Only respond to messages containing "hi", "hey", "hello", or "sup"
if (context.params.event.content.match(/hi|hey|hello|sup/i)) {
let messageContent = context.params.event.content.match(/hi|hey|hello|sup/i);
await lib.discord.channels['#0.3.0'].messages.create({
channel_id: context.params.event.channel_id,
content: `${messageContent[0]} to you too 👋`,
message_reference: {
message_id: context.params.event.id
}
});
}
--Ends--
Image of code
I suggest using autocode.com it will really help you in coding life. I use it myself.
Here's a small guide https://autocode.com/guides/how-to-build-a-discord-bot/
If your banned using discord selfbot, that's not my fault
from discord.ext import commands
client = commands.Bot(
command_prefix='-',
self_bot=True,
help_command=None
)
#client.event
async def on_message(message):
if message.author == client.user:
return
if message.content == 'Hello!':
await message.channel.send("Hi how your day!")
client.run('user token', bot=False)
I am trying to code a discord.js bot for my community server and I was having some issues with making my help command. I have a command for >help that shows and embed with all the different categories of commands. It also shows how to view those other commands, but for me to be able to do this I need to be able to have commands like >help fun or >help staff. I tried to make the >help fun command but when I type it, it only takes the first argument and just shows me the >help embed. If someone could show me the code for a >help fun command that will just send a new Discord.MessageEmbed that would be great. This is the code I tried using:
module.exports = {
name: 'help fun',
description: "get some `fun` help!",
execute(message, args, Discord){
const helpfunEmbed = new Discord.MessageEmbed()
.setColor('#9947d6')
.setAuthor('Vero Commands List', 'https://cdn.discordapp.com/attachments/746321327727706226/819556499088605214/Hypers.png')
.setDescription("The Vero Bot prefix for `Ak's Basement` is `>`")
.setThumbnail('https://images-ext-2.discordapp.net/external/hn8Iyc--j2npBvCjnAsXUt78zMovfsTj_DyRaBb1YdU/https/media.giphy.com/media/eEx0qRFYM1dyGQPAID/giphy.gif')
.addFields(
{ name: '`>ping`', value: 'shows bot latency'},
{ name: '**Work In Progress**', value: 'More commands coming soon!'},
)
message.channel.send(helpfunEmbed);
}
}
Make the help command, and let the user pass "fun" as an argument, then base the bot's reply off that, that way you can have one command for all the help sections.
here's a code example,
btw discord.js guide has a whole explanation on this, so you might want to read it
Here a link if you want to that exact page;
https://discordjs.guide/creating-your-bot/commands-with-user-input.html
and here is a code sample,
I am assuming execute(message, >>>> args <<<<< , Discord) (args) passes a array ( this code is according to the guide i said above)
module.exports = {
name: 'help'
description: "get some `fun` help!",
execute(message, args){
if(!args[0]) { // if no args were give : ex: ">help"
const helpEmbed = new Discord.MessageEmbed()
.setColor('#9947d6')
.setAuthor('something here')
.setDescription("A description")
// do whatever you want with the code and send it,
// assume prefix is >
// this is if there were no args: ">help" will be the command
return message.channel.send(helpEmbed);
} else if(args[0].toLowerCase() == 'fun') { // lowercase it so it will not be case sensitive ex: this would allow ">help FUn" and ">help fun"
const helpFunEmbed = new Discord.MessageEmbed()
.setColor('#9947d6')
.setAuthor('something here')
.setDescription("")
return message.channel.send(helpFunEmbed)
} else if(args[0] == 'info'){ // without ".toLowerCase()" will only allow : ">help info" and will give the below error we set if we use something like ">help Fun"
// do something here (send your embed with help menu for info)
} else { // optional, if some one do a invalid category, it will send a error : ex: ">help dfsg"
return message.channel.send('Invalid category')
}
with this you will not have to create individual command for each catergory*
we can just check the args to see if they provided any args or not (detailed explanation below)
ps: you would have noticed I have removed Discord from execute(message, args)
this is as you don't need to export Discord like this as you can just do
const Discord = require('discord.js') at the top. there will be no difference changing this, but I like to just require it at the top, if you want just add discord in there like execute(message, args, Discord)
Simple explanation on what we do here
first, we check if args[0] is undefined (if a user do ">help" without something in front of it, this would detect it and send
then it will send the embed with the categories if this returns undefined
if a arg is given it will go to the if-else chain
checking if the args = to the category we set.
if it is send the embed with the relevant command info to the user
if its not equal to the category it checked it will go through all the if else chains looking if it matches
if It does not match it will send the error " Invalid category" meaning the user sent a category that we were not looking for
Currently trying to use setPresence for my bot, and I can get the name but no extra details for the 2nd line and no images.
bot.user.setPresence({
game: {
name: "Ready to brawl!",
application_id: 'the id',
details: "These sharks are ready for a fight.",
type: 0
},
assets: {
large_image: "large",
large_text: "Do not jump into that tank...",
small_image: "small",
small_text: "c!help"
},
status: "dnd"
});
So what shows up is:
My bot is on DND, shows "Playing Ready to brawl!", but nothing else. The details part doesn't show up and there's no large or small image.
I've used a custom presence application before so I assumed you needed your own discord application on the developers site, so I made one. I have the name of it the exact same as the "name: '.' " part and I have the id in the application id part. (I'm not sure if it's bad to share the ID so I excluded it.)
Before I tried using large_image and small_image as pure inputs and gave them links, but neither that nor this application one worked.
So if I'm seriously fucking something up here, help would be appreciated
It's normal, you can't use Rich Presence with a bot actually. Maybe someday Discord will allowed this.
So, I have a KiK bot and want to add buttons to the bottom of the chat window to ask specific questions. The user clicks on one, which is taken as there response and processed as a message. The buttons then change again based on this response.
I've seen it in a lot of other KIK apps, but there's nothing in the KiK API that says how to do it!
Does anyone know how to create these response buttons in KIK? :)
What you're looking for are keyboards (specifically the Suggested Response Keyboard), you can read up on how to use them here: https://dev.kik.com/#/docs/messaging#keyboards
Adding my solution as it may help to someone:
function sendButtons() {
var arrResponse = [{ type: "text", body: "Summer" }, { type: "text", body: "Rainy" }, { type: "text", body: "Winter" }];
var sendingMessage = Bot.Message.text("Which Season do u like the most?")
bot.send(sendingMessage.addResponseKeyboard(arrResponse), recipient);
}
As you can see, you need to create an array of the input to show the user on keyboard.
And then attach this response array to the message.