#discord-bots
1 messages · Page 822 of 1
what sort of discord bots have you done atm?
before it was for irc and skype bots
atm my bot keeping track of livestreamers when goes online and alerts and changing activity showing how many are live atm of how many total of streamers in database, and also posts clipped clips from livestreams into a #clips channel - and moderators can add/del streamers and or webradio-stations
and it also plays webradios in voicechat (grayzone)
i want to get the message id of the repliedmessage
how about yourself?
!d disnake.Message.reply
await reply(content=None, *, fail_if_not_exists=True, **kwargs)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
A shortcut method to [`abc.Messageable.send()`](https://docs.disnake.dev/en/latest/api.html#disnake.abc.Messageable.send "disnake.abc.Messageable.send") to reply to the [`Message`](https://docs.disnake.dev/en/latest/api.html#disnake.Message "disnake.Message").
New in version 1.6.
Changed in version 2.3: Added `fail_if_not_exists` keyword argument. Defaults to `True`.
nonono not this like the message which is replied
huh?
Oh you want to get the content of the referenced message?
yessss tbh i want the aauthor of that message
Hmm
!d discord.Message.reference
The message that this message references. This is only applicable to messages of type MessageType.pins_add, crossposted messages created by a followed channel integration, or message replies.
New in version 1.5.
Was about to type that
but how to use this
it is a message object
Is there a way to make slash commands visible to specific users? If so, does anyone know how to do this in disnake?
Not that I know of
im sry idk i never tried that before
Except editing their perms to use slash commands as a whole
There is tho? But i forgot the name let me see
Aah ok no problem :)
Is it possible to get the online status of a user? Like the online, idle and do not disturb thing
ephemeral=True
... slash commands, not the response
oh
You using discord.py?
yeah
empheral is if the response is visible to a specific user
Yeha i read wrong sorry 😦
!d discord.Member.activity
property activity: Optional[Union[discord.activity.Activity, discord.activity.Game, discord.activity.CustomActivity, discord.activity.Streaming, discord.activity.Spotify]]```
Returns the primary activity the user is currently doing. Could be `None` if no activity is being done.
Note
Due to a Discord API limitation, this may be `None` if the user is listening to a song on Spotify with a title longer than 128 characters. See [GH-1738](https://github.com/Rapptz/discord.py/issues/1738) for more information.
Note
A user may have multiple activities, these can be accessed under [`activities`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member.activities "discord.Member.activities").
!intents
Using intents in discord.py
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.
To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.
Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.
import discord only works too?
i think thats for fetch custom activity message etc i think idle etc is on activity
!d discord.Member.status
property status: discord.enums.Status```
The member’s overall status. If the value is unknown, then it will be a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") instead.
oh there u got it
that's the custom status I believe, on mobile so can't double check
One sec
okay
async def new_restriction():
for guild in client.guilds:
for channel in guild.channels:
print(channel.id, channel.name)
restriction = await get_restriction()
if str(channel.id) in restriction:
return False
else:
restriction[str(channel.id)] = {}
restriction[str(channel.id)]["Moderation"] = 0
restriction[str(channel.id)]["Scores"] = 0
restriction[str(channel.id)]["PCC_Content"] = 0
restriction[str(channel.id)]["Server"] = 0
with open("channel_restrictions.json", "w") as f:
json.dump(restriction,f)
return True
I have this code
But when I run it the bot will only "check" and print one channel and then the bot stops
But why
What is wrong with my code?
cause you return
i tried without return and its the same
maybe you want something like pass
I will try
there's pass and continue, break
In this article, you will learn to use break and continue statements to alter the flow of a loop.
you prob want continue
In my code is there a big difference between pass and continue?
I have multiple casino games how can I make it where a user can't open up more than one game at once?
@fresh orchidyou should take look of that link i gave and read about break n continue ignore pass
I read it
Continue will just "stop" the loop at this point and the loop will start again
Bad explanation I know
And pass is just a placeholder and will do nothing
and remove returns if you wanna go throu all
continue will ignore that one, and keep looping throu list
break will stop
u can see break as return
so when I use continue it will ignore the json.dump part if its already in the list
And when I use pass it will do the json.dump part but it wont change anything in the file because there is no code to change anythin
right?
u have a nice example showing you exaclty whats going on with continue
ok thanks for the help I think I got it
!e
# Program to show the use of continue statement inside loops
for val in "string":
if val == "i":
continue
print(val)
print("The end")
@honest vessel :white_check_mark: Your eval job has completed with return code 0.
001 | s
002 | t
003 | r
004 | n
005 | g
006 | The end
not be an ass but this has nothing todo make a D-bot its general python.
I know
And I know I should learn Python first
And I will learn Python too but I dont have motivation
i promies your motivation will grow as more you learn - cause that will make it more fun for you
and its not C++ and thousands of pages to read
ok so this is going to be long but i need help normalizing my data. i have a ticket system that when someoine interacts with the persistent button it makes a channel aka the ticket chennal, i want it to be aqble to have commands to show open tickets. i was thinking of making a dict of dicts with the dict key being the channel id and thebn the rest of the info in a dict but im not sure if its good. how should i do it?
list of dicts? dict of list?
im just not sure
sebt here bc its a mix
ok I will try to learn it but one last question
So the code I've sent before is in my main.py file
Is there a option how to use the function in a cog without copy and paste the whole function?
I tried something like this
client.get_restriction = await get_restriction()
But this will just call the function one time when the code starts and later when I use
self.client.get_restriction
It wont get updated
So I just get the information of the time when the bot started and not the actual
https://mystb.in/HopNothingDoors.python when i tip .v name <Name> it doesn't change name of channel
in ur code there is no .v commands?
what library is it?
whats the code for the current member count?
!d discord.Guild.member_count
property member_count: int```
Returns the true member count regardless of it being loaded fully or not.
Warning
Due to a Discord limitation, in order for this attribute to remain up-to-date and accurate, it requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be specified.
import discord
from discord.ext import commands
client = commands.bot(command_prefix="!")
@client.evevt
async def on_ready():
print(f"logged in as {client.user}")
print("ready!")
print(f"ID: {client.id}")
@client.command()
async def ping(ctx):
await ctx.send('Pong! {0}'.format(round(client.latency, 1)))
client.run(token)
whats wrong with my code????
i keep getting the error import discord even though i have discordpy defined and installed
event, not evert
@bot.event
async def on_member_join(member):
embed=discord.Embed(title="**__Welcome To GFFL__**", description=":wave: **:partying_face:Hello welcome to the League** **Have Fun** :scroll:`Make sure to go follow the rules everything is listed in information ` ", color=0xe0e0e0)
await member.send(embed=embed)```
another thing, make sure python is added to path
member.guild.member_count will be the member count
well were u wanna display it
okay i still getting the import discord error
Welcome you are our <current member>
it is
then put it there
@fresh iron
event not evevt
it is added to path
oh, are you using vscode?
yes?
I have been told not to spoonfeed so
do you have multiple versions of python installed?
title="Welcome To GFFL" how can u include a variable into a string?
if you installed the library just now, restart it
dont use the play button to run the code, download the python extension and use the run option above to run your code, you can confirm your python installation there
<PREFIX>
@pliant nacellei dont know most annoying shitty code iv ever seen doing a discordbot
one asked tho what lib u using
lol?
doesn't seem like that
it looks like a homebrewed
not a real lib
raw api?
import functions as func
from commands.base import Cmd
help_text = [
[
("Usage:", "<PREFIX> <COMMAND> `NEW NAME`"),
("Description:",
"Directly change the name of the channel you're in. "
"Supports all variables from the `template` command (use `<PREFIX> help template` to get a list).\n\n"
"Use `<PREFIX> <COMMAND> reset` to remove your name override and revert to the original template."),
("Examples:",
"<PREFIX> <COMMAND> Bob's bustling barbeque bash\n"
"<PREFIX> <COMMAND> Karen loves @@game_name@@\n"
"<PREFIX> <COMMAND> reset"),
]
]
async def execute(ctx, params):
params_str = ctx['clean_paramstr']
guild = ctx['guild']
author = ctx['message'].author
new_name = params_str.replace('\n', ' ') # Can't have newlines in channel name.
new_name = new_name.strip()
if new_name:
return await func.custom_name(guild, ctx['voice_channel'], author, new_name)
else:
return False, ("You need to specify a new name for this channel, e.g. '{0}name <new name>'.\n"
"Run '{0}help template' for a full list of variables you can use like "
"`@@game_name@@`, `@@creator@@` and `@@num_others@@`.".format(ctx['print_prefix']))
``` where is import discord?
kek
not in this file
no shit sherlok 😄
this file has nothing with discord.py todo
verry confusing codes
show the commands/base.py file @pliant nacelle
for discord.py
and functions
return await func.custom_name(guild, ctx['voice_channel'], author, new_name)
tbh it seems like a poor discord.js commands implentation in python
they do it like that
!pip discord.js
omg
why thoi?
why not use discord.py forks or discord.py it self
"i wanna code JS but in python"
idk maybe someone said, discord.js has better Object attributes than discord.py and he just made it to prove them wrong
well yea for some things , like js Guild.iconURL({dynamic: true/false}) it allows users to choose weather to return the animated or static version
from discordjs import Client
from javascript import console
client = Client()
client.on("ready", lambda:
console.log("Bot is ready")
)
async def msg(message):
if message.content.startswith("!ping"):
await message.channel.send("pong")
client.on("message", msg)
client.login('Token')
``` then go code in JS
discord.js' kinda bettter with these things
for what?
^^
cant they use a js lib already?=
ofcourse, "but python is easy"
id say discord.py is better than that library
if u code js code js, thats fine ... but i dunno its like write chinese but wanna speak swedish with a indien accent taste of japan
u need to code js to understand that lib
djs?
ye
yessir
Well I tried coding with it once...
tell us how did it go lol
When I got started, I started thinking, "Python is way better in terms of simplicity as compared to JS"
until you realise OOP is a thing
So yea, I got mad because I wasn't able to understand when to use === and when to use == lmao
so you didnt wanna convert your religion from py to js
Ah yea. Don't just get me started about oop in js
one think js had as fresh n shit well handy was Objects aka Arrays
some person who used js teached me how to make objects in python ```py
_object = {'attr':'value'}
I mean, why add another keyword to subclass LMAO
Python is just too simple and readable haha
it has cons tho
but imagine write pythong and put js brackets on lol
how could i do this
!d discord.Embed.add_field
add_field(*, name, value, inline=True)```
Adds a field to the embed object.
This function returns the class instance to allow for fluent-style chaining.
by learning to code?
++
Lmao
nothing was super excotic about that embed
Well there is a probability they are new to discord bot making
then its a py server
why use jswrap
they misled
how i make discordbot like this? shows embed coded in asm
Erm, do you already know VSolar? If not, these aren't the kinds of comments we like in this server.
@visual yarrowhe could specify Q more
it only display an embed
@fresh iron do pip install discord.py once more and show us the results
do you want to be a part of this community?
most probably wrong python version
do you have multiple versions of python installed?
Alright, but you could guide them in the right direction, rather than giving them a snarky comment.
not really
discord.py or just discord
I forgot already
maybe i mixed him up with the jsguy
discord is just a shim for discord.py
py -3 -m pip install discord.py
My man using disnake, so forgot about discord.py
u also forgot already
yes, if specify a Q i gladly try help
I only installed it once, so it wasn't enough of a beautiful experience for me to remember
Haha
discord.py who? the only wrappers for dpy ik are hikari and rin
it's installed in 3.6
I looked at the wrong line
Told ya, most probably wrong Python version selected
because your answer of "learn to code" is not what i want to see on this server
do pip3.10 install discord.py @fresh iron
Yups, rin ftw
everything was fine yasterday not sure whats changed now
Ok i will try not say that then, I could as him/her specify it better
Well most probably yr Python version in yr IDE changed @fresh iron
made the first, and maybe most significant contribution https://github.com/an-dyy/Rin/pull/6
pip install discord.py
W O W
can you see a option "Python interpreter" at the left bottom?
breaking changes
I looked at the wrong line
on where
@daring olive @visual yarrow u give me another chance?
in vsc
Yeah, I mean you can always just ask someone to clarify the question 👍
ye i will next time
@fresh iron
oh
install the python installation as told ya already
I'm gonna blame toxickids!
Can you specifie your Q lil bit more? What i see is just an embed
👀
if you did and its still not coming , use ctrl+shift+p and type select interpreter
which version again
like the amount of people on a role
python extension mate, just go to extensions, type python and install the one from microsoft
it is installed
grab the role or so and len() members
if u want an int of how many
🏃♂️ i was sick trying to install it with that command until i realised it missed the :
well imma try looking into the internals to get familiar with the library and may make some contributions :)
and how did you run the code?
add_field()?
from run?
use the run option above in near file and other options
embed.add_field() and inline=False, or If want True?
no ik add field but i am saying like you can use -members <role> and lists all the members that have the role
or just hit ctrl+f5
but i want it to be only 32 roles
yes
so that members see how many members are on that role
that's what i literally do though it gives the same error, might just reinstall everything
you def can do
the play button is broken
?
ill reinstall python
@balmy ivytrying to figure out but should be around guild.roles and go from there
ctrl+f5 still results with the same error?
yeah it's literally the same
ok
@bot.command()
async def members(ctx):
i just noticed i shared a token lmfao
👀 Why I wasn't here
fetch role you want to check of how many users, and then you have Role = fetched....
count = len(Role.members)
feel free to use that bot its made by an alt
@balmy ivy u wanna len() that members
fetched is a error
omg
just sent it all in one
fetch a guild role
or get_ it actually
spoonfeeding is hated
lmao
its true others complain if i do it
Role = ("Indianapolis Colts")
count = len(Role.members)
no Role needs to be grabbing an role object from that guild
and then len() on that role object with attribute members
how can i add that the user can just use the command between different time examples just from 10am until 3pm
the id or the name?
make an if statement at the start of the command
import datetime
@balmy ivyeither way tbh, but hint guild.get_role()
and check if datetime.now() is above 10am and under 3pm
wait so replace role =() with guild.get_role()
ok thanks
I need the function in every cog and it would be nicer to use the function in my main file
i have to go but you need to get/fetch an role object if you know what that is? and from there you can count how many members has that role
in that guild
guild.get_role() i think
with id or name
ok but len(Role.members) has a error when i use guild.get_role()
i would recommend use ID instead of name cause if u wanna change name of role its broken
Just put it into a module or to bot subclass
How?
For the first method, just define a function in a separated file and import it from there whenever you need it, for the second just define it in your bot's subclass
mutedRole = discord.utils.get(ctx.guild.roles, name="Muted")
if not mutedRole:
index = 0
for role in ctx.guild.roles:
if role.permissions.administrator:
index += 1
index -= 1
mutedRole = await ctx.guild.create_role(name="Muted")
await mutedRole.edit(reason = None, position = index)```no error, doesnt drag it to the right position
how could i make a command where it shows how many people on a role
!d discord.Role.members
property members: List[Member]```
Returns all the members with this role.
no like
Just use len on it
how?
!e py some_list = [1, 2, 3, 4, 5] print(len(some_list))
@vale wing :white_check_mark: Your eval job has completed with return code 0.
5
how does it know what role ?
May I ask what is your python experience level
a million

sum like this
I will not write the full command for you lol, this is enough help I'd say. The docs are pretty useful
i am not asking for full command
Like what else is required to make a members command
I just don't get what you don't understand, if you told me I could've helped you probably
Also you haven't answered my question about your python knowledge properly
its like a 2
Just in case it is low, the discord bot is not a good beginner project
You need decent knowledge of python to understand what you do
On the other hand, if you consider yourself experienced enough you may check this tutorial out https://vcokltfre.dev
A tutorial on how to use discord.py to create your own Discord bot in Python, written to fix the flaws of many other popular tutorials.
i already know how to use embeds and make like a help command
Yea but do you know how to iterate through the list and get attributes of an object
That's all you need for members command
- some docs, to be more exact
discord.Roleanddiscord.Member
this tutorial uses ridiculous things
It doesnt
nvm, confused it with another one
I've seen some really bad ones, mb
Like what
nah, i've seen some not using @bot.command but instead an on_message event for !help
Hello... someone have some time to help to make a trigger author message delete ?
(User sent a message, bot automatically delete the current message who the user sent)
Can you explain better?
You shouldn't even be using a dedicated command for help...
it was an example
even though I make my own help commands
since I never learnt on how to style a built in one
!docs discord.ext.commands.HelpCommand
class discord.ext.commands.HelpCommand(*args, **kwargs)```
The base implementation for help command formatting.
Note
Internally instances of this class are deep copied every time the command itself is invoked to prevent a race condition mentioned in [GH-2123](https://github.com/Rapptz/discord.py/issues/2123).
This means that relying on the state of this class to be the same between command invocations would not work as expected.
While me who uses help command without subclassing it
When i do the command trigger (+trigger <id>)
the bot will delete every message the user sent
so if he send a msg, the bot will delete the msg automatically with 1 ms
So i did @bot.command() async def trigger(ctx, message, author): await ctx.message.delete list_of_ids.append(author.id) if author.id in list_of_ids: await message.delete() await asyncio.sleep(0)
But i get discord.ext.commands.errors.MissingRequiredArgument: author is a required argument that is missing.
Okay my eyes gonna bleed
Im beginner xd
Im not sure if this is the right channel but I have this code
@commands.command()
async def whois(self, ctx, member:discord.Member = None):
await check_server_restriction(ctx)
await ctx.send("CONTENT")
The check_server_restriction looks like this
async def check_server_restriction(ctx):
restriction = await get_restriction()
if restriction[str(ctx.channel.id)]["Server"] == 1:
await ctx.send("This command is restricted. You can use it in the #bot-commands channel")
return
So when I run it it sends the this command is restricted text but the other CONTENT too
I dont get why because my code says after the bot sends the this command is restricted it should return
So why it sends the content too and ignores the return
i think you dont need message and author
Just use ctx.author.id i think
Imma try
there is no error
Wrong reply
youre sus
as I said it just send both things
hi, i have a question. i have a @task.loop and i want to run it through async. problem is, whenever i try to await it start. it runs but whenever i try to do it again, it just wont run the task seperately
basically i wanna run 2 tasks at the same time
and I dont know why because there is a return
and it doesnt seem that possible for me
Does that make any difference for me?
Because, its gonna stop the function check_server_restriction and not the command function
oh ok
Whatever
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: object method can't be used in 'await' expression
hey, I'm making a discord bot, but I want to be able to run it with arguments.
I've tried looking into sys.argv and argparse but nothing is working for me right now. I think because discord.py is asynchronous but I don't know for sure if that's even remotely close to why I can't get it to work... anyone able to help?
can you send your actual code
You dont need 2 parameters for the Context
@bot.command()
async def trigger(ctx):
await ctx.message.delete
list_of_ids.append(ctx.author.id)
if ctx.author.id in list_of_ids:
await ctx.message.delete()
await asyncio.sleep(0)```
Thats my actual code now
Where the brackets for delete()
Why even make a conditional when its gonna append it to the list in the first place
bcs its the logic of trigger message
really need help on this one

What
Can you show your code
when the trigger user send a msg, i want the bot automatically del the msg
so i did 0 ms
I don't think you can do that with commands
discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") is created and sent.
This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.messages "discord.Intents.messages") to be enabled.
Warning
Your bot’s own messages and private messages are sent through this event. This can lead cases of ‘recursion’ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
That's a whole nother issue
its pretty long, messy since i didnt expect anyone else to see it. it has nothing to do with the code but ill show you the important parts
@tasks.loop(seconds=30.0)
async def plant_growth(self,ctx,trayid,number):
await plant_growth.start(self, ctx, trayid, number)
@stray solar you might want to check this tutorial out, it seems like you missing normal resources https://vcokltfre.dev
A tutorial on how to use discord.py to create your own Discord bot in Python, written to fix the flaws of many other popular tutorials.
You don't start the loop like this iirc
You don't parse args to it do you? I never did so idrk
you can
@tasks.loop(seconds=30)
async def some_loop(self):
pass #stuff
#and this is in some cog init
some_loop.start()```
The start surely doesn't need to be awaited and you don't parse self that's for sure
Gotta check docs about other things
!d discord.ext.tasks.loop
discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True, loop=...)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
tried this, still
when i run a command, and yes
You typically don't start loops from a command
Can you tell me what are you trying to make
im trying to basically randomly simulate 4 trays with different plants in them, and i run the command to start the plant growth
hey
i want to run the same task for 5 different trays
Maybe it is better to store the data somewhere and periodically update? Creating many internal background tasks is not a good practice
how could i make a command where it takes everyone off a role? like -disband <emoji>
idk
Why client ?
You need to provide client when using command
as in $ping client?
Yes
This error now
remove the client from your args
Well seems like you are doing something wrong
Could you show the whole command
You probably want the latency of the bot
And show cog init as well please
There is no reason for you to have client as an argument here. You want to do self.client or whatever your client is defined as in the cog
then how to get client.latency
self.client
ah ty 🙂
np
Since in the init i have defined self.client as client then why should self.client be used instead of client?
that defines it for the bot cog start pretty sure, its good to add a self to the beginning of your args
Is there a way to do this in which one does not have to type client after the command?
@commands.command()
async def ping(self, ctx):
embed = discord.Embed(title="pong")
embed.add_field(name="latency", value=self.client.latency)
there
The self refers to the class object
Indentation?
ok there
This is my version of the last line that you gave but the same error appears when $ping is inputed without client at the end
You didn't remove client from command args
^
ty
Whi this:
class NoInviteFound(CheckFailure):
super().__init__(message="This user has no invites")
File "C:\Users\giacomo.dimatteo\PycharmProjects\ZhagoBot\lib\bot\invites_check\Checks.py", line 11, in NoInviteFound
super().__init__(message="This user has no invites")
RuntimeError: super(): no arguments
This should be inside of __init__ lol
i'm stupid D_D
async def bold(ctx, text):
ff.boldTEXT(text)
await ctx.reply(text)
text = text.replace("a", "𝗮")
text = text.replace("b", "𝗯")
text = text.replace("c", "𝗰")
text = text.replace("d", "𝗱")
text = text.replace("e", "𝗲")
text = text.replace("f", "𝗳")
text = text.replace("g", "𝗴")
text = text.replace("h", "𝗵")
text = text.replace("i", "𝗶")
text = text.replace("j", "𝗷")
text = text.replace("k", "𝗸")
text = text.replace("l", "𝗹")
text = text.replace("m", "𝗺")
text = text.replace("n", "𝗻")
text = text.replace("o", "𝗼")
text = text.replace("p", "𝗽")
text = text.replace("q", "𝗾")
text = text.replace("r", "𝗿")
text = text.replace("s", "𝘀")
text = text.replace("t", "𝘁")
text = text.replace("u", "𝘂")
text = text.replace("v", "𝘃")
text = text.replace("w", "𝘄")
text = text.replace("x", "𝘅")
text = text.replace("y", "𝘆")
text = text.replace("z", "𝘇")
text = text.replace("A", "𝗔")
text = text.replace("B", "𝗕")
text = text.replace("C", "𝗖")
text = text.replace("D", "𝗗")
text = text.replace("E", "𝗘")
text = text.replace("F", "𝗙")
text = text.replace("G", "𝗚")
text = text.replace("H", "𝗛")
text = text.replace("I", "𝗜")
text = text.replace("J", "𝗝")
text = text.replace("K", "𝗞")
text = text.replace("L", "𝗟")
text = text.replace("M", "𝗠")
text = text.replace("N", "𝗡")
text = text.replace("O", "𝗢")
text = text.replace("P", "𝗣")
text = text.replace("Q", "𝗤")
text = text.replace("R", "𝗥")
text = text.replace("S", "𝗦")
text = text.replace("T", "𝗧")
text = text.replace("U", "𝗨")
text = text.replace("V", "𝗩")
text = text.replace("W", "𝗪")
text = text.replace("X", "𝗫")
text = text.replace("Y", "𝗬")
text = text.replace("Z", "𝗭")
text = text.replace("|", "┃")
text = text.replace("-", "━")```
why wont this work
it says ff is a error

why not make a dict or use the built in feature?
example on how to use a dict
en = {
'a': '>',
'b': '?',
'c': '*',
'd': '-',
'e': '+',
'f': '^',
'g': '%',
'h': '@',
'i': '!',
'j': '$',
'k': '_',
'l': '`',
'm': '~',
'n': 'c',
'o': '|',
'p': '}',
'q': '[',
'r': ')',
's': '{',
't': ']',
'u': '(',
'v': '=',
'w': ';',
'x': ':',
'y': ',',
'z': '.',
'1': '"',
'2': 'j',
'3': 't',
'4': 'k',
'5': 'b',
'6': 'd',
'7': 'l',
'8': 's',
'9': 'a',
' ': ' ',
'.': '.',
',': ','
}
def encrypt():
text = input("\nWhat text would you like to encrypt:\n")
print(f"\nYour encrypted text looks like:\n{''.join([en[l] for l in text.lower()])}")
encrypt()
dumb little thing i made lol
No like
example on how to use a dict
i said it was an example you use the dict so it will return the key
no i am saying thats not what i am using
you want to replace each letter with its font counter part right?
i am trying to do this
yes im correct?
but that isnt fonts
this is bold?
bro is that bold or not
its an example bro
What are you doing
and why not use the built in bold feature discord provides?
its the same thing
What's the point?
@client.command()
async def bold(ctx, *, text):
await ctx.reply(f"**{text}**")
to bold the message

