#discord-bots
1 messages · Page 641 of 1
Yea
Even notepad has it
wrong, the ["discord"]
another way would be to use sys.modules btw
Then?
Wym
!d sys.modules
sys.modules```
This is a dictionary that maps module names to modules which have already been loaded. This can be manipulated to force reloading of modules and other tricks. However, replacing the dictionary will not necessarily work as expected and deleting essential items from the dictionary may cause Python to fail. If you want to iterate over this global dictionary always use `sys.modules.copy()` or `tuple(sys.modules)` to avoid exceptions as its size may change during iteration as a side effect of code or activity in other threads.
change disnake to discord
Ah
I just wondered if you knew the correct syntax by any change
no need to replace imports or change it afaik
I am confused ngl
if you do it in main file
My English has just broken down, I'll try to talk later
story of my life
indeed
Anyways hi there Robin. Long time :D
Wdym???
!d discord.Guild.created_at
property created_at: datetime.datetime```
Returns the guild’s creation time in UTC.
And that's a property
Ohhh i thought he ment a event
Lol it's fine, got ya covered
py
#suggest
@bot.command()
async def suggest(ctx, *, query):
embed = discord.Embed(
color=0xff0000,
description=
f":bust_in_silhouette: ❘ **User:** {ctx.author.mention}\n\n:bulb: ❘ **Suggestion:**\n\n{' '.join(ctx.message.content.split(' ')[1:])}")
if "!suggest + your suggestion here." not in ctx.channel.topic:
return
embed.set_thumbnail(url=ctx.author.avatar_url)
channel = bot.get_channel(867484283526578256)
msg = await channel.send(embed=embed)
await msg.add_reaction("")
await msg.add_reaction("")
await ctx.send(f"✅ {ctx.author.mention}, succesfully sent your suggestion to [#867484283526578256](/guild/267624335836053506/channel/867484283526578256/).", delete_after=12)```
Why i cannot react to the emojis?
You can do
msg = await bot.get_channel(ints).send(embed=embed
Makes it more compact
And i think for custom emojis you can only use the id
Hmmmmmm
You don’t want to know what happened
My biggest mistake was..... nvm, won't continue
Ok then don't tell 🤷♂️
It was traumatising actually. I think I’ll have nightmares
Best of Luck then
when did I never have no nightmares anyways hru Hunter?
!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.
You are the new Hunter. GJ!
Yes sir
Fine
ok
🤬
You be swearing?
Yes
well https://cdn.discordapp.com/attachments/802603832449695806/915290355665104896/unknown.png , i've got my db in another folder in the same dir , would this be the way to connect ?
In what way correct?
U still need to connect with code
snipe is against Tos
No....?
Sniping a message is against ToS? Or what kind of sniping
u can go to any server with dank memer
and type 'pls snipe'
huh idc tbh
that gives you all the info on it
🤷♂️
okay enjoy terminations 🤷♀️
why
Then why does discord provides on_message_delete event 🤨
oh dw i'm using snipe for logs only 🙏
Can you possibly send the part of ToS to me, I'd like to read it
its only used for logging i assume
just wtv tbh
moderation purposes, for mod logs
snipe commands on their own arent allowed
That doesn't mean it's against ToS wtf
That's a whole different thing ngl
man just ignore them
await coro(*args, **kwargs)
File "c:\Users\rrfda\OneDrive\Desktop\sublime\commands\snipe.py", line 78, in on_message
x,y = set(lastest_string) ,set(self.blacklisted_stuff)
TypeError: 'NoneType' object is not iterable
Command raised an exception: AttributeError: 'Bot' object has no attribute 'db'```
Yea ig
oh ik wheres that
yeah but where is it being called lmao
Python allows you to set custom attributes to most objects, like your bot! By storing things as attributes of the bot object, you can access them anywhere you access your bot. In the discord.py library, these custom attributes are commonly known as "bot variables" and can be a lifesaver if your bot is divided into many different files. An example on how to use custom attributes on your bot is shown below:
bot = commands.Bot(command_prefix="!")
# Set an attribute on our bot
bot.test = "I am accessible everywhere!"
@bot.command()
async def get(ctx: commands.Context):
"""A command to get the current value of `test`."""
# Send what the test attribute is currently set to
await ctx.send(ctx.bot.test)
@bot.command()
async def setval(ctx: commands.Context, *, new_text: str):
"""A command to set a new value of `test`."""
# Here we change the attribute to what was specified in new_text
bot.test = new_text
This all applies to cogs as well! You can set attributes to self as you wish.
Be sure not to overwrite attributes discord.py uses, like cogs or users. Name your attributes carefully!
its against tos because discord has interpreted in their privacy policy that deleting a message implies they dont want its publicity anymore, meaning that sniping it would go against the privacy policy
makes sense?
Snipe.py line 78
Not really
good job
mind if u quote that line from their tos ?
So logging bots also send the deleted messages in the logs channel, won't that also be against ToS then? Since they are also invading privacy by sending the message content and other information 🤣
some famous servers make their logs public lmao
log channels are different
hows that
H O W
thats for moderation purposes as i stated
If you link me the part of ToS I would understand that but otherwise I won't
yeah
snipe commands are recreational and used in the channel a message was deleted in
this is how this looks like
@bot.command()
async def gamer(ctx):
conn = sqlite3.connect('test.sql')
c = conn.cursor()
good = random.randint(100, 150)
some = random.randint(50, 80)
player = ctx.author
await ctx.send('There Is a Zombie Apocolypse right now and You have 2 Choices \n(A)A Baseball Bat With Iron Wires Coverd\n(B)An M16 With 90 Bullets\nWhat will you choose?')
msg = await bot.wait_for('message')
if msg.content in ('a','(a)','(A)','A'):
c.execute(f'UPDATE data SET balance = balance+{good} WHERE ID = {player.id}')
conn.commit()
await ctx.send(f'You Are A Real Gamer **{good}:nexus:** as Gift From Every Gamer')
else:
c.execute(f"UPDATE data SET balance = balance+{some} WHERE ID = {player.id}")
conn.commit()
await ctx.send(f'Wrong but you still get some {some} for trying')
snipe can be too
U don't know 🤷♂️
That's what they are made for, not everyone use them for moderation purposes dude
if x & y:``` thats 78
That's where it's being used, or somewhere near it
Nothing against tos
Half knowledge is dangerous 😐
Ye
instead of if msg.content in ('a','(a)','(A)','A'):
what you could do is, if msg.content.lower() in ('a','(a)'):
!d str.lower
str.lower()```
Return a copy of the string with all the cased characters [4](https://docs.python.org/3/library/stdtypes.html#id15) converted to lowercase.
The lowercasing algorithm used is described in section 3.13 of the Unicode Standard.
yeah lmao
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'WindowsPath' object is not subscriptable
does this mean that the path doesnt exists?
Can I see code?
well i think windowspath is returning none
@commands.command(description="Add a word to the blacklist", usage="<word>")
@commands.has_guild_permissions(administrator=True)
async def blacklistWord(self, ctx, *, word:str):
if not word:
return await ctx.send("What word should I blacklist?")
self.client.blacklisted_words.append(word)
await ctx.send(self.client.blacklisted_words)
data = utils.jjson.read_json("blacklist")
await ctx.send(data["blacklistedWords"])
;-; why I get into an argument with literally everyone most of the time when I am here
And which line?
i actually using this so users can give choice if they are lazy
well that was a normal talk tbh , not an argument
data = utils.jjson.read_json("blacklist")
!e print("cAsE doEsnt matter".lower())
@sullen shoal :white_check_mark: Your eval job has completed with return code 0.
case doesnt matter
Haha it was tbh. It was turning into an argument
def get_path():
"""
A function to get the current path to main.py
Returns:
- cwd (string) : Path to main.py directory
"""
cwd = Path(__file__).parent[1]
cwd = str(cwd)
return cwd
def read_json(filename):
"""
A function to read a json file and return the data.
Params:
- filename (string) : The name of the file to open
Returns:
- data (dict) : A dict of the data in the file
"""
cwd = get_path()
with open(cwd+'/client_config/'+filename+'.json', 'r') as file:
data = json.load(file)
return data
oh
And what's that function?
Ah that
^^
well thats what happens when someone think their opinion is superior
🤷♂️ Anyways let's leave it
Well sadly this channel has become a bit like that
also i suggest just return str(cwd) no need for extra lines and same thing with reading the json
Why do u even doing that much....?
Just save the JSON in the same directory and use absolute paths
and hey 😔 dont use json as a database
Seems like it, yea
mm ok thanks :)
I wish I could understand this tbh
It’s probably where you try to send data["blacklistedWords"]
its for a single server sooo
Not subscriptable means you can’t index or slice it.
Lol good old times
oh ok
Oh hi there NIR! Long time dude
Yap
https://cdn.discordapp.com/attachments/784465822180704340/915283393388884048/unknown.png why is the region deprecated?
Because guilds don’t have regions
no
Voice channels do
!d discord.VoiceChannel.region
No documentation found for the requested symbol.
Tf?
Is that even a thing you can change?
I thought discord automatically selects that for you.
!d discord.VoiceChannel.rtc_region
The region for the voice channel’s voice communication. A value of None indicates automatic voice region detection.
New in version 1.7.
Ah
There (:
That man hunter hit the docs up so fast.
Bruh why couldn't Danny name it to fricking region instead of rtc_region
Really? I feel like my speeds are slow tho 

ctx_author = ctx.message.author.id
it gives me an error message
ctx.author also returns message.author tho
!d discord.ext.commands.Context.author
Union[User, Member]: Returns the author associated with this context’s command. Shorthand for Message.author
ty
still 
for vc in ctx.guild.voice_channels:
region = vc.rtc_region``` its returning none but why i set a voice channel region
Do u have intents?
yea
Which ones?
all xd
O
Read this.
Wait
None means automatically chosen region
None means it's set to automatic detection
but i set a region
O
Interesting
Hmmmmm did u save the changes 
Ik noob question but people sometimes forget to save them
yea
Weirdddddddd
i keep getting an Command raised an exception: NameError: name 'cursor' is not defined
is their a way to define it all over the files ?
What’s the problem?
Importing it?
like maybe something like bot.something = await connect my cute database
its in the same cog and needs to be inside a corotinue
Is it somewhere in your file?
i told you , its inside a corotinue in the cog
Isn’t this @slate swans?
yes
I feel like I remember something like that from his template
hey @sullen shoal
Euclid is I pay for Winrar?
i had to change so much stuff dude omg
Wait
you got dem intents?
I misunderstood, the code is ipayforwinrars
'py ("hello world")'
i am trying to make this look like
print("hello world")```
I changed so much stuff omg
? Aliases?
try adding a line
i think
a line?
like a blank space
like \n?
Try using aliases
maybe
hello
. Is this a function?
Hai myxi 😄
Idk tbh. If Guild.owner returns None. Im pretty sure it would be an intents problem.
there is a blank space after py
If it is a function, then use aliases
hello downloadpython
No
It needs members intent
If it’s a function try aliases
i am trying to make the bot to recognize this
print("hello world")```
That’s….hard
?
so i've got my cursor and db loaded inside a coroutine and in the cog commands , i was wondering if i can make it public all over the files and stuff cuz whenever i try to use it , gives me an undefined error altho i made it global which isnt a good practice
I mean I don’t really understand your question
before i started coding i was ready for depression
Are you trying to eval this?
im confused what are you talking about
Or is it some kind of function
😵what is happening
lmao do you even know what are cogs and corountines ?
How do I get the arguments part for subclassing help command?
Errr…I just started learning it, and I have read the docs
okay this is gonna be hard to explain
sooo
look at dis
inorder to write dis
print("hello world")```
check asyncio docs aswell
you gotta type like dis
😭 biggest mistake was skipping it now I have to go through it
👍 that’s my homework
so i want the bot to see this thing
Wtf 😳
Command.signature ?
okay then?
I don’t understand at all
.bm need to learn this as well
oh god
You dont know asyncio?
I do (a bit) but no in depth
Dang
i am trying to make the bot see this
print("hello wold")```
in this line
arent you supposed to put `````````
there is
this ```
Ok
OH
…?
just check if the content has ```
I mean you sound like you don’t have a 100% understanding on them either. You're saying you have stuff inside a coroutine when you probabaly mean you have them in a async function. Coroutines are what are returned when you call async functions normally.
I don’t understand anything so I’m just going to watch this and provide support , best I can do 😭
I think my English bad
yes i have added that
🤷♂️💀
…asyncio?
after that you could use str.strip to strip them out
ah discord doenst allow me to send the example
i gotta go afk now
okay
And to answer your question. You can assign a cursor to one of your bot variables. And you’ll have access to it anywhere you have your bots instance
Such as a cog
For example if you had a bot subclass
you can have like
self.dbcursor = cursor shit
In the instance variables.
…
And just that attribute normally.
Im just watching the show while eating pizza 
😋
reusing cursors is bad though, right? race conditions and what not
rather you can save the connection instance, and get a cursor from that every time you want to do something with the database
Pepperoni or cheese? Or both?
Pepperoni 

Hes Running here
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.
how do I hid links under text?
[text](url)
Thank you, just about to ask that
or is it the other way around
do i have to do
[text = wala](url='url')
no just like [google](https://google.com/)
"[Text To Click](https://www.youtube.com/ "Hovertext")"
- Needs to be a full url (http/https)
- Hovertext is optional
- If sent by a bot/user it needs to be in an embed
- If sent in a webhook you can hyperlink raw text cuz fuck being consistent amirite discord
- This only works in the embed description and field value
If you want to hyperlink a title or set_author, you can use the url kwarg
hyperlinks ^
u type fast
oh
but I do type fast
Noice
ill take a typing test rn
nice
do i need to add "hovertext"?
@slate swan
It does work
Show ur code
U made a space?
await ctx.send('you made a beautiful painting of a [women](https://cdn.discordapp.com/attachments/871082657742725182/915304518214905866/1200px-Mona_Lisa2C_by_Leonardo_da_Vinci2C_from_C2RMF_retouched.png/) and she looks good or idk')```
like [p] ()
it works in descriptions for bots only
like embeds only?
also values
.bm
How to fix this? What should i need to install?
ohhh
Ye
however webhook messages are allowed to send them in raw text
Have you ever seen a beginner who hangs around an expert, tries to help but all they’re doing is rephrasing what the expert says but using different words?
discord-ui is a module
Yeah i have 
yes and i have done that
Oh
and then few days later that person starts dming me for help
what should i do than to fix that error?
oh something is wrong
oh wait its replit
import discord-ui
maybe they arent using 2.0
…me?
in terminal do, pip3 show discord or pip show discord
in replit's terminal
Idk am i a expert
Happened to me a lot.
I call that reinforced learning.. lol
Yes i am continues to compare a list with a int
me too
?
Events cant use cooldown
@commands.cooldown() is only for commands
you gotta know python well if you are going to make your own parser and stuff to make commands with that event yourself
Ye but is there away? like making sleep()
Im not talking abt that
Doesnt stop from invoking it
…that stops the event temporarily
Oh i see
I mean I do make careless mistakes
Well idk
Purposely to see if python returns an error
.bm?
Bookmark
it is not working?
both of them?
show me the terminal where you did it
In repl.it the terminal is the shell
go on shell and type pip show discord
I use the shell for that
no 😢
did it return anything?
yo guys this is my script please think of it in your brain yourself and help me fix the thing, i aint showing it
import discord-ui i used
Freecodecamp?
Ok, but what about the shell output?
thats not the terminal
go into the shell and type pip show discord
freecodecamp kids
😭
can I send images here?
what is .bm
if its not nsfw and is about discord bots

does anyone know how i can make this work
@client.command()
@commands.has_role('Staff')
async def close(ctx):
if discord.TextChannel.category == 'TICKETS':
await ctx.channel.delete()
a bookmark command that sends you a DM with hyperlink to message you replied to / gave
What you wish to do ?
Doesnt that use an id?
i tried with an id but no luck
a command
oh
so i thought i should try with a string
Its a book mark if you have dms on it will dm you the message with the link of it and a bit of text so you can save it for later
well you clearly didnt put in a valid id
was it int, was it valid
you dont put in str
ye it was int
!d discord.ext.commands.has_role
@discord.ext.commands.has_role(item)```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member invoking the command has the role specified via the name or ID specified.
If a string is specified, you must give the exact name of the role, including caps and spelling.
If an integer is specified, you must give the exact snowflake ID of the role.
If the message is invoked in a private message context then the check will return `False`.
This check raises one of two special exceptions, [`MissingRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") if the user is missing a role, or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") if it is used in a private message. Both inherit from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
Changed in version 1.1: Raise [`MissingRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")
Shouldn't it be ctx?
wasnt valid 
it should but he doesnt know python
The issue is here, no need to search that much..
oops..
damnit he deleted it before i could reply
What is scoopy?
thats what they alll say
Why would you use a role for a ticket system,anyone can go to the channel and close it you should save the authors id
It's a person
didnt mean to bloody ping
hes a dude you idiot
So what?
(No homo)
So you had to insult to say that?
ye but nah
Welcome to the Python server I guess..
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

This channel is turning to the toxic discord.py support channels XD
!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.
toxic cus someone said idiot
Stop guys
Guys actually chill
this is not bing chilling
Guys calm down
You really wanna get banned dont you
😭

Against the rules iirc
He was typing

i'm quite confused what should i do then?
I have this code but it works only the yes - no and the no - no
learn oop 
Wtf does oop mean?
Yes wont work
🤦♂️
You know it?
@dire folio
I do know about dpy its object oriented
it is
really it is
Then why ask? Were you asking for what it stands for?
YES
😭
There was a funny joke about OOP

oops
oof
How do I get the permission level of a command?
woof woof
I dont know where it is tho
someone here pls
I laughed for like 10 hours
Elaborate
@slate swan
Like how would I get this
Ahhh well you add it as a footer in a embed
you got an error?
I know how to add a footer 💀 I’m asking how I would get the permission level
Not a thing you add a string
Ohh
Okay
nope
I do have a bit of clue
On mobile so i didnt even checked
I do get a little bit of a headache seeing the code be so unorganised
well...what does it send?
then don't help me.
nothing idrk
not even doing so
not even an embed?

Why do you use
if
elif
elif
and not just
if
elif
elif
elif
my code is messy af. Leave the chat when I ask for help.
oh lol
Or just use elif
but I'm just tryna help salamalego
Oh yeah it's elif
*what he's trying to say-
what
Yeah
See that if in the middle?
Replace it
and those indents, spaces and empty lines
oh no bruv
it sends no embed. Make an else statement that just does something
and execute it again
might not be
Replace it to an elif
it looks similar to the one on top and the middle
No it doesn't
so we don't know if he screenshotted the top one or the one in the middle.
and why don't you just put
if time.content == "yes":
#put the time
if pfp.content == "yes":
#put the pfp
Don't do that
It will be slower
how
I think he wants to check if it does both
As it will always check every single if
well it's two if statements
If you use if, elif, elif once it hits the first elif it will stop trying the others
the no -yes doesnt work
top tip: Leave the chat when I ask for code help
Always do
a good tip

@velvet tinsel
this is also gonna check a lot tho
it's just bad logic what's happening here
If the first if is true, it won't even try the others
Ok, ok, stop pinging me
srry
it's a 1/4 chance that the first if is true
I think my google broke
Same for the second and third
the other 3/4 times, it's either the same amount of memory or even more
if time.content == "yes" and pfp.content == "yes":
emb = discord.Embed(title=title.content, description=desc.content, timestamp=ctx.message.created_at)
emb.set_thumbnail(url=f"{author.avatar_url}")
await ctx.send(embed=emb)
This isnt work either
oh lol
what version are you using
These two arent working
if time.content == "yes" and pfp.content == "yes":
emb = discord.Embed(title=title.content, description=desc.content, timestamp=ctx.message.created_at)
emb.set_thumbnail(url=f"{author.avatar_url}")
await ctx.send(embed=emb)
elif time.content == "no" and pfp.content == "yes":
emb = discord.Embed(title=title.content, description=desc.content)
emb.set_thumbnail(url=f"{author.avatar_url}")
await ctx.send(embed=emb)
in 2.0, it's gonna be author.avatar.url
I built the connection instance into a custom context, if that makes any sense
I was looking at RoboDanny (discord.py bot that danny made) and it does something similar
Yeah.
I have custom context but I haven’t used it for things like that.
Just for embed stuff.
My google brokk
😦
site not loading
every other site works tho
I think the site brokken
easy
f
no I trust google
I'm doing this request:
r = requests.post(f'https://discord.com/api/v8/channels/{channelId}/messages', headers=headers, data=payload, files=files)
And it works with channel IDs in servers but it doesnt, when i want to message a user by using the ID i get when right clicking a friend and pressing "Copy ID"
DO I have to change the request link in order for it to work
Hello I'm trying to make a bot that when anyone join to send a welcome card but It's not working any ideas?
`import discord
intents = discord.Intents.default()
intents.members=True
client = discord.Client(intents=intents)
@client.event
async def on_message_join(member):
channel = client.get_channel(channel_id)
embed=discord.Embed(title=f"Welcome {member.name}", description=f"Thanks for joining {member.guild.name}!") # F-Strings!
embed.set_thumbnail(url=member.avatar_url)
await channel.send(embed=embed)`
Maybe you want on_member_join instead of on_message_join
oh yes
no
Ok, I'll try now
Thanks, It's working!
Hey im trying to use the discord buttons
Im getting ModuleNotFoundError: No module named 'discord.ui'
Ive installed the discord.py and tried updating it
import discord
from discord.ui import Button, View
from discord.ext import commands, tasks```
Any ideas what im doing wrong?
Have you installed v2.0?
can you run python -m discord -v real quick? 😛
Run it in a cmd window?
Yes
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.
Python is installed with PyCharm
Discord versoin is 1.73?
Im installing it with PyCharm interpterter ive tried updating it
yeah, discord.ui is 2.0+
is there a way i can manually install v2
you need to install it from git, since it's not on pypi
To install the development version, do the following:
$ git clone https://github.com/Rapptz/discord.py $ cd discord.py $ python3 -m pip install -U .[voice]
you don't exactly need to manually clone it locally though
Noob question, once again do i just copy and paste that into a cmd window? or can i do it through PyCharm
Not copy paste
Since you maybe don't use python3
Do it in the same place where you got the version number
One line after the other
Im using python 3.9 pycharm says
okay so ive just ran the command in pycharm terminal window
says its installed but still isnt working?
can samone givr exemple of random anime photo and natauki random photo command please?
make a list of strings
the strings are just GIFs
!d random.choice use this with passing in the list and send the result in a message
random.choice(seq)```
Return a random element from the non-empty sequence *seq*. If *seq* is empty, raises [`IndexError`](https://docs.python.org/3/library/exceptions.html#IndexError "IndexError").
done
or use os *cough* or PIL, whatever you use to go through your files
administrator_help = Button('Administrator', color="green")```
This should be producing a button?
errrr
what module are you using
;-;
A discord.py extension for sending, receiving and handling ui interactions in discord - GitHub - discord-py-ui/discord-ui: A discord.py extension for sending, receiving and handling ui interactions...
oh
I never used it sorry
but I'll look into it
I use discord-components
cough 2.0
it's pretty easy and the support server is helpful
Ill check the github out now
I will probably use disnake but I never really used button
@manic wing too bothered to go to 2.0 to be honest
but I think the disnake owner helps in this server quite a lot
yeah i havent used 2.0
I'll join it, no idea
Why doesn't the check work for me? The participant ID is in the database, but the check does not work and does not display an error that the person is in the black list
I need to check which one I'm using
cant find it
well a coro is whats returned ?
Yes
apparently discord --version nor discord.py --version works ;-; idk what to do now but I'm not really bothered
Precisely
well i found this on asyncio docs ,
Coroutines declared with the async/await syntax is the preferred way of writing asyncio applications. For example, the following snippet of code (requires Python 3.7+) prints “hello”, waits 1 second, and then prints “world”:```
I saw that example
consider reading them and telling me what you understood , i might've understood them wrong
I miss pandabweer and Ipayforwinrar 😦
try for r in ctx.guild.roles @slate swan
if you're using a command
In a specific role
am I doing something wrong
Role.members()
Oh, knew it
property members: List[Member]```
Returns all the members with this role.
I was thinking about that
Whenever Tylerr starts typing I know I'm doing something wrong
;-; imposing threat, Charisma a definite +3 modifier. Maybe he's a warlock? (sorry, dnd reference)
i mean the code or somehing its gonna helps me out making 2 this commands
Oh, like going through your files?
you can do that, yeah
I swear all helpers here have a charisma modifier of 15, maybe okimii has like 13 or 12 (or possibly 10) and caeden is probably a higher Charisma modifier
what's that
sorry went a bit ot
Why doesn't the check work for me? The participant ID is in the database, but the check does not work and does not display an error that the person is in the black list
async def foo():
#from what i know foo is now a coro
return ""
foo```
no, no
I was speaking to myself there ;-; I do it a lot (I have no friends)
actually what's that
you speaking to me?
yes
err...dnd reference
do not disturb reference?
you get a high Intimidation if you have high Charisma, I'm scared of some of the helpers here
dungeons and dragons

I should stay on topic
No no i just need a code example od this commands
whenever I see something like Tylerr is typing or Myxi is typing or okimii is typing I get nervous
I'm speaking to myself, but that's alright.
and you...sometimes...
there's a saying...I forgot how it goes
I think it's like help a man to fish, feed him for a day, teach him how to fish, feed him for a lifetime
Ugh
Hmm. I may of been lil wrong.
Tylerr intimidating af
But shady is more intimidating
I think Andy is less intimidating
Shady?
Shady the evil cat lady
Is this another one of your dnd references?
@slate swan So I have a list of the members now but I want to check if they have a specific role.
Tried
if role in role_bla.members.roles:
print("bla")```
It can't check if they have the role because role.members just gives a list
'list' object has no attribute 'roles'
you didn't use the for loop
members is a list
you can iterate through that
So
for role_bla.members.roles in what tho?```
for member in role_bla.members
I guess you wanna check everyone that has a specific role
that's how I understood
BRUH NO I have it now
sorry dude
i was a bit braindead
no
I can ping her now, but she'll kill me
we are all braindead when it comes to coding
sry quick question, how do i check if a channel is a TextChannel
cant find it and i already spent 20 minutes searching the docs
if isinstance(channel, discord.TextChannel)
if isinstance(channel, discord.TextChannel)```
thanks
shit you got there quicker
Hello! I'm trying to make my own Discord bot with welcome cards like Mee6, but i'm stucked. I'm trying to find the code to do that and i find that but i dont how to make it after that. I'm doing it on replit but i dont know if its gonna work there.
`from PIL import Image, ImageDraw, ImageFont
get an image
base = Image.open("Pillow/Tests/images/hopper.png").convert("RGBA")
make a blank image for the text, initialized to transparent text color
txt = Image.new("RGBA", base.size, (255,255,255,0))
get a font
fnt = ImageFont.truetype("Pillow/Tests/fonts/FreeMono.ttf", 40)
get a drawing context
d = ImageDraw.Draw(txt)
draw text, half opacity
d.text((10,10), "Hello", font=fnt, fill=(255,255,255,128))
draw text, full opacity
d.text((10,60), "World", font=fnt, fill=(255,255,255,255))
out = Image.alpha_composite(base, txt)
out.show()`
and whats the problem?
I tried but it didn't worked
Do you upload the picture in replit?
I'm new and i'm not sure what is dpy.
what the actual thing
!docs
if i wanna message someone directly using my bot what can i do to like message that specific person?
Why does the cycle start to operate if I specified the condition that if there are no documents in the collection then return
what its the import for mongodb?
import pymongo
thanks!
you get the member and you do member.send
@commands.command(name="serverinfo")
async def serverinfo(self, context):
"""
Get some useful (or not) information about the server.
"""
server = context.message.guild
roles = [x.name for x in server.roles]
role_length = len(roles)
if role_length > 50:
roles = roles[:50]
roles.append(f">>>> Displaying[50/{len(roles)}] Roles")
roles = ", ".join(roles)
channels = len(server.channels)
time = str(server.created_at)
time = time.split(" ")
time = time[0]
embed = discord.Embed(
title="**Server Name:**",
description=f"{server}",
color=0x1eff00
)
embed.set_thumbnail(
url=server.icon_url
)
embed.add_field(
name="Owner 👑",
value=f"{server.owner}\n{server.owner.id}"
)
embed.add_field(
name="Server ID 🤓",
value=server.id
)
embed.add_field(
name="Member Count 🎅",
value=server.member_count
)
embed.add_field(
name="Text/Voice Channels 📃",
value=f"{channels} "
)
embed.add_field(
name=f"Roles ({role_length}) 👮♂️",
value=roles
)
embed.set_footer(
text=f"Created at: {time} ⏰"
)
await context.send(embed=embed)```
uhh what
please @ me if you can help
@wild oak the server owner id is None
try server.owner_id
Wont work
how would i set the current date as an embeds footer?
!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.
@dire folio ^
!d discord.Guild.owner_id
The guild owner’s ID. Use Guild.owner instead.
@wild oak use it
well umm
did you quit the for loop?
show some code
why
why are you using a while true
with spamming API calls
and you don't even leave it
just delete the while true...
and find a way you won't spam send()
that's no good for nobody
boy I gotta go
👍
good night
Why is their a while true if your iterating through a list?
Make a delay when sending a msg so you wont get rate limited
zip(*iterables, strict=False)```
Iterate over several iterables in parallel, producing tuples with an item from each one.
Example:
```py
>>> for item in zip([1, 2, 3], ['sugar', 'spice', 'everything nice']):
... print(item)
...
(1, 'sugar')
(2, 'spice')
(3, 'everything nice')
```...
all of their messages were deleted
Pretty sure thats against discord TOS
it is
api ratelimits are there for a reason
getting around it is a no no for TOS reasons and courtesy
ive classified a cog, properly, loaded it in the main file, but the command isnt found
not sure why, ive restarted it multiple times now
can we see how you're loading it?
- the setup function
sec
The python bot logs deleted messages while discord doesn't
all of my other cogs load fine im not sure whats wrong with this one
main file bot.load_extension('cogs.misc')
If an admin wanted to punish you deleting the message wouldn't matter. What I did prevented your entire account from getting terminated
cog
import imports_here
class misc(commands.Cog):
def __init__(self, bot):
self.bot = bot
whitelisted = [813989866236149770, 431427182926102528, 853544955300806657, 755127293432692757, 911079118165131284]
def terror(ctx):
return ctx.author.id in whitelisted
@commands.command()
@commands.check(terror)
async def changepfp(self, ctx):
with open('./pfp/acrella.png','rb') as f:
await self.bot.user.edit(avatar=f.read())
#defs
@commands.command(pass_context=True, aliases=['eval', 'exec', 'evaluate'])
@commands.check(terror)
async def eval(self, ctx, *, code: str):
#stuff
def setup(bot):
bot.add_cog(misc(bot))```
wdym
move the commands into the misc class
The indentation is wrong
right now they're nested into the terror function
yaaa
i just fixed that
whitelisted = [813989866236149770, 431427182926102528, 853544955300806657, 755127293432692757, 911079118165131284]
def terror(ctx):
return ctx.author.id in whitelisted
class misc(commands.Cog):
def __init__(self, bot):
self.bot = bot
how do I check if someone is tagged in a x time
how do i customize what these say ? https://mystb.in/EndorsementInterfacesCorners.python
Where did you find that?
wym
Did you see that in the docs?
Having more context on what you mean would help us help you
the command yes
For which
??
Where exactly did you find it in the docs?
https://github.com/Rapptz/discord.py/blob/master/examples/basic_bot.py oops i meant the github
Still quite confused on what you need help with, where is this in the github link you sent me?
line 44
im just trying to make it say ;repeat <amount> [text] instead of ;[repeat|rep|r] <times> [content=repeating...]
Then make the command accordingly with the right arguments
Unless you mean that in the help command
If I'm understanding you right, the command has 3 aliases: repeat, rep, r. When you run the help command, it shows all 3 instead of just the first one
Is that what the issue is?
yes
You'll need to do some overriding and customization
how do i do that?
I'm pretty sure you can get the aliases as a list, you can just get the first one
Or, alternatively, you can get the name. Each command can only have 1 name, but multiple aliases
You can get both of these by the command.aliases and command.name respectively, where the command variable is of type discord.ext.commands.Command
oh okay
also how would i add the command prefix to a command if it has no args?
@sick birch
is contextLib not a valid import?
ctx.prefix
or self.context.prefix for help command subclass
okay
can we not have more than 1. event in our discord bot?
whenever i add another event, the first 1 stops working
send_command_help overrides everything, so whatever you have inside will be the only things it sends when you get help with it
You have to add the arguments, prefix, etc manually
use @bot.listen()
for .event no, use .listen() instead
so just replace. event w listen?
Not necessarily
You should stay away from @bot.events, but there are many cases where it's required
And if you do use @bot.event, some of them have some special caveats which you have to keep in mind
ok well for now i. just took my entire code from the second .event() and paasted it to the first one and its working
they both have specific conditions so its fine ig
for now atleast
many?
I can barely think of one
Good point, off the top of my head I can only think of on_message haha
Anyone know the deal with discord.Users? I’m getting major errors when I try and use it.
Hey does anyone know how to make a level bot?
what error
ye does anyone know how to make a level bot (xp, leaderboards, and double xp in certain days or for certain channels?)
!d discord.on_message
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.
!d random.randint
random.randint(a, b)```
Return a random integer *N* such that `a <= N <= b`. Alias for `randrange(a, b+1)`.
Same for you
!d discord.on_reaction_add
Hey im trying to install discord.20 so i can use buttons. cant seem to get it installed though
im using py -3 -m pip install -U discord.py in pycharm terminal window
Whats the issue?
Is it not installing period or not installing 2.0
Not installing at all by using py -3 -m pip install -U discord.py
Only if i install it through pycharm interpreter but then i get v1.73
which i cant use the fancy buttons 😄
@final ironany ideas?
Try using a virtual environment
This is the correct version?
pip install -U git+https://github.com/Rapptz/discord.py
Yea, but prefer using any fork like disnake since discord.py has ceased development
yes
@maiden fableOh really, which one would you suggest? Im pretty new to all this my bad
@sullen shoalI can install disnake straight through with PyCharm right?
i think you can
Awesome ill take a look. is there any examples of how to create a button with disnake?
You can but I wouldn't suggest trying to uninstall a package through it. It bricked my venv which wasn't a big issue but it would of been if it was my actual python installation
Awesome, @sullen shoal@final iron i had a part in my code which was the loop Client.loop any idea how this is replaced with disnake? has a search through their documentation cant find anything
i need help with just one code line can somone help me
it was big so i was like to do in dm
please dm me
@client.loop(seconds=60)```
The beta version of discord.py has very good buttons and selects, slash commands and context menus you can implement yourself with relatively little effort. I don't like any of the forks as they are not headed by as experienced developers as danny, but you're free to use whatever you want
Even though it says it's beta, it's quite stable. At least, it's worked like a charm for me and haven't run into any issues
@sick birchThat was my worry, id preferably like to stick with discord.py just because i can find alot of help just by googling.
@sick birchI just cant seem to get it installed properly 😦
What seems to be the issue with it?
If you install through pip, you'll get the older version
I tried to install Discord v2.0 but its just installing 1.7.3
Are you getting it through pip?
Im running the pip command from their github through pycharm terminal?
Explains it
You can't get the beta version through pip, only 1.7.3. That's the last version before beta iirc
You'd need to install it manually
gotcha
Quite easy, it's a 3 liner
How would i install it manually?
Well I use linux for development, so hang on while i take a look on how you do it for windows
According to the official GitHub page, here's how you install the development version:
git clone https://github.com/Rapptz/discord.py
cd discord.py
python3 -m pip install -U .[voice]
The first part is where you clone the GitHub repository, meaning it downloads it to your local machine.
The second part just moves into the directory, i.e sets it as the current working directory
Last part basically just installs it through the local files, without getting it from pip
I hope that makes sense, and you can use the latest features 🙂
thanks for your help dude. i just use those commands in a CMD window?
You could just do pip install git+https://github.com/Rapptz/discord.py
@pliant gulch Once i download it from github which directory do i put it in?
Correct
C:\Users\Jorda>git clone https://github.com/Rapptz/discord.py
'git' is not recognized as an internal or external command,
operable program or batch file.
It doesn't really matter, it only needs the file so it can install it on your system
Ah yeah you'll want to install git first
ohhh
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
okay. is there a command for that? or is there a program to download?
I've never actually done that before as linux comes preinstalled with git, but https://git-scm.com/book/en/v2/Getting-Started-Installing-Git is where you go to install it
https://git-scm.com/download/win (auto-download)


