Im am right now creating an info command for my discord bot and want to make a footer in an embed with the developers/my name and avatar.
But now if I add my name and avatar url to the field then when I change name or avatar the informations in the footer will still stay the same.
Is there something I can use, to get my own avatr url and name just like I get the ctx.author.avatar_url and ctx.author?
Or is threre something like bot.owner?
This is my code:
user_me = ?
em = discord.Embed()
em.set_footer(icon_url=user_me.avatar_url, text=user_me)
You need to use your id, and from that you can create a user object.
user = await bot.fetch_user(<your_id>)
em = discord.Embed()
em.set_footer(icon_url=user.avatar_url, text=user.name)
Related
I was trying to find the way you can identify embed message text and author, but never found it. So is there any way to do that?
Googled through out of the Internet but not found it unfortunately.
Take a look at the docs here
If you have an Embed object, obj just use obj.author to get the author. The text I'm assuming you mean the title, which can be accessed by obj.title.
Assuming you have a Message object,
First, to get message author:
author = message.author
To get the embed from the message:
embed = discord.Embed.from_data(message.embeds[0]) # gets embed from message
Before getting the embed text, we first look at the attributes of a discord.Embed object. It has the attributes title and description [source].
Therefore:
embedTitle = embed.title # get title
embedDescription = embed.description # get description
Hi stalkers
Is there a way to access a site's data directly?
I need it for my code :
#commands.command(aliases = ['isitsafe','issafe','scanlink'])
async def isthissafe(self, ctx, link: str):
try:
link = 'https://transparencyreport.google.com/safe-browsing/search?url='+ link.replace('/','%2F')
embed=discord.Embed(
color = discord.Color.dark_red(),
title = '',
description = f"[Transparency Report verification]({link})")
await self.emb(embed, ctx.author.name, 'https://cwatch.comodo.com/images-new/check-my-site-security.png')
await ctx.send(embed=embed)
except:
await ctx.send('An error has occured')
print('\nERROR')
Basically I made, a command which should tell if a link is safe or not, I did it using google's verification report site, but.. the problem is I only reformatted the link so the bot sens it in an embed and you access it from there.
My question is, now that you understood what I need, is there some way in which I could directly let the bot output the message from the website that indicates if the site is malicious/safe ??
Please help me.
I provided an image as well with the message I want to get from the site.
You might want to try scraping the site with bs4, or just look for the string "No unsafe content found". However, it looks like google populates the field based on a request.
Your best bet would be to use transparencyreport.google.com/transparencyreport/api/v3/safebrowsing/status?site=SITE_HERE. It returns a JSON response, but I don't understand it, so play around and figure out what the keys mean
def send_dm():
token = 'i know, just not putting my token here'
message = 'yo, dont mind just testing smth'
id = "681089525702721546"
header = {
'authorization' : token,
'user-agent' : 'i know, just not putting my user_agent here',}
payload = {'content' : message}
sd = requests.post(f"https://discord.com/api/v9/channels/{id}/messages", headers=header, data=payload)
print(sd.status_code)
So i am trying too send for fun too my friend a message with python requests but i just find out that you need to get the channel id for the direct message, but i dont know how, can someone help me finding out?
Go to Discord Settings
Click on Advanced under App Settings
Toggle Developer Mode
Go to the channel of your choice
Right-click and click on Copy-ID
Per documentation Create DM with a user (recipient_id) to return a Channel Object.
In this returned object the id key will be the id of this channel that you can use to send a message in the way you tried to.
If you want to send a message to a spesific/public channel you can get a list of all the channels via Get Guild Channels
I am trying to read the members of a guild by invitation. As soon as we send a link from a server, information such as name, online membership and total members appears. How do I get this information? (The library in question is discord.py)
Example:
(I can't share an image, so I ask you to open the photo link:)
https://cdn.discordapp.com/attachments/842566116978327584/844421408019841034/unknown.png
Name: ☕|Clube do café #240|☕
Photo url: https://cdn.discordapp.com/icons/828004701148676137/62f745ee62f7fb6dd7fbc34a6b75f2df.png?size=128
Online: 112
Members: 232
Id: 806673124819992688
(I extracted this information manually, but was wondering how to do this in the code)
I have already tried to use the following message attributes: attachments, embeds, guild, stickers and system_content. Both returned empty or the invite link.
This is possible with the help of the fetch_invite() function
invite = await client.fetch_invite(url = "https://discord.gg/Invite-ID")
You can then retrieve your desired attributes
For example:
memberCount = invite.approximate_member_count
presenceCount = invite.approximate_presence_count
guildName = invite.guild.name
guildIcon = invite.guild.icon_url
guildID = invite.guild.id
And so on
I would like to get a users avatar link with their user id without using discord.py
Is there an alternate library?
If you are using rich embed for discord.js this should be your code
const embed = new controller.RichEmbed()
var user = message.user;
var useravatar = message.user.avatarURL;
embed.setAuthor(`This was requested by ${tk}`, useravatar);
embed.setTitle("Current Inventory");
embed.addField(`Wardrobe:`,`Pink hair, choker, pink and white striped hoodie, and ripped black jeans`);
embed.addField(`Invenory:`,`Bat with nails, Medkit, ||secret knife|| `);
embed.setColor('#b89870');
bot.reply(message, embed);
but you probably wanna know what gets the avatar url,
first we declare our variable
var useravatar = message.user.avatarURL;
Then we use it in our embed as an image
embed.setAuthor(`This is plain text, the next slot is for the image url grabbed from discord`, useravatar);
Anything that states you can put a url in discord.js, you can put a variable.