#discord-bots
1 messages · Page 619 of 1
I was really into it, it felt really OOP-y to me and I was a big fan of that haha
Thats funny
Ive always been told to do a a custom help command cuz of "customization"
Oh yeah sorry for not saying it earlier but @sick birch great to see you 
heh, i seem to remember seeing you in the d.py server as well. great to see you as well!
i am new to slash commands so i was trying with shash commands examples , so it was working when guild id is given
so can we do without it?
is there any way
What is "it"?
slash commands
discord slash
And how did you provide guild ID? i'm pretty sure that's not an option
Yeah
you can do that without providing a guild id , but it will take around 2hrs to get itself registered
Oh i see
Yeah for testing purposes do it guild only, for public changes do it without a guild id
This is the place I stay most of the time on discord lol
*them = the time
Thats cool
@novel bolt this. Was for u
Love to see all the regulars here always like to be nice and greet them
oh i ddint see that
how to do it?
basically , you just remove the guild_ids parameter
If you remove it , the command gets added globally ( i.e. in every server your bot is in) , it takes around 2hrs for this process to complete
If you use guild_id , as you are doing rn
The command gets added in the guild whose Id you provided , it takes no time to get added in this case
i had tried it yesterday without any guild ids
oh
read the last line , you need to wait for 1-2 hrs

ok
mine is just for my server so ..
Are you making the bot/slash command for a single guild?
so bot should be online for 1-2 hrs?
yea just trying(for fun)
yea I think so
What library are you using?
discord slash
In most of the libraries you can add the guild ids to your bot object instead of adding them in every command
Dont know if it makes them happier or thankful but i always like doing it
oh got it
thank you
i think it's fine to be offline, as you have made a request to discord
it doesn't matter if the bot is online or not, it's just a post request at the end of the day
it has nothing to do with your bot's gateway status
I see , I was unsure about it
thanks!
Yw , and you dont need to keep it online for all time as icy said
oh nice
Is the gateway the connection the user has with the discord api?
correct
Ah i see 🤔
it's at it's core a websocket connection
Yea basically the sharing of data ( recieving events and making reqs ) happens with it
it's basically a discord for discord
Alr
Gateways are Discord's form of real-time communication over secure WebSockets. Clients will receive events and data over the gateway they are connected to and send data over the REST API
According to docs
the server and your client can talk to each other in real time
Thx for both of you🤔
#help-burrito about bots
gateway - events
the api - fetching messages, guilds, user data, etc
Yes
Thank you @sick birch and @slate swan very professional 🤔
Great to see you again
Cool
Ikr
It was just a quick search in the docs tbh👀
Lmao
🤷♂️ 😭
i used my last brain cell 😂
Dang you really said sorry little one😭
(Marvel reference)
Damn bro you all pros
could you show the command's code and the cog
sure
Me as a pro used discord.Client for making all the commands
Hey @unkempt jewel!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
That's weird , did you restart the bot?
One time i was so tired i tried to compare a int to a array of strings😭
And is the cog loaded?
I wanted to duplicate a channel in my guild so I made thispy g=ctx.guild for c in g.channels: if c.name=="staff": ch=await g.create_text_channel(name=f"copy-{c.name}")
How can I copy every role permission from my old channel to new channel??
its loaded
Happens ...
Happens to the best of us
😭
uhm can u guys help me ://
you can get the permission object for the channel using channel.permissions
And use it inside it
Hi
Can you explain how can I get role permissiom for Channel I know how to get it for guild but not channel
how to ummmmmmmmmmm
help
make a ummmm
me
music bot
yes?
@unkempt jewel seems like you have 2 Card cogs?
Cards and Card2
@slate swan im still confused on how he has channel assigned to a variable and it still executes the coroutine is it because its a async function?
whats the question?
and the Card cog hasn't really loaded
youtube :v
youtube?
it doesnt work.
!ytdl
Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.
For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:
The following restrictions apply to your use of the Service. You are not allowed to:
1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service; (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;
3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;
9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
You can try using channel.clone
no
Against tos^
The class name there is different from the one you shared
How can I?? I never used it
Just use something else
so what should i do now
its possible , like people often use ```py
msg = await channel.send(....
and later
await msg.edit(...```
Notice the class name
IDK if it copies channel permissions
It does
Share the right cog, and also check if you have the collect command in the right one
Well, you can try.
Clones this channel. This creates a channel with the same properties as this channel.
i got collect here
How does it send something if its a var😭
I dont get it 😭
Like i know it does send but why???
!e py m = print("like this")
@slate swan :white_check_mark: Your eval job has completed with return code 0.
like this
I thought it was cause its a coroutine but idk
Wait a damn minute
the line is interpreted and executed rather than just assigning the value
My life is a lie
MY LIFE IS A LIE I THOUGHT THAT WAS NEVER POSSIBLE😭
pip install -U life
What if I want to clone the channel in my backup guild??
It returns the channel that was created
NameError: name 'life' is not defined

#help-burrito more helpers needed
*an.
And good to see you here too
import it
yo im waiting for help ._.
still waiting...
okimii help ._.
Simply how can I get permissions of each role from a specific channel
No. CONTINUES TO COMPARE A INT TO AN ARRAY OF STRINGS
!d discord.TextChannel.permissions
No documentation found for the requested symbol.
Why wait
stop doing that :vv
Im sorry😔
!d discord.TextChannel.permissions_for maybe?
permissions_for(obj, /)```
Handles permission resolution for the [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") or [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role").
This function takes into consideration the following cases...
Ignoring exception in command None:
discord.ext.commands.errors.CommandNotFound: Command "collect" is not found
They need overwrites for a channel
Oh ye
I literally did:
if int == "str":
🤦♂️
lmao what?
!d discord.TextChannel.overwrites
property overwrites: Dict[Union[Role, Member], PermissionOverwrite]```
Returns all of the channel’s overwrites.
This is returned as a dictionary where the key contains the target which can be either a [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") or a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") and the value is the overwrite as a [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/master/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite").
Here ^
I was tired ok.
Ok here is my code of what am I doing py for g in Blank.guilds: if f"copy - {ctx.guild.name}" in g.name: for c in g.channels: await c.delete() for cate in ctx.guild.categories: x = await g.create_category(f"{cate.name}") for chann in cate.channels: if isinstance(chann, discord.VoiceChannel): await x.create_voice_channel(f"{chann}") if isinstance(chann, discord.TextChannel): await x.create_text_channel(f"{chann}") for roles in ctx.guild.roles: await g.create_role(name=roles.name, colour=roles.colour, permissions=roles.permissions) try: await g.edit(icon=requests.get(ctx.guild.icon_url).content) except Exception: pass
ctx.guild is the original guild
please help me ._.
- You haven't load the cog
- on_message issue
- You're setting it wrong
Do i seem that smart bro your smarter than me i literally dont know abour dbs i only know json which isnt a db
😭
See icy is smarter
@slate swan
This is what I am trying to do
it works fine
why me
how to laod the cog ._.
you are trying to copy a complete guild?
yea
why not both of u ?
Why not only you?
if im smart i wont be here to ask :?
let's not go ot
I want to copy the permissions of each role in each channel from previous guid to new
Why am i here🧍
for help me :vvv
!d discord.ext.commands.Bot.add_cog
add_cog(cog, *, override=False)```
Adds a “cog” to the bot.
A cog is a class that has its own event listeners and commands.
Changed in version 2.0: [`ClientException`](https://discordpy.readthedocs.io/en/master/api.html#discord.ClientException "discord.ClientException") is raised when a cog with the same name is already loaded.
and load_extension
h o w
🧍
where can i put this?
I see , that would be complex , since Roles are guild binded , and you cannot edit a role's permission in a channel which is not in the role's guild
Irrc bot.add_cog(cogname())
role names in both guild are same
no :v
where to put :bbbbbb
sigh
literally answered you, main file
yea , and you pass the bot object in cogname if you want. Something like self.bot
Bottom of your code above your run
Yup
has a stroke
put it in your cog file
has a even bigger stroke
nu okimii , it's normally done like
bot.load_extension("path to the cog") , the load_extension method call the setup function inside the cog , where bot.add_cog exists
so
or , you need to import the Cog class from the cog file and use the method you told
how can i fix this, can u fix this for me :)
Does other commands run?
Ohhhhh yeah i forgot thats a thing😭
Add bot.process_commands(message) at the end of all your on_message events
( events I said , not listeners)
Don't u use cogs? Just asking
No🥺 😭
you should , makes life easier
I do know how to i just find them over complicated and never do them😭
https://github.com/sarthak-py/disnake-template/tree/main/cog_examples have a look, it maybe helpful
I really should im just too lazy and im scared idk why when i know how to completely use them and i know about classes
I have
Lmao
it's a bit of OOP stuff , once you are comfortable with object oriented programming , you'll rock it
@slate swan How to get role from name?? (any other way than discord.utils??)
I do tho 
other than utils.get , you can iterate thru guild.roles and check role.name
ook
Im just to lazy to do cogs 
I was too , but when my main file crossed 2000+ lines it was hard to handle and fix stuff
I dont worry most of my files rn dont pass 300+ lines
Like being efficient
I see
Not that their basic but im just efficient ig
I tried cogs inside main file once , just to make the help command a bit less uglier
I just made a list and used .join on the desc of a embed
lol it was for command categories
I see🤔
have they call the run function?
No idea , I just saw the cog file and not the main one
but yes since the bot is online , sure
@slate swan Do you think if this would work for the roles stuff I was doing before?? py for channel in ctx.guild.channels: ch=discord.utils.get(g.channels, name=channel.name) for role in ctx.guild.roles: nr=discord.utils.get(g.roles, name=role.name) ch.permissions_for(nr)=channel.permissions_for(role)
Cogs scare me for no reason 
I mean this run function
Regenerate your token
@slate swan You just leaked your token regenerate it
permission_for is used for getting permission , you need to use channel.edit(overwrites= ) to edit them

@slate swan what library are you using?
Yea they do , it gets printed in their console
Also none of their commands were working so it was an on_message issue ig
well, firstly we can't help you if you don't even know what lib you're using
ok
We cant even see your error anymore
Wait how can I edit role perms using overwrites then??
overwrites (dict) – A dict of target (either a role or a member) to PermissionOverwrite to apply to the channel.
so, it's something like
await channel.edit(overwrites={role_object: PermissionsOverwrite(...)})
Can anybody please explain whats a property in the dpy docs i kinda dont know cuz i knew but i forgot cause the answer wasnt clear
Icy just told ya
basically a function , which you don't need to call iirc
Ah i see🤔
!e
class b:
@property
def a(self):
return 1
print(b().a)
@boreal ravine :white_check_mark: Your eval job has completed with return code 0.
1
it's a property of the class, it doesnt take any arguments/parameters
Imagine not using capital letters for class names ;-;
Good to see you here and thank you🤔 
Good*
Goose 😳
Lmao
Yes
😳
I tried my best 😔
I don't have time to click the shift key everytime I do a class
i just realized we are all indians so the same people meet at the same time
well most of us
I wish i was
I'm not
I love my indians bros ngl
What's a property?
A property is a method/attribute from a class which must return/yield value(s).
What makes it different from normal attribute?
For example I have a bot "icy" which I store the name in class Foo
Normal attribute:
class Foo:
def __init__(self):
self.name = bot.user.name
a = Foo()
print(a.name) # icy
# then if I for example edit the bot name to "someone" then self.name is not updated
print(a.name) # still icy
Property:
class Foo:
@property
def name(self):
return bot.user.name
a = Foo()
print(a.name) # icy
# then if I for example edit the bot name to "someone" then self.name is not updated
print(a.name) # someone
something like that
Gosh i love icy your so professional 🥲
lmao hunter
Even if its from docs😭
It's a pro
Yea, it hurts 🥲
Ofc ofc
I'm just bored so I wrote something...
Yea yea

what. is. that
You guys are all fun to talk to ngl
my english is trash tho
The error I am getting when I go to VPS Website
Doesnt matter your cool
.-..-...(imagine these as beats and tell me what it is)
Your a poopy head for correcting my grammar
icy: My English is trash
Also icy: Speaking better English than me
what vps do you host on
😐
Your cool cuz you cant take a joke
Friend's
This. Is. The. Most. Active. Topical. Chat.
my english is trasher than yours
indians....

Your status 👌
Facts
Yes
Yes
Anyways it's all OT
time to eat brb
!ot please
Off-topic channels
There are three off-topic channels:
• #ot2-never-nester’s-nightmare
• #ot1-perplexing-regexing
• #ot0-psvm’s-eternal-disapproval
Their names change randomly every 24 hours, but you can always find them under the OFF-TOPIC/GENERAL category in the channel list.
Please read our off-topic etiquette before participating in conversations.
With life imported
Have a great meal \👍
thanks
don't y'all think this is becoming more OT talks
Then think like that (:
Basically import everything from life
Xd
Anyways cya guys. , I need to get my admit card today lol
Smort
Wait let me import all my life
Pleasure to talk to you 
I get a name error
!pypi life
Kk
How active server
Your brain is outdated no offense
Ik
Its like replit with its module errors
Mhm
Very active
!ot
Off-topic channels
There are three off-topic channels:
• #ot2-never-nester’s-nightmare
• #ot1-perplexing-regexing
• #ot0-psvm’s-eternal-disapproval
Their names change randomly every 24 hours, but you can always find them under the OFF-TOPIC/GENERAL category in the channel list.
Please read our off-topic etiquette before participating in conversations.
@sullen shoal @slate swan is missing you
didn't I do that, like, a minute ago but everyone ignored me?
My finger slipt
This is a litlle bit active server
Yea yea

5 minutes ago
Please no one ss😭
Ofc hes my son okimii.jr the ||| 
I wanna make a bot count how many strokes i have a day how may i start?
Strokes?
Yeah like i basically die for a bit of secs
use Arduino
Good dang idea 
:)
Use a db to store the data, make a command that increments the value in the db by 1 everytime you use it, and you're done
Should i add a except if i die?
Maybe make it give a little feedback too to let you know that you had a stroke just in case you forget
Good idea
:kek:
Automation tho
How are you gonna automate your strokes
who said that
What were we talking about again :kek:
I want it to automatically check for my strokes using a sensor
About a bot that counts your strokes
Yeah
Oh :kek:
:kek: 😔
😔
What if i call the api(my heart) and i call it to much will it stop my strokes?
There's 8 kids and first class started 😭
Probably
hm i got a notification
What grade are you in?
Cause im a freshman
hello okimii
10th, in other countries I'd be 11th, different school systems
Who that
oh
Ship
Ah i see
hello pablo
(No homo)
?
I was one last year 
wtf
alright i gotta eat my chocolate before it melts
Damn and you aint even sharing😔
:kek:
this chocolate is mine

It's fine I hate chocolate anyways 😎
@slate swan rate the name?

SyntaxError
You like nutella dont you
No
I don't like any kind of chocolate
Well, kinder is an exception
What kid doesnt like that lmfao
:kek:
Im to mature for a kinder
eats kinder
You're never too mature to eat a kinder 🍫 😎
Off-topic channels
There are three off-topic channels:
• #ot2-never-nester’s-nightmare
• #ot1-perplexing-regexing
• #ot0-psvm’s-eternal-disapproval
Their names change randomly every 24 hours, but you can always find them under the OFF-TOPIC/GENERAL category in the channel list.
Please read our off-topic etiquette before participating in conversations.
I only buy them for the toys👉 👈
😳😳
Not at all
😔
Smh stop being so boring no one's using this channel anyways 😔✌️
I thought kinder is for < 12 
If anyone asks we're talking about a kinder bot
NO IT ISNT
No it's not 😳
Kinder is all ages 😌
TAKE THAT BACK NOW
Last time I checked kinder didn't have an age requirement
Yes
tbh idek what chocolate i eat, i just eat them
Lol
I mean "usually"
Exactly 😡
like it's name speak for itself
If it contains diabetes count me in
💀
No it doesnt🤬
Anybody uses to sniff fundip
is kinder that thing with two small brown balls
😔
kinder is for five lol

You're so uncool
🤬

oh thats kinder joy
everyone bullies me
No you
!e
print("icy just eat a kinder youll feel better")
@slate swan :white_check_mark: Your eval job has completed with return code 0.
icy just eat a kinder youll feel better
I ate it once..
You chocked on it didnt you
Definitely
If you didnt ate it so quickly like no one is gonna steal it from you

icy has left the chat
the error says it all
I think you cant iterate a property
then listen to it
discord.Guild.members is a property
!d discord.Guild.members
property members: List[discord.member.Member]```
A list of members that belong to this guild.
My name says it all :kek:
although i never saw that error and it shouldn't either, looks like you have to use iter function over it
it should, he is trying to get the property from a class not an instance, which will never work
oh so they're one of those people
mhm
if you want to 
yeah if you want to
I hate how your flexing it rn
😭
tbh im already happy with the tag i got after my nitro ended and that's the only thing i like about nitro so now i dont need to buy nitro

I want it for the emojis
oh yeah, time to change my tag
🤬
what is self.guild

Bro wtf
Wdym u don't know
Kraots == icy??!??!
Just saying kraots has better grammar 
😳😳
😎
??
So it's not your code
a
Do you have any idea what you're doing
Your using the smort kinder egg brain power are you?
Shh 😳
how
Sorry im mean to people who dont like kinder eggs
And where are you defining what self.guild is
Just gonna say it is that mario as your pfp?
I don't see any "guild" keyword there
show the code for the cog
i dont see self.guild there
Makes sense
I like them but they're for kids
Arent you one?
We're all kids
😎
Deep down
Then we can't help you
nah, im mature
dont you gave the code on replit
You like to think so
You like them dont you😏
Maturing is realizing that everyone is a kid deep down
Ikr 💀💀
Hes just to scared to say it😭
Ikr
okay so its private only for 6 months
Smort
im an exception tho
tf is going on here

No one is
Nothing go back
Stubborn little one😭 
oof
Go back to your cave you gnome
Kk cya
✌️
Bye
Bye mr.gnome
Or maybe he just really likes mc :kek:
any repo?
not ready rn
😳
You with your kek i swear😭
:kek: 😔✌️
:kek:
:kek:
:kek:
Best of Luck Myxi!
thanks!
i got the two loops running one of which is the heartbeat thing now idk what to do with the recommended shards
Hmm
shards and keep alive (heartbeat) are the hardest to implement imo
indeed
why is this error happening when i added slash command
Maybe read the error
It clearly tells you that you can't have duped slash commands (slash with the same name)

same name as that of commands?
No, same name as that of other slash commands that you have in your bot
i onlyhave added one
The error says otherwise
discord_slash/client.py lines 93 to 96
if not hasattr(self._discord, "slash"):
self._discord.slash = self
else:
raise error.DuplicateSlashClient("You can't have duplicate SlashCommand instances!")```
it's not meant for duplicate commands
don't use light theme the error will go away
Ah mb
Red text on white is really shit
😓
@novel bolt do you have 2 external libs or something?
hey can anybody help me in python i am new to it
#python-discussion someone will help you
oh wait , i have dislash
pick 1
oh so that was teh prob
mhm
i used dislash for buttons
so use dislash for slash commands also then
oh ok thank you
Im goind to sleep gn guys love you all
gn
i used dislash coz in discord components i saw interactiont type removed
you dont actually need external libs anymore, there are many discord.py forks that have implemented everything
Like disnake, best fork
Not in revolt, since the heartbeat in revolt.chat API can be done anytime between 10-30 seconds haha
No hard calculations for that
Make sure you uninstall dpy and other 3rd party libs
Before i go to sleep you have to uninstall dpy?
Yes
lol
Could cause conflicts, seen it happen before somehow
So that it doesn't conflict with the namespace, yes
Cause i have disnake and dpy and it works fine
hmm
He's using python's default IDE I think
ye
Oh 💀💀💀
how about discord?
use multiline strings
for instance??
I saw discord docs once, discord wants us to do some calculations to send the heart beat, and not every 10 seconds or something
"""
Text
Here
Dum
Dum
Dum
"""

hmm
use multi line quotes
ok tysm <3
Where's that? Dpy?
im new sorry
yeah
It's fine
Ah, hmm. I would instead prefer a while loop with an asyncio.sleep(10) at last haha
That's what I do in my wrapper 🤷♂️
yeah data returned from HELLO op code * random.random() miliseconds for every heartbeat
Too much work tbh
Why not a simple one, like every x seconds or something 🤦
ask discord 
Eh, they weird tbh
Anyways, I should be getting a reply from discord ASAP tbh.. Since, well, I haven't heard from them since a week or something
On my bot verification
Let's hope for the best
I thought you prayed so your bot gets rejected?
I never "prayed" for anything, but I don't have much expectations
Since most are small servers
But let's hope for the best, shall we :D
who knows if the staff accidentally pressed "verify" button
Ye, let's hope that happens 🥺
lol 🙏
yes
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.
Whatttt
?
Sure
@client.command()
async def mute(ctx, member: discord.Member, time=None, *, reason=None):
format = datetime.now(tz=pytz.timezone('America/Tijuana'))
formatted = format.strftime("%I:%M %p")
b = DT.datetime.now().timestamp()
modlogs = client.get_channel(872909569196707870)
db = await aiosqlite.connect('database.db')
cursor = await db.execute('SELECT * FROM mutes')
rows = await cursor.fetchall()
muted = discord.utils.get(ctx.guild.roles, name="Muted")
farmer = discord.utils.get(ctx.guild.roles, name="Farmers")
apprentice = discord.utils.get(ctx.guild.roles, id=907127783849861120)
if ctx.message.author.guild_permissions.administrator:
if member is None:
e = await ctx.reply('You must mention someone to mute!')
await asyncio.sleep(5)
await e.delete()
await ctx.message.delete()
return
if time is None:
a = await ctx.reply('Please state a time for a timed mute or a reason for a permanent mute!')
await asyncio.sleep(5)
await a.delete()
await ctx.message.delete()
return
if reason is None:
if time[-1] in ['s', 'm', 'h', 'd']:``` This is quite messy, but is there a way that I can somehow determine if the `s`, `m`, `h`, and `d` are touching another letter, if so it does something?
```py
if time[-1] in ['s', 'm', 'h', 'd']:``` after this line of course.
what do i do if i just want the words to be in code block and not the commas for the synonym part 🙁 https://mystb.in/MeasuringNailParticipants.python
what i mean by that is (synonyms: word, word, word and so on)
synlist = ', '.join(synlist)
one way would be to do something like,
', '.join([... for word in synlist])```
@slate swan
word will be each element of the list
', '.join([... for word in synlist]) what else do i put before the word part
you gotta think about that, im not spoonfeeding that much
ok
my bot is now online yoooooooo
websockets nice
anything
@client.command()
async def embed(ctx,*,title,description,url):
await ctx.send("Enter the Title for the Embed")
def check(msg):
return msg.author == ctx.author and msg.channel == ctx.channel
msg = await client.wait_for("message", check=check)
if msg.content.lower() == "none":
await ctx.send("There should be a title argument, Please use the command again!")
return
elif await ctx.send("Enter the description for the Embed"):
if msg.content.lower() == "none":
await ctx.send("There should be a description argument, Please use the command again!")
return
elif await ctx.send("Enter an url for the image or write `None` to skip"):
if msg.content.lower() == "none":
embed = nextcord.Embed(title=title, description=description, color=0xA020F0)
await ctx.send(embed=embed)
else:
embed=nextcord.Embed(title=title, description=description)
embed.set_image(url=url)
await ctx.send(embed=embed)```
` i wnt that bot shud ask user for title desc and url, heres what i got can someone help me in this?
whats the error
I wanna make the fields in a list like that of @unkempt canyon
How to make a command specific to a channel?
this is easy
How 🤔
!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.
use inline as False
Check for the channel id/name
@prisma spoke
@client.command()
@commands.has_permissions(manage_messages=True)
async def session(message, ctx, info, *, name):
if message.channel.id == 912962943484066367:
mes = await ctx.send(f'**{ctx.author.mention} is hosting:**\n*Info: {Info}\Name: {Name}\nDate: {datetime.datetime.today().weekday()}*\n*Please react to this message if you plan on joining today! See you all there!*')
await mes.add_reaction(":heavy_check_mark:")
@boreal ravine
or wait
remove message from the parameter
says message is not defined
for commands, dont use on_message
thanks for pinging i wudnt have seen the msg tbh (not kidding)
use ctx.message. it's an instance for discord.Message
yea was a little confused
ctx.message(message, ctx, info, *, name)?
the first parameter of the function will be passed as the Context
currently, message is the Context
ctx an argument

I have a python code in my github encrypted as base64
When I print it using b64decode, requests.get....I get the string which also contains escape sequence....How can I fix it
!d discord.Client.wait_for use this
wait_for(event, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.
The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.
In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
ahhh
i am using it ?
Yes, so what seems to be the problem then
does discord_slash work for cogs?
@client.command()
@commands.has_permissions(manage_messages=True)
async def session(ctx, info, *, name):
if ctx.channel.id == 912962943484066367:
mes = await ctx.send(f'**{ctx.author.mention} is hosting:**\n*Info: {Info}\Name: {Name}\nDate: {datetime.datetime.today().weekday()}*\n*Please react to this message if you plan on joining today! See you all there!*')
await mes.add_reaction(":heavy_check_mark:")
```?
Im a little confused here, @boreal ravine I understood that message wouldnt go as the first parameter because its not the context
replace message with ctx and replace ctx.message with ctx.reply or send
it wud just say ("what shud be the description but not execute it or ask the url
Then make it ask for the URL too
just use ctx, no need to use message. ctx has an instance for every dpy class iirc
tip: ctx can't be used in events 🚎
perfect brotha thank u understood
you can get Context, if you want
i use commands.Context for no reason
you can actually
i did
tip: ctx can be used in events 🚎
if ctx can be used how tf do i ditch message.channel.send 💀
so whats the issue then 🤔
!d discord.ext.commands.Bot.get_context this should work i think
await get_context(message, *, cls=<class 'discord.ext.commands.context.Context'>)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Returns the invocation context from the message.
This is a more low-level counter-part for [`process_commands()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.process_commands "discord.ext.commands.Bot.process_commands") to allow users more fine grained control over the processing.
The returned context is not guaranteed to be a valid invocation context, [`Context.valid`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Context.valid "discord.ext.commands.Context.valid") must be checked to make sure it is. If the context is not valid then it is not a valid candidate to be invoked under [`invoke()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke").
It worked Thanks
wtf is this
gets you the context
getting context for an on message
not really worth it tbh
try removing bot.event and change it to bot.listen()
@bot.event
async def on_message(message):
await bot.handler.propagate(message)
await bot.process_commands(message)
message_split = message.content.split(".")
for message_word in message_split:
for bad_word in Filter:
if(bad_word == message_word.lower()):
await message.delete()
await message.channel.send("I have deleted that message :angry:")
``` I want to give the user Muted role, but how ?
maybe, but sometimes it is
still used to message.channel.send its simpler
when?
!d discord.Member.add_roles get the member instance
await add_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
i think it was member.add_role
yea the message above the message above is the right one
and give your bot manage_role perms
yes but I have to add member in my function and my other code in the function doesn't work
Cool
you will have better luck to find bad words if you use in statement
why do you need to add member in your function..?
To add muted role
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: type object 'datetime.datetime' has no attribute 'datetime'
show me your imports
allready told u
you dont, just get the member isntance add it
@client.command()
@commands.has_permissions(manage_messages=True)
async def session(ctx, info, *, name):
if ctx.channel.id == 912962943484066367:
mes = await ctx.send(f'**{ctx.author.mention} is hosting:**\n*Info: {Info}\Name: {Name}\nDate: {datetime.datetime.today().weekday()}*\n*Please react to this message if you plan on joining today! See you all there!*')
await mes.add_reaction(":heavy_check_mark:")
```?
I am tired a lot, made so many code
import datetime
must be from datetime import datetime; datetime.datetime
?
issue
o i just did import datetime 1 sec
you didnt, show me your code/error again
like?
!d discord.Message.author <=
it's an instance of member
ohh
whats ;?
i was guessing how youd import it to get that error
from datetime import datetime; datetime.datetime
AttributeError: type object 'datetime.datetime' has no attribute 'datetime'```
year is a string
!e print(1);print(2)
@sullen shoal :white_check_mark: Your eval job has completed with return code 0.
001 | 1
002 | 2
you dont have to do that
ohok what should i do instead?
wait now that i think of it
just from datetime import datetime and the function you wanna use
that's what you did,
correct way would be
from datetime import datetime; datetime....
the error in the console?
await discord.message.author.add_roles(role)
``` I think it's wrong  @boreal ravine
how do i make my bot and it's bad filter look for the filtered words in sentences like for example i have a filtered word called super then how would it delete messages like superb 💀
i did get it working for the main words tho
obviously, I told you to get the instance of discord.Member I didnt tell you to use the whole class
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: type object 'datetime.datetime' has no attribute 'datetime'
show me your code
ok but those are only selected words to be blacklisted tho
extremely long i'll type the method and import
what do you want then
you guessed what i wanted, but the only issue is that it's only limited to what words to be blacklisted
then what you do you want
someone = discord.message.author
someone.add_roles(role)
import discord
import datetime
from datetime import datetime
from datetime import *
import random
from datetime import timedelta
import asyncio
from discord.ext import commands
@client.command()
@commands.has_permissions(manage_messages=True)
async def session(ctx, info, *, name):
if ctx.channel.id == 912962943484066367:
mes = await ctx.send(f'**{ctx.author.mention} is hosting:**\n*Info: {info}\Name: {name}\nDate: {datetime.datetime.today().weekday()}*\n*Please react to this message if you plan on joining today! See you all there!*')
await mes.add_reaction(":heavy_check_mark:")
only use datetime and not datetime.datetime
datetime is the module name, datetime is the things in the module
a class
do you know what an instance is?
!d datetime.datetime
class datetime.datetime(year, month, day, hour=0, minute=0, second=0, microsecond=0, tzinfo=None, *, fold=0)```
The *year*, *month* and *day* arguments are required. *tzinfo* may be `None`, or an instance of a [`tzinfo`](https://docs.python.org/3/library/datetime.html#datetime.tzinfo "datetime.tzinfo") subclass. The remaining arguments must be integers in the following ranges...
no like super is blacklisted word for example and if someone said superb and it isn't in the blacklisted words list (like the url you showed in the example) so how do i make it block every str containing the bad word
no 😅
my bad, classes are usually upper case
regex I guess
add super to the blacklist?
well i do have words in the blacklist
but they can be bypassed using plurals or stuff
if it sees super, it will trigger
class Member:
...
class Message:
...
message.author = Member()
``` eh this is somewhat of an instance but you get what I mean
this is what i mean
fuck is blacklisted but it works with even iwhejejefucksehekekn?
no
if I do this then I can use ?await member.add_roles(role)
saying that also doesn't make the bot delete the msg
then delete it 🤔
The code I gave was an example, get the member instance from message
!d discord.Message.author <= this is the member instance
🤔 but im not gonna add 150 lines of code only to blacklist every str which has the bad word
!e
words = ("hello\nlol\npenis\nsuper").splitlines()
test_urls = ('wkwneffwfwlol', 'wefewefwfwfwpenis', 'wkejnfwkfsuperfidjndkdkd')
for url in test_urls:
for word in words:
if word in url:
print(f"{url} is blacklisted")
@sullen shoal :white_check_mark: Your eval job has completed with return code 0.
001 | wkwneffwfwlol is blacklisted
002 | wefewefwfwfwpenis is blacklisted
003 | wkejnfwkfsuperfidjndkdkd is blacklisted
I have no idea what to do with this
show examples in which it shouldn't work and in which it should work
I've always been a little confused with *. I understand it serves the purpose of allowing multiple words within the parameter but what if you have two different parameters that are gonna have multiple words? I dont know how to exactly explain what i think of it
should work with every str containing the bad word
passes all the arguments after something into the parameter before it I guess (idk how to explain it)
then doesnt that work
my code?
every str
so what
.author is an attribute from discord.Message, and discord.Message.author is a member instance, and since you already have message which is a discord.Message object, so guess what you gotta do
explain what even str is for you
idk 6 words 🤔
what
it's 6 words excluding explain 🚎
!e
words = ("hello\nlol\npenis\nsuper").splitlines()
test_urls = ('wkwneffwfwlol', 'wefewesuperpenis', 'wkejnfwkfsuperfidjndkdkd')
for url in test_urls:
for word in words:
if word in url:
print(f"{url} is blacklisted")
@sullen shoal :white_check_mark: Your eval job has completed with return code 0.
001 | wkwneffwfwlol is blacklisted
002 | wefewesuperpenis is blacklisted
003 | wefewesuperpenis is blacklisted
004 | wkejnfwkfsuperfidjndkdkd is blacklisted
what if you have 2 parameters that could potentially have multiple words? For example:
@client.command()
@commands.has_permissions(manage_messages=True)
async def session(ctx, info, *, name):
if ctx.channel.id == 912962943484066367:
mes = await ctx.send(f'**{ctx.author.mention} is hosting:**\n*Info: {info}\Name: {name}\nDate: {datetime.today().weekday()}*\n*Please react to this message if you plan on joining today! See you all there!*')
await mes.add_reaction(":heavy_check_mark:")```
!session 3:00 Pm Mom House
How would you setup the * in this situation?
I am simply going to say the bot to give a role to discord.Message.author
a string is basically text, that computers can identify
why not just pass Pm into 3:00 so it becomes 3:00Pm
I think I was doing that here
how can i add a cap to a number given in a command
ok apparently i use lists instead of () (or tuples)
well yea but is there no other way of doing it?
basic OOP smh, just use message.author.add_roles 🤦♂️
The bot can change roles of a owner ?
sure, why not as long as hierachy doesn't occur
idk what you are talking about now,
give me examples, where super shouldn't work for your "str"
because my current code works for every string containing those characters in a order somewhere in the string
Discord filter is great. Can't even upload images now.
Bad image then
wait i just realized
that it wouldn't work for every word then
ye sorry for being stupid to you
i'll just blacklist selected words
uh well technically yes, i'd personally do
async def session(ctx, time, md, *, info)
``` and the command would look like `!session 3:00 pm At my moms basement`
what you want then is splitting it by spaces
moms basement
kind of guessed it again, blacklist spaced filtered words like "among us" or sentences
whats md?
the checking for the blacklisted words in every word of the string
meridian (pm)
yes
among us isnt a single word
I suggest to create a custom converter and make the argument optional, in this case it seems like it is one argument made of 2
maybe
g
@copper ore Please don't try to ping @everyone or @here. Your message has been removed. If you believe this was a mistake, please let staff know!
message.author.add_roles(912976244499427339)
``` Why is this not working 😭
idk how to explain this but like instead of 'fuck' you could say 'fu ck'
and if i were to implement it into a list then it'd still wouldn't work
Because you need to add Role object
your supposed to use a role instance/object
Instead of just ID
you cant add an int to a member
like bad_words = ['fu ck']
@client.command()
@commands.has_permissions(manage_messages=True)
async def session(ctx, time, md, *, name):
if ctx.channel.id == 912962943484066367:
mes = await ctx.send(f'**{ctx.author.mention} is hosting:**\n*Info: {info}\Name: {name}\nDate: {datetime.today().weekday()}*\n*Please react to this message if you plan on joining today! See you all there!*')
await mes.add_reaction(":heavy_check_mark:")```
date is just 2?
@boreal ravine
wut date 
remove spaces from the string 🤨
datetime.today().weekday()
yes
I wanted it to print November 24, 2021 or sumthing
(╯°□°)╯︵ ┻━┻
role object, what I don't want to
prolly bc of that
i guess, try looking at datetime attributes to find what your looking for
perfect
imagine not wanting to do code which works for the problem your looking for 🚎
@bot.event
async def on_message(message):
await bot.handler.propagate(message)
await bot.process_commands(message)
message_split = message.content.split(".")
for message_word in message_split:
for bad_word in Filter:
if(bad_word == message_word.lower()):
await message.delete()
await message.channel.send("I have deleted that message :angry:")
message.author.add_roles(912976244499427339)
``` I have this
@slate swan you want to print a date in certain format right?
it's a coroutine (add_roles)
😅
anything that prints the current date
Just use str on it lol if you don't need any formats
use discord.utils.get() to get the role you want if you wanna get it by name
!d discord.utils.get
discord.utils.get(iterable, **attrs)```
A helper that returns the first element in the iterable that meets all the traits passed in `attrs`. This is an alternative for [`find()`](https://discordpy.readthedocs.io/en/master/api.html#discord.utils.find "discord.utils.find").
When multiple attributes are specified, they are checked using logical AND, not logical OR. Meaning they have to meet every attribute passed in and not one of them.
To have a nested attribute search (i.e. search by `x.y`) then pass in `x__y` as the keyword argument.
If nothing is found that matches the attributes passed, then `None` is returned.
Examples
Basic usage...
😵💫
@tropic briar you can get role object by uh message.guild.get_role(id)
my guy do be speaking in emojis
Message has guild attribute right?
Can I just put this in a variable
Sure
huh?
The guild that the message belongs to, if applicable.
Then that code is ok
This ain't js
Why not just py str(currentDate)
fock
Ah yes that's js
i was seeing different examples from stackoverflow didnt even read just copy padted
my fault
bro here's an example but it's not the complete fix to your thing
@bot.command(aliases=['addrole'])
async def add(ctx, role: discord.Role, user: discord.User):
await user.add_roles(role)
await ctx.send(f'added {role}')```
@slate swan it's just str(date_object)
And there's a method to output it in the specific format
not rlly what he wanted.. and I think his code is fixed now
bro that is js 😂
never said it was what he wnated
useless code then?
no
its an example to give him a little bit of understanding
it's not meant to be used
@slate swan also there's this in case you want special format
https://www.geeksforgeeks.org/python-strftime-function/
A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
Yes it is helpful when I we are making a !role command
wot
nothing