made it a kwarg so it will get stored as a dict
so any text you add no matter if it has invalid chars it will make them bold and you will not be limited by chars*
Well it really is a hard way of doin' it
ok?
why not use the code i gave you can make any sentence bold and youre not limited to chars
?
i did use it
did it worked?
yea
are you satisfied?
yea
great
thanks
yw
do you know what i mean tho
𝗭
Z
when i used the first letter it does this
in channels
the point of this is to make channels
then use a dict
this?
yes but replace the keys and values
whats the point i just wanna know how to fix my code i will just spend more time
? thats the point
like this but not using **
Why though
You have to hardcode all of the characters
Also why is your prefix /
That's so annoying to use
Not an issue if theyre fine w it
It's dumb though
i need help with anti nuke
What specifically
the whole thing @final iron
Anti nuke is quite complicated
You need to decide what you want to trigger it and how to handle it
You want to prevent server invites?
@slash_command(name="accept_reaction", guild_ids=[865691556736008213])
@has_permissions(administrator=True)
async def accept_reaction(self, ctx: ApplicationCommandInteraction, emoji: str):
emoji: Emoji = self.bot.get_emoji(int(emoji))
if emoji is not None:
await ctx.send(f"L'emoji {emoji.name} è stata impostata", ephemeral=True)
db.execute("UPDATE Guild SET InvitesEmojiID = ? WHERE GuildID IS ?", emoji.id, ctx.guild.id)
else:
await ctx.send("Emoji non trovata", ephemeral=True)
It gives me None, someone knows why?
does anyone know how to use the Discord-Anti-Spam package
look at the source code
Is anyone here ok with disnake ? 
most people here use disnake
cuz my button doesnt work anyone after i restart my client :(
and i wanna know how to fix that
heres my code
class VerifyButton(disnake.ui.View):
def __init__(self):
super().__init__(timeout=None)
@disnake.ui.button(label="✅ Verify", style=ButtonStyle.green, custom_id="verify")
async def verify_button(self, button: disnake.ui.Button, interaction: disnake.MessageInteraction):
role = interaction.guild.get_role(838801845530919002)
if role in interaction.user.roles:
embed = disnake.Embed(
title = "You are already verified!",
color = disnake.Color.red()
)
await interaction.response.send_message(embed = embed, ephemeral = True)
return
await interaction.user.add_roles(role)
embed = disnake.Embed(
title = "You have successfully verified!",
color = disnake.Color.green()
)
await interaction.response.send_message(embed = embed, ephemeral = True)
return
``` hope anyone can help 
You need to make the button persistent in order for it to work after restarts. Take a look at this example https://github.com/DisnakeDev/disnake/blob/master/examples/views/persistent.py
What amount of code knowledge should i have before starting to make a discord bot
Basics of python, like types, etc. You'd want to know at the very least OOP (Object oriented programming) and asynchronous programming
No
how come
I've never spoken to him
someone can help with this?
shame
on_message > check if the message content ```py
r"(?:https?://)?discord(?:app)?.(?:com/invite|gg)/[a-zA-Z0-9]+/?"
Hey guys, im coding a Discord bot, and i need to add a role to a user upon a message event.
i found this on stackoverflow
var = disnake.utils.get(message.guild.roles, name = "12")
member.add_role(var)```
"12" is the name of my role
message.guild.roles simply does not exist.
Guessing thats a age role
copying code from stack overflow like all devs 🗿
No its just a placeholder, since you can't mispell 12 lol.
thats the urban dictionary definition of development 🤣
member = message.author
var = disnake.utils.get(message.guild.roles, name = "12")
member.add_role(var)```
full code any one know whats wrong
Where is this code
on my screen?
In a command or?
Okay
Do you get an error when you use this?
File "c:\Users\giftc\OneDrive\Desktop\Python\Discord Bot\cogs\verfication.py", line 70, in on_message
print(message.guild.roles)
AttributeError: 'NoneType' object has no attribute 'roles'```
also i tried printing message.guild.roles
it doesnt exist, but all solutions online include it
Try to print message.guild
None
it prints None
OHHH
i think i know whats going on rn
Wait
gimme a sec
I was gonna ask if its in dms or not but wanted to make sure
it is in DM's lol
server_id = 932378633463562290
print(server_id.guild)```
this doesnt work either lol
server_id.guild? 
What's server_id?
supposed to be the ID of the server..
all these results are very outdated im finding
trying to take a new approach.
An int has no guild attribute...
yeah, i know im just trying everything i can think of
this is what i have currently
the_role = disnake.utils.get(942138061792378931)
await message.author.add_roles(the_role)
this gives me the error
File "C:\Users\giftc\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\utils.py", line 480, in get
for elem in iterable:
TypeError: 'int' object is not iterable```
942138061792378931 is the Role ID
this is a on_message event btw
u need to put disnake.utils.get(message.guild.roles, id = <id>)
Hello i need to know, have any difference between discordpy and disnake?
just the names nothing much
discordpy is official lib of discord and disnake is a fork
yes nearly nothing
here the guide to disnake https://guide.disnake.dev/
Thx so much ;)
message*
theirs no context on a on_message event
wha
yw
would only work if the message param were name ctx
official makes it sound like it was Discord-endorsed, it was just the most adopted python library
most popular wrapper for the discord api thats writing in python
but its not official*
uh yes lol im a newbie been a month since i started python
all good 😄

and iirc the discord api is written in js
It is not official
It's just the most popular
ohh okk
that event only takes payload
lol
newchannel = await
altchannel.guild.create_text_channel(f'{channel.name}-{memberline2}', category=category)
await newchannel.edit(sync_permissions=True)
for member in members:
overwrites = newchannel.overwrites_for(member)
overwrites.send_messages = True
await newchannel.set_permissions(member, overwrite=overwrites)```
When the code doesnt give u errors 😔
indentation and error handler 
Its not overwritng perms as usual
not indentation that was discord's fault
when i pasted
ah
discord is mean >:C
True
error handler eating it perhaps?
specifclly overwrites
its not overwriting the member to read the channel
and yes the member object is indeed a member object lol
is newchannel created?
yes it does get created
and it syncs the perms to category as intended
try adding a few prints here and there imo
i guess?
does it loop?
members list might be empty
its not empty cuz i did a ping test prior to it
list check*
interesting
it grabs the members from an existing VC channel and created a discord channel for the people in the vc
like a queuing system if that makes sense lol
except it doesnt queue the members...
which fork/version are you using?
nextcord ofc
ofc 
im using the discord.py code so that might be why
well the docs says overwrites_for* wants a user object, not a member object
well some of it
a discord.User not a guild member?
yes sir, worth a try?
i mean a guild member would make more sense but sure why not
client.fetch_user ye?
get_user sure
ah get_user
also use Bot instance when 
client.Bot.get_user?
or u mean my decorator?
If they don't want to make commands, then client is fine
^ that too, I meant using the Bot class for your bot, not the client
bot = nextcord.ext.commands.Bot() client = nextcord.client()
im making this specifc line of code off a on_voice_state_update event btw
i mean
do the prints reveal anything?
didnt try it yet
what is cogs and how is it used in discord bots development
lemme try the user object idea rq
cogs are (wait I had it somewhere let me find copy paste)
A "Cog" is just a class dpy implemented and you subclass in order to develop in multiple files
EXCELLENT!
u were right
just needed the user object not guild member object, thanks mate
cogs are used to keep code in order
k
Cogs are a very important part of discord.py which allow you to organise your commands into groups - not to be confused with actual command groups, which will be explained later in the tutorial.
tnx
is there a way to not get rate limited?
good code
Not using repl
cooldowns and ^
what would I have to use
!hosting 
so I have to buy a server?
how to make a bot which has interactive welcome message setup?
Yes
how much do servers usually cost
there are a few hosts out there, let me quickly paste a tag
-
Get a cheap VPS
A VPS is a good way to run your bot 24/7, and they can be rented quite cheaply from various companies, some hosts include:
https://scaleway.com/ (EU) https://digitalocean.com/ (US)
https://linode.com/ (US/EU/Asia) https://www.hetzner.com/cloud (US/EU)
We recommend you compare the options before choosing a provider, and look for other providers that suit you well. It is also possible to use free trials of services AWS, GCP, and Azure to run your bot for up to a year for free on a low power machine. -
Host locally
If you have a RaspberryPi this can be used as a bot host quite easily, and many tutorials exist for it online. You can also host a bot on your PC if you keep it on 24/7.
This is not recommended due to the investment involved as well as your network stability
If you are using your PC you should consider using a VPS provider instead.
Note:
Free hosts, such as Heroku, Replit, and EpikHost, are not good hosts for your bot. Heroku and Replit are designed for websites, which is why they expose a domain for you. EpikHost is known to give away customer information and it is advised that you do not use them for this reason.
on_member_join send the views with everything
cheaper than you might think
I use aws one year free without any prolem (my bot has 10k users) and even after the free period, the same specs are like 6$ a month
so that'd be on digitalocean?
amazon
aws
something wrong pls help
google, first or second hit
kk
You can also get a free for life vps from oracle if u have a cc
😳 specs of the vps?
24 gb ram
but could I still code it on replit or would I have to move the code somewhere else
that's too good for free
Oracle is just different
I also sent that yesterday haha
i sent it a week ago 😔
sigh site wont load 
Aws also gives something like that for 1 usd
idts
Yeah they do
I get an ubuntu 16.04 with 1 VCPU and 1 gb ram at 6$
still wondering about this
Iirc in oracle
but then it's a full fledged virtual machine, perhaps it must be different for vps
need to move it to your new host
you can code it anywhere
but you would need to have the source in your vps/host
but the code will still work when I move it over right like how much do I have to change
cause still want to use it on replit rn until it's finished
depends on the host
yup just code it locally in pycharm or something then yeet the new code to your host to run it
some hosts use pyproject.toml/poetry for installing reqs
some will do that for you with requirements.txt/an option to add packages
you don't need to change anything considering you are using the same python and lib version, some things might have to change if your using the sys or os module / interacting with the vm/vps
some things like file paths will also change
alr alr thnx for the info

I wanna make a repo for my bot and on my host, automatically pull everything from the GitHub so I can directly commit stuff to the repo from my vsc and ez update, though I'm having a problem even making the repo lmao, it just doesn't ignore venv and the secrets file
use .gitignore file
i did
you can specify the files and venv there ```
.env
venv/
rin 😔
dont make a new repo, just clone it on your device again and it will work
vsc is sometimes buggy with it :V
👁️
You would be surprised by how little I know
would I be able to use one amazon web server for both a discord bot and a website or only one thing at a time
I've literally been doing this for a week
I know one that sounds too good to be free
Wanna hear
sure
How would I go about making an uptime command
I just want to see how long the bot has been up
Hi i would really appreciate some help if anyone has time. I'm pulling some data from an API and displaying it on my bot activity but the data is displaying weird have no idea how to fix it. I recently replaced the api. Not sure if maybe the way i'm round the decimals is creating the error?
async def loop():
token = open('crypto.txt', 'r').read()
url = f"https://api-v2-mainnet.paras.id/collection-stats?collection_id={token}"
data = requests.get(url).json()["data"]["results"]["floor_price"]
price = str(round(float(data)*10000)/10000)
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="💎 $"+price))```
Make a start time then subtract the current time from it to get the uptime
It's being shown in exponential format
Check if thats what the api is returning
Nop the api returns this
how do I make a start time and literally everything else you said please
!d datetime.datetime.now
classmethod datetime.now(tz=None)```
Return the current local date and time.
If optional argument *tz* is `None` or not specified, this is like [`today()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.today "datetime.datetime.today"), but, if possible, supplies more precision than can be gotten from going through a [`time.time()`](https://docs.python.org/3/library/time.html#time.time "time.time") timestamp (for example, this may be possible on platforms supplying the C `gettimeofday()` function).
If *tz* is not `None`, it must be an instance of a [`tzinfo`](https://docs.python.org/3/library/datetime.html#datetime.tzinfo "datetime.tzinfo") subclass, and the current date and time are converted to *tz*’s time zone.
This function is preferred over [`today()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.today "datetime.datetime.today") and [`utcnow()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow "datetime.datetime.utcnow").
Make a variable with that
Thank u, and what
make a variable with what
With this
just use the string format of that and it will work
Assign a variable to that
name="💎 $"+str(price)
Ok will try that thanks
Oh but price is already a string
@tasks.loop(seconds=20)
async def loop():
token = open('crypto.txt', 'r').read()
url = f"https://api-v2-mainnet.paras.id/collection-stats?collection_id={token}"
data = requests.get(url).json()["data"]["results"]["floor_price"]
price = str(round(float(data)*10000)/10000)
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name=":gem: $"+price))```
What do I assign it as, only ‘datetime.now’ has the red squiggly line under it
ah its because of the mathematical operations your perform
Epic make look like code fail Xd
You know how to assign a variable, right?
why multiply it my 10000 and divide it again?
my_var = "is amazing"
Yes, but what do I assign it as
What’s after the = sign
this
So I can set how many decimals I want
round(number[, ndigits])```
Return *number* rounded to *ndigits* precision after the decimal point. If *ndigits* is omitted or is `None`, it returns the nearest integer to its input.
For the built-in types supporting [`round()`](https://docs.python.org/3/library/functions.html#round "round"), values are rounded to the closest multiple of 10 to the power minus *ndigits*; if two multiples are equally close, rounding is done toward the even choice (so, for example, both `round(0.5)` and `round(-0.5)` are `0`, and `round(1.5)` is `2`). Any integer value is valid for *ndigits* (positive, zero, or negative). The return value is an integer if *ndigits* is omitted or `None`. Otherwise, the return value has the same type as *number*.
For a general Python object `number`, `round` delegates to `number.__round__`.
just round the value
^
classmethod
datetime.now(tz=None)
time.time()
I did it here but it broke the bot
i know for a fact im doing this wrong, how do i fix it
@tasks.loop(seconds=20)
async def loop():
token = open('crypto.txt', 'r').read()
url = f"https://api-v2-mainnet.paras.id/collection-stats?collection_id={token}"
data = requests.get(url).json()["data"]["results"]["floor_price"]
price = str(round(float(data), 2)
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name=":gem: $"+price))```
you want it with decimals or without decimals?
With 2 decimals
!e py num_str = "1234565325632653.34532" print(round(float(num_str),3))
it should work then, are you sure the data that website returns is in numeric form?
@bot.command(name="uptime")
async def uptime(ctx: commands.Context):
await ctx.send(f"{client.uptime}")
quick google check, this should work?
That would just send when the bot was started
they're in the same dir, just adding database.db to the gitignore will work right? no . or /?
I would add *.db to the .gitignore to ignore all db files
Means you won't need to manually add it for each db file you have
i see, thanks
@bot.command(name="uptime")
async def _uptime(self,ctx):
uptime = str(datetime.timedelta(seconds=int(round(time.time()-startTime))))
await ctx.send(uptime)
i need to define startTime, any idea on how
i dont relly understand this
Tbh I just don’t get the startTime part
I think my question is too specific for Google
Make a bot var
And variable/function names should be named in the snake_case convention
camelCase should never be used in python
why start_time instead of startTime
Because pep8
and what is the time code in this case
!pep8
PEP 8 is the official style guide for Python. It includes comprehensive guidelines for code formatting, variable naming, and making your code easy to read. Professional Python developers are usually required to follow the guidelines, and will often use code-linters like flake8 to verify that the code they're writing complies with the style guide.
More information:
• PEP 8 document
• Our PEP 8 song! :notes:
oh I see
Is doing sys.exit() the exact same thing as raise SystemExit ? 
!d datetime.datetime.now
classmethod datetime.now(tz=None)```
Return the current local date and time.
If optional argument *tz* is `None` or not specified, this is like [`today()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.today "datetime.datetime.today"), but, if possible, supplies more precision than can be gotten from going through a [`time.time()`](https://docs.python.org/3/library/time.html#time.time "time.time") timestamp (for example, this may be possible on platforms supplying the C `gettimeofday()` function).
If *tz* is not `None`, it must be an instance of a [`tzinfo`](https://docs.python.org/3/library/datetime.html#datetime.tzinfo "datetime.tzinfo") subclass, and the current date and time are converted to *tz*’s time zone.
This function is preferred over [`today()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.today "datetime.datetime.today") and [`utcnow()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow "datetime.datetime.utcnow").
@bot.command(name="uptime")
async def _uptime(self,ctx):
uptime = str(datetime.timedelta(seconds=int(round(time.time()-start_time))))
await ctx.send(uptime)
start_time = classmethod; datetime.now(tz=None)
like this?
what u prefer custom help command as help command = none or in built?
The resources I tried aren’t helping ;-;
Custom help command obviously
The default one is ugly as hell
haha ya
Oh hey it’s dynos brother
hehe
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
Python/sysmodule.c lines 863 to 870
static PyObject *
sys_exit_impl(PyObject *module, PyObject *status)
/*[clinic end generated code: output=13870986c1ab2ec0 input=b86ca9497baa94f2]*/
{
/* Raise SystemExit so callers may catch it or clean up. */
PyErr_SetObject(PyExc_SystemExit, status);
return NULL;
}```
you're using vsc right?
yes
its a private repo, I wanna ignore venv because its annoying to push it every time
dont you use source control?
left click on the files you want to add to gitignore and use "add to gitignore"
makes life easier
right click?
oh yes right click
ah
sec
seems the venv files arent there in the "changes" anymore
though I can see this green marker which I think means "new files"
cool, and ill assume you use the source control for push too?
yep
see what file is it indicating
!afk command comes in which category?
Lib\site-packages and some of the packages inside it
.
afk command comes in which category?
Utility or Misc imo
how to create these types of button
they are normal buttons with custom emojis
pls provide button docs
!d discord.ui.Button
class discord.ui.Button(*, style=<ButtonStyle.secondary: 2>, label=None, disabled=False, custom_id=None, url=None, emoji=None, row=None)```
Represents a UI button.
New in version 2.0.
ok
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/usr/local/lib/python3.7/dist-packages/discord/ext/commands/core.py", line 855, in invoke
await self.prepare(ctx)
File "/usr/local/lib/python3.7/dist-packages/discord/ext/commands/core.py", line 789, in prepare
await self._parse_arguments(ctx)
File "/usr/local/lib/python3.7/dist-packages/discord/ext/commands/core.py", line 697, in _parse_arguments
transformed = await self.transform(ctx, param)
File "/usr/local/lib/python3.7/dist-packages/discord/ext/commands/core.py", line 542, in transform
raise MissingRequiredArgument(param)
discord.ext.commands.errors.MissingRequiredArgument: ctx is a required argument that is missing.
class Uptime:
def init(self, bot):
self.bot = bot
@bot.command(name="uptime")
async def uptime(self, ctx):
current_time = time.time()
difference = int(round(current_time - start_time))
text = str(datetime.timedelta(seconds=difference))
await self.bot.ctx.send("Current uptime: " + text)
just dont push it :p
i literally do not get this, monkey brain is die
you can always sync changes using this
ig lol
yeah
oh wow that fixed it, amazing
You're not in a class. You don't need self
So the self should just not exist
Remove it
self.bot.ctx.send, ctx.send is enough
Alr thanks so much for the help
so if u trying to make a cog file, use commands.command instead of bot.command
class Uptime:
def init(bot):
@bot.command(name="uptime")
async def uptime (ctx):
current_time = time.time()
difference = int(round(current_time - start_time))
text = str(datetime.timedelta(seconds=difference))
await bot.ctx.send("Current uptime: " + text)
says uptime isnt a command
Button is a class, @button is a decorator
there's no button method
ok
Are you trying to make a cog?
The init has __ beside it and __ after it
Yes
I can feel the rage of pep8 compliance officer
@commands.command(name="uptime")
async def uptime (self,ctx):
current_time = time.time()
difference = int(round(current_time - start_time))
text = str(datetime.timedelta(seconds=difference))
await ctx.send("Current uptime: " + text)
thank so much for real
@slate swan components = #button??
make intendations correct
like this
Don't spoonfeed
oh sry
gnoring exception in command None:
discord.ext.commands.errors.CommandNotFound: Command "uptime" is not found
start_time = time.time()
class Uptime:
def init(bot):
@commands.command(name="uptime")
async def uptime (self,ctx):
current_time = time.time()
difference = int(round(current_time - start_time))
text = str(datetime.timedelta(seconds=difference))
await ctx.send("Current uptime: " + text)
tfym uptime isnt found
same thing happened with old code
A tutorial on how to use discord.py to create your own Discord bot in Python, written to fix the flaws of many other popular tutorials.
actually ur code is wrong
Check out their section on cogs
wat
@final iron bro i wanted to know that how to ban some one fast like if we use normal guild.ban then some nukers get bans after 50 bans btw it is too slow how to stop nuker at less bans bro, i was using httpx with v9 api still stopping nukers at 47 bans
Don't ping random people for help
@final iron no i wanted to ping u only, i thought that u r a proffesional
🥲
and u can help me
I haven't interacted with you recently
yes btw......
My point still stands. Don't ping random people for help

uh?
bruhhhh somebody help me with my bot plsss iam using https still getting nukers stop at 47 bans
😑 😑 
how to call something when button is click like editing a msg??
!d discord.ui.Button.callback
await callback(interaction)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
The callback associated with this UI item.
This can be overriden by subclasses.
Does anyone know how to add your discord bot to multiple servers instead of just one? (Feel free to DM me.)
Just invite it?
how could i put embeds in these
!d discord.Embed
class discord.Embed(*, colour=Embed.Empty, color=Embed.Empty, title=Embed.Empty, type='rich', url=Embed.Empty, description=Embed.Empty, timestamp=None)```
Represents a Discord embed.
len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.
bool(b) Returns whether the embed has any data set.
New in version 2.0.
Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty").
For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") for you.
where would i put the embed?
ik how to use embed but it set up diff
Anywhere you want?
doesnt show as embed
because u are returning so the code below it before the else doesnt reach
thats why its grayed out
so where do i put it?
change guild.roles() to guild.roles and try,in line 22
oh sure
below the send method I suppose
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'coroutine' object is not iterable
@bot.command(
aliases=["find", "google", "src"]
)
async def search(ctx,*, query):
author = ctx.author.name
async with ctx.typing():
s = discord.Embed(title=f"Here are the links related to your question {author} !", description=query, colour=ctx.author.color)
for j in search(query, num_results=10):
s.add_field(name=j,value=":arrow_up:",inline=True)
s.set_footer(text="Have any more questions:question: Feel free to ask again :smiley: !")
await ctx.send(embed=s)
:bruh:
