#discord-bots
1 messages · Page 30 of 1
!d discord.Guild
class discord.Guild```
Represents a Discord guild.
This is referred to as a “server” in the official Discord UI.
x == y Checks if two guilds are equal.
x != y Checks if two guilds are not equal.
hash(x) Returns the guild’s hash.
str(x) Returns the guild’s name.
if isinstance(error, commands.CommandOnCooldown):
if error.retry_after < 60:
message = await ctx.send(f"{ctx.author.mention} This command is on cooldown! You can use it again {round(error.retry_after, 2)} seconds.")
await asyncio.sleep(5)
await ctx.message.delete()
await message.delete()
elif error.retry_after > 60 and error.retry_after < 3600:
mins_decimals = error.retry_after/60 - math.floor(error.retry_after/60)
mins = math.floor(error.retry_after/60)
secs = round(mins_decimals*60, 2)
cooldown = f'{mins} minutes and {secs} seconds'
message = await ctx.send(f"{ctx.author.mention} This command is on cooldown! You can use it again {cooldown}.")
await asyncio.sleep(5)
await ctx.message.delete()
await message.delete()
elif error.retry_after > 3600:
hrs_decimals = error.retry_after/3600 - math.floor(error.retry_after/3600)
hrs = math.floor(error.retry_after/3600)
mins_decimals = (error.retry_after/60) - math.floor(error.retry_after/60)
mins = math.floor(hrs_decimals * 3600/60)
secs = round(mins_decimals * 60, 2)
cooldown = f'{hrs} hours, {mins} minutes, and {secs} seconds.'
message = await ctx.send(f"{ctx.author.mention} This command is on cooldown! You can use it again {cooldown}.")
if isinstance(error, commands.MissingRequiredArgument):
message = await ctx.send(f"Missing required argument/s. Use $description [command] to view the required arguments.")
if isinstance(error, commands.MissingPermissions):
message = await ctx.send(f"Missing required permisions, please check that you have the permission/s to perform this command.")
wait, where?
if if if 😭
uhm yeah but we usually use the elif in that error handler block, because when you catch the error is useless to check for other ones, so it's something like this:
if isinstance(error, discordError_1):
pass
elif isinstance(error, discordError_2):
pass
...
and in the end you put the else statement with what i sent
😂 sorry, I coded this section when I was just beginning to program
well it's not like that is not right in that way, but using elif is better because an error can't be an instance of two different objects
oh ok
and using elif you will need to type this else statement only once
bruh I just looked at my old on_command_error 😭 😭 😭
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'channel'
oh god
lol, did what i did with the if statements
how was I so d.. nsfw code writer
I see, this makes it much easier to debug
when you are not in voice channel, this doesn't find a channel cus voice.state is None
user = ctx.message.author
channel = user.voice.channel
so the problem is that channel actually is none, that is because a member object hasn't an attribute channel which refers to the channel where the user is, so try this:
channel = ctx.author.voice.channel
you're welcome
wait I just noticed wth is user = ctx.message.author, using it in channel var and then using ctx.author in other vars
Wait... wouldn't the same error occur?
yeah to get the author of the command just use ctx.author
yeah, this'll give same error
it gave the same error, i just tested
You just need to put this line channel = user.voice.channel here
yup
You're a bloody genius. Why didn't I think of that? 😂
Thank you so much guys
im not sure, is doing this good? or better to do smth like >=1,<2, cus im just lazy to seacrh what versions would be compatable
it's normal when you're new to d.py
make sure to check the docs when you're not sure of something, it helps a lot
yep, thank you
💀

oh wait i guess that's new to python at all :lmao: not just to dpy
yeah but not entirely at beginner level lmao
lol some middle dumbass
I'm at beginner level for Python as well as Discord.py😂
I started python with dpy ||it wasn't very good decision as I see from my old code||
I still need to figure out how to use classes and stuff. I guess I should look at some Python tutorials. I just realised how much of the fundamentals I'm lacking.
i started with C and then learnt assembly so nothing scares me anymore 
Wow.
im only scared of rust (rust ig mostly because i haven't tried it) and JS
js it's not scary, it's stupid 
Why did they put that S if not so?
Assembly code as in the 4 letter code?
yeah was just thinking to say that I'm more not scared of JS than confused and disgusted
well py-script is in alpha testing so, we will say bye bye to js soon
Wait, is it 3 letter mnemonics?
Well it's not like the instructions can't have more than N letter but yeah, asm is mnemonics
sounds nice (cus I never heard of py-script)
ah ok
like BTFSZ is asm "if"
Really? Is there a good way to memorise that?
omg, just looked at my old on_message, I won't send even part of it, you'll die from cringe
They're all acronyms, that means Bit Test File Skip If Zero
lmao
Oh wow, I wouldn't even be able to memorise that lol
at least I knew about this...
How do I get the guild ID when using on_member_join?
Database?
you have the member object so
member.guild.id
ty
%s, like so '; DROP ALL TABLES nickname won't be stored with deleting all tables
that won't protect against this
?
that's what users with nicks '; DROP TABLE users; expect
so like if I used f string query would be this INSERT INTO users (nick) VALUES ('haha, bye'; DROP TABLE users;')
oh okay
No hate but I dont think any language can be compared to one another, each has its own purpose
I can't handle it anymore... Creating DB tables in __init__ of Bot subclass...
how do you even do that, since the execute method is a coro, or do people use sync db libs for creating tables lmao
I agree.
x = await random.randint(1, 2)
x = random.randint(1, 2)
like 1st enhance my code ?
or unaffected ?
How can I find messages sent by a user in the past 100 messages
(postgres)
@silk fulcrum
using connection instead of cursors
booo
await gws.send(f"{member.mention}, welcome to **{member.guild.name}**", delete_in=5)
TypeError: send() got an unexpected keyword argument 'delete_in'
Why’s this happening?
delete_after *
fetch the history of the channel with the check kwarg
pools :_)
Did it
ah okay ty
async for message in ctx.channel.history(limit=100):
check = lambda x: x.author == samandra
[message async for message in channel.history(limit=100, check= lambda msg: msg.author.id == user_to_check.id)]```
I would've used it now if I knew about that, now I wrote too much using on MySQL (not even async) and idk to switch or not, cus im layzy
You can do messages = await ctx.history(limit = [number])
And how do I send the message count?
len...
store the list comp in a variable, and do len(var)
hellish
@commands.command()
async def messages(self, ctx, member: discord.Member):
messages = [message async for message in ctx.channel.history(limit=1500, check = lambda msg: msg.author.id == member.id)]
await ctx.send(len(messages))
``` nothing happens
wait
!d discord.ext.commands.Bot.wait_for
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.10)"). 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.10)") 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.10)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/latest/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
which library should I use?
I have used pure discord.py for a year. now everything have changed. My Bot gives me some weird erros
Is discord.py dead or dying?
no
Discord.py is still maintained
it has major changes
If you're getting errors please send them
client.loop is not working anymore sad
yeah it has changed
are you on the master branch or 1.7.x?
and also show your full code because that doesnt tell us much
regenerate your token man
you shouldnt name functions and variables as same but nvm what does messages print
client.loop.create_task now has to be used in an ASYNC context
use asyncio.run or override Bot.setup_hook
nice token
when I asyncio.run it says Client has not been properly initialised. Please use the login method or asynchronous context manager before calling this method
yeah do it in Bot.setup_hook

read the changes on asynciofor dpy 2.0 here https://gist.github.com/Rapptz/6706e1c8f23ac27c98cee4dd985c8120
yeah I think I need to rewrite bot 😅 interesting
ofc, bumping versions = major and breaking changes
!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.
Re writing is a good opportunity to learn 
oh thank you!
yes of course
You don't have to rewrite the whole code just to fix a few errors, it's better to go line by line and fix the modifications
btw there was a Discord.py big server in discord. Now I cant find it. only discord.js is there
thank you
I got ignored again :AScry:
Lol
yep I know 😁
nice
ignoring messages is common in the Internet world
but it's good to know someone goes outside often :p
deep
How can I make the bot reply multiple times when the max_values = 7 on select menu?
a for loop or a task loop?
no?
ok?
Usually you'd have an if statement to check if max_values is 7, then use a for loop to send the messages
!d discord.ui.Select
class discord.ui.Select(*, custom_id=..., placeholder=None, min_values=1, max_values=1, options=..., disabled=False, row=None)```
Represents a UI select menu.
This is usually represented as a drop down menu.
In order to get the selected items that the user has chosen, use [`Select.values`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.Select.values "discord.ui.Select.values").
New in version 2.0.
what's max_values got to do with reply
thats i was going to ask
^^
Hey, I was just looking through some bots and noticed that some bots have a 'supports slash commands' badge and i was wondering how i could get that on my bot?
register a slash command
non-blocking but a for loop is okay too
u don't 👀
how do i do that
ik
make a slash command
why? Cant just if statements and else work ?
" a for loop is okay too"
u need global
also btw the badge dosent show on phone atleast for me
yeah
damn
@shrewd apex do you have any ideas how to make this?
.
i think if interactionl.reponse.is_done() will work somehow
i haven't even got the idea how max_values or reply is related but if u could use a if statement for checking max_values and for loop to reply
but i have need to have two if statements
get the values in the callback using Select.values which returns a list and access the first element of the list which returns the value that the user selected from the drop down, then use a for loop to send the messages
And how the for loop will work if i select one option?
i don't think .values works u have to parse from .data
!d discord.ui.Select.values
property values```
A list of values that have been selected by the user.

hmm i mean for interaction
"Select.values"
👌
from discord.ui import Select
class MySelect(Select):
def __init__() -> None:
super().__init__(...)
async def callback(self, interaction: discord.Interaction) -> None:
for c in self.values[0]:
await interaction.channel.send(...)
here's an example
there is anythink like dynamic bot token ?
i still get error
“Dynamic bot token”?
Does anyone know how to make a discord bot react to certain messages?
For example somebody types "L"
And the bot reacts with the L emoji
and the error is
for c in self.values[0]:
if role1 not in interaction.user.roles:
await interaction.user.add_roles(role1)
await interaction.response.send_message(content=f"**✅ You got {role1}**", ephemeral=True)
else:
await interaction.user.remove_roles(role1)
await interaction.response.send_message(content=f"**✅ You were removed from {role1}**", ephemeral=True)```
discord.errors.InteractionResponded: This interaction has already been responded to before
leomao
use interaction.edit_original_response instead of interaction.response.send_message
for both send_message?
logging in using static token // login message !! thats why i ask
Right, but I fail to see how that’s “dynamic”
hm
best hosting configration for a single server bot ?
I think they're asking about the logging message Logging in using static token, and wondering if there's a dynamic token
yesss
Check pinned messages in #965291480992321536
or replit-
Shut.

should i replace interaction.edit_original_response with both interaction.response.send_message?
hm
dude what does "hm" suppose to mean?
what about deferring + sending one message with all role changes? its a lot easier to read than 7 messages at once
hm
hm 🤔
whats the power of t2.micro ?
1gb ram, 1 core
ohhh k
2 cpus right ?
t3 micro , i think this hv 2 cpus and 1 gb rab
is it ok ?
or should inc ram ?
If you don't need presence intents it should be fine
I would increase just to be safe
what code do you have so far? and what library are you using for your bot?
presence mean the change_presence think ?
right ?/
- create an on_message event
- check the message content (requires message content intent if 2.0^)
- use the
ordfunction on the message content after you pass the content through some checks as required
the ord function returns the unicode of the object
ohh how can i turn it of ?
What intents do you have rn
Well you'll need to use default() and then enable members and message_content
client = discord.Client()
@client.event
async def on_ready():
print("We have logged in as {0.user}" .format(client))
@client.event
async def on_message(message):
username = str(message.author).split("#")[0]
user_message = str(message.content)
channel = str(message.channel.name)
print(f"{username}: {user_message} ({channel})")
if message.author == client.user:
return
if message.channel.name == ':speech_balloon:│general' or ':robot:│bot-spam':
if user_message.lower() == "hello":
await message.channel.send(f'Hello {username}!')
return
elif user_message.lower() == 'hi':
await message.channel.send(f'Hi {username}!')
return
elif user_message.lower() == 'bye':
await message.channel.send(f'See you later {username}!')
return
elif user_message.lower() == 'yo':
await message.channel.send(f'Yo {username}!')
return
elif user_message.lower() == 'cya':
await message.channel.send(f'Cya {username}!')
return
elif user_message.lower() == '!random':
response = f'This is your random number: {random.randrange(1000000)}'
await message.channel.send(response)
return
Hello, I have a problem with the cogs, the commands I put in the cogs do not work, the bot tells me that the commands do not exist
please use a pasting service to send your code
me ?
yes
yes
how do i convert binary from a request into an image and then send it on discord
i would suggest using a dictionary to map alphabet characters to the corresponding unicode (i.e. standard) emoji, then check if their message is in the dictionary and if so, react to it
e.g. py letters = { 'L': '\N{REGIONAL INDICATOR SYMBOL LETTER L}' # there's also several other ways to represent unicode characters } ... if content in letters: emoji = letters[content] await message.add_reaction(emoji) a page of other 🇱 emojis: https://www.fileformat.info/info/unicode/char/search.htm?q=regional+indicator&preview=entity
documentation for add_reaction: https://discordpy.readthedocs.io/en/stable/api.html#discord.Message.add_reaction
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
async def load():
for file in os.listdir("./cogs"):
if file.endswith(".py"):
await bot.load_extension(f"cogs.{file[:-3]}")
I have a problem with the cogs, the commands I put in the cogs do not work, the bot tells me that the commands do not exist

could somebody help me with this I don't usually code so I am clueless
assuming your image is in the form of bytes, you'll need to wrap it in io.BytesIO() to make it file-like, then wrap it again with a discord.File() object, and then you can upload it with the file= parameter in any .send() method
I think you should call add_reaction on the class instance, not the class itself
So whatever that might be, message or msg or whatever
is it possible for a bot to send slash commands?
if message.author == client.user:
return
if message.channel.name == ':speech_balloon:│general' or ':robot:│bot-spam':
if user_message.lower() == "hello":
await message.channel.send(f'Hello {username}!')
return
elif user_message.lower() == 'hi':
await message.channel.send(f'Hi {username}!')
return
elif user_message.lower() == 'bye':
await message.channel.send(f'See you later {username}!')
return
elif user_message.lower() == 'yo':
await message.channel.send(f'Yo {username}!')
return
elif user_message.lower() == 'cya':
await message.channel.send(f'Cya {username}!')
return
elif user_message.lower() == '!random':
response = f'This is your random number: {random.randrange(1000000)}'
await message.channel.send(response)
return
elif user_message.lower() == 'L':
discord.Message.add_reaction(':regional_indicator_:')
return
what do I change
the bit I need help with is the bottom part
Seems like your Message instance is named message, so call add_reaction on that instead
^ also you cant directly paste :regional_indicator_l: since the emoji is part of the unicode standard, you need the unicode format as i described before
Or to put it simply, replace discord.Message with message :p
..
send as in?
invoke
Like execute slash commands from other bots?
other bots command
No.
You'd be... botting a bot using a bot
no way
ctx.send(discord.File(fp=io.BytesIO(image.content))) like this?
No way. But if there was a way, the bot (or Discord) would probably not allow it
there isn't a way and it's hard to think of one
with the file= argument before the discord.File
thanks
elif user_message.lower() == 'L':
message.add_reaction(':regional_indicator_l:')
return
Renamed the variable but the command is still the same
I changed it to this but what did I do wrong
Seems about right. Make sure to await that call, too
And change :regional_indicator_l: to the actual unicode character
elif user_message.lower() == 'L':
await message.channel.send(response)
message.add_reaction(':regional_indicator_l:')
return
is that what you meant or no
No, add the await to the add_reaction call
what does the list comp print
multiple instances of my bot are running how could i fix this if i am on replit
elif user_message.lower() == 'L':
await message.add_reaction(':regional_indicator_l:')
return
like this?
Looks right.
reset the token, easy
ok thank you
ok
U+1F1F1 this is the unicode btw
Replace :regional_indicator_l: with 🇱
imagine making a conditional for every emoji 
it didn't work
did the :regional_indicator_l: work, though?
nope
Is there any error message?
Easiest to pass in the actual emoji
You can copy it off emojipedia if you’d like
ok
Many OSes also come with a native emoji picker
like that?
The L at the beginning?
Right
how would i be able to make this a thumbnail for an embed
just copy it from discord 
There should also be a copy button on screen
It copies the text with the ::
os variations then
L
@south steppe u could use the unicode for L U+1F1F1
none of this is working sadly, should I send the full code again to show what I have done?
No need, I know what you’re trying to accomplish
I tried that and it didn't work
ok
I’m guessing it’s because of the if statment
You’re checking if a lowercase letter is equal to an upper case letter
Which is never true
Awesome
thank you everyone that helped me 🙂
robin supremacy
haha
I can’t ping mods dammit
there's an FAQ entry for this
https://discordpy.readthedocs.io/en/stable/faq.html#how-do-i-use-a-local-image-file-for-an-embed-image
essentially the important part is setting the filename= for your File and the url= argument on Embed.set_thumbnail()
<@&831776746206265384> here it is
Someone wanna see smth cursed? 👀
I have one more question
sure
Is it possible to keep the bot logged on without having the script open all the time?
no.
oh damn ok
how are bots always online for example mee6
jeez, how do you find such people
hosting
VPS
they either use a hosting service or have the bot running on a private device
oh ok
Don't ask
thanks for helping me understand, I thought it would be hosting but I was making sure 🙂
Plot twist: MEE6 is hosted on 1GB RAM Windows XP
BTW there are a few hosting services in #965291480992321536 in case u need help designing
Feels like it sometimes
lol
need to stop using discord at this point
free years of AWS with alts superior
and oracle hosting 
plot twist our life is simulation
I mean......it doesn't deserve better
chat became dead!!!!!!!!
omg
Didn't know everyone hated MEE6
it is hatable so can't prevent honest feelings
How is this thing "hatable"?!
https://www.youtube.com/watch?v=l5wvqKcqL7c
I’m a compilation of all the best Mr. Meeseeks moments, look at me! Stream seasons 1-5 now on HBO Max: http://bit.ly/3hRw9rU
#AdultSwim #RickAndMorty
SUBSCRIBE: https://youtube.com/adultswim1?sub_confirmation=1
What to watch next: more Rick and Morty clips!
https://youtube.com/playlist?list=PLQl8zBB7bPvI_iYCe4LT8HHfjonOog4u3
Watch the Adul...
don't-
it's @bot.event
any error?
what...
well then guild is None prolly
doesnt matter if the guild isnt in the cache then it'll return None either ways
is it easy to host on aws? kinda broke rn to spend on a host
math.ceil(error.retry_after) vs int(error.retry_after) // any diff ?
like int was more op for mr
me*
math.ceil rounds to nearest number, int removes digits after .
!e
v = math.ceil(5.34)
u = math.ceil(5.74)
w = int(5.34)
x = int(5.75)
print(v,u,w,x)```
@limber bison :x: Your 3.10 eval job has completed with return code 1.
001 | File "<string>", line 2
002 | u = math.ceil(5.74)
003 | IndentationError: unexpected indent
!e
v = math.ceil(5.34)
u = math.ceil(5.74)
w = int(5.34)
x = int(5.75)
print(v,u,w,x)```
@limber bison :white_check_mark: Your 3.11 eval job has completed with return code 0.
6 6 5 5
upwards to the nearest number*
got it
u need a credit card tho👀
just get one 
not happening unless i am 18
im 13 💀
same 
patience 
how do you work without a cc company pays in cash?👀
"with without"?
f autocorrect
debit cards exist
🥲 🆗
yeah that's nothin
only 5
passes by in a flash
U can make paypal acc
go play on the streets by that time 
eh try to avoid qr code payment methods
i dont have friends
alleys*
Imaginary friends
how to play

Lmao 😂
except okimii
under the bedsheet
play with Asher 
...
U can code a bot to play with u
@shrewd apex lets play somegames
they're too stupid for a human
bring ashley along too three much more fun than two
It’ s as stupid as u make em
reason why you guys have no friends
@slate swan @shrewd apex lets play somegames
I’ m good, I was just tryna help him out
dont give bad advice
friends aren't something to be made fun of
especially when you dont have any
wtf( why this started playin
😂
🗿
empathy
how can i get my bot online 24/7?
i make fun of you all the time tho
no
do you have a website for that?
why v2 dont support diff extention for a single cog 🥲
whyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
fix it bisi
wdym for a single cog?
you can reload extension
what is wrong with that
i mean like i make a class xx in with my commands , i cant use the same class in another file again in discord,py v2
file 1
class xxx
@commads.command 1
#shit
setup(xxx)
file 2
class xxx
@commads.command 2
#shit
setup(xxx)
__this didnt work in dicord.py v2 i dont know why ?
you still haven't finished solving the problems?
why would you need this?
why not put command1 and command2 in one file
when i reload , both will be reloaded
and what?
and asyncio.sleep disturb
scheduling 😎
nope, your own scheduling sys, e.g.: https://github.com/python-discord/bot-core/blob/main/botcore/utils/scheduling.py
I need a command idea cuz I'm bored 😔
minesweeper
ew nobody plays that on discord, some other
does anyone even play Minesweeper in first place
i do (when im bored)
thanks
found one in vicinity
.
go sleep👀
I already did 
make candy crush command
...
¯\_(ツ)_/¯
that's just like minesweeper but not minesweeper
yeah it's tougher and interesting
altho it's prolly gonna be a chore to make
totally not me, not into games within discord, thanks
well just make so fun facts or interests stuff calculator commands ig
calculator
ok
Calculators are good projects to practice making a lexer on
Do u want to see something cool
yes
uh join this zeffo.me/guac
doesnt seem so trustable, I'll be fine 
Hey have any of you tried to run a discord bot on an android smartphone? Im wondering if it would still work, im thinking about using pydroid
It would but probably would be quite limiting
How so?
yes it will work
CI would be a pain
Whats CI?
continuous integration
Like working on it and updating it?
That's one aspect of it
Also for databases, you'll need to host those elsewhere
Or use a file based one
Which would be a bottleneck if you have a lot of data
Right, im not at that stage yet but i can see how that would be an issue for a bigger bot with many users n servers
discord bot developping pain:
When the bot is being used by people and you're making edits with another bot on another server, and you gotta push your edits without the test server and bot configs and pull them on the working bot feels like UGHHHHH XD
raise your hand if you're also annoyed by this XD
If it's really that big of a problem just setup some CI workflow that runs after test cases pass
Hello, I have commands in cogs, I know that the files are supported in main.py but the commands do not work
probably this
#discord-bots message
I think it's not that
for file in os.listdir("./cogs"):
if file.endswith(".py"):
bot.load_extension(f"cogs.{file[:-3]}")
I have do that for the cogs
But the commands do not work
This is the problem ?
i dont think so, but that's unlogical

#help-croissant need help with discord.py
they would raise an error
you named class and function the same (embed), that looks sus
(class embed, async def embed)
Do you have 3.10 installed?
install 3.10 first then
it only says Python 3.11 (Dxbs) C:\Users\Owner\Script\python.exe
U have installed only 3.11 then
yes
so I need to delete 3.11 in order for 3.10 to pop up?
then search for it using browse then select python.exe in 3.10 directory
just deleted 3.11
go to settings
ok
bbruh
click cntrl alt s
ok
k
add python interpreter
it should say local right?
and then browse to 3.10 directory
yes
k
and select python.exe
bro here worked faster than sanitizer 🗿
thats hwat pops up
yes
what*
click apply then ok
k
python3.11 bro.py
u already have a venv then 👀
bro im so frustrated
wait so I just need to type in my code then click run and it should work?
it still says this
like BRO this is getting on my nerve
you would be correct
and 3.11 should've prolly been ur latest
u can just delete the project and create a new one
if i deleted 3.11 then why is it still popping up as a interpreter
oh and it should be fixed?
it would show invalid next to the interpreter tho
yes
ok so it looks like this
where it says base interpreter
theres option that says 3.11 and 310
I click 310 correct? @shrewd apex
im sorry im confusing you im just frustrated
yes
yep
hmm give me a few secs
k
pip install virtualenv
terminal?
run this in your terminal
k
yes
ok it says
[notice] To update, run: python.exe -m pip install --upgrade pip
PS C:\Users\Owner\PycharmProjects\pythonProject2>
``` is this good or bad?
yea
ok try again now
k
says this now
just do it again
thats what it says in settings
just add one manually
and it seems u have 3.11 installed in two different places or u didn't delete it first time
so 3.11 installed in 2 diff projects?
most probably yeah
ok so do I do? pip uninstall python 3.11
@shrewd apex
damn pycharm seems like ass
apply then ok
ok
ah no it's not that bad as it's showing up here 🗿
1 thing after another -_-
face of pycharm users gone
@bot.event
async def on_cooldown(ctx, error):
if isinstance(error, commands.CommandOnCooldown):
await ctx.channel.send("This command is still on cooldown!")```
@commands.command()
async def sm1(self , ctx):
tst = ["a" , "b"]
first = random.choice(tst)
second = random.choice(tst)
third = random.choice(tst)
mag = await ctx.send(f"🎰 | :owosloth:")
await asyncio.sleep(1)
await mag.edit(content = f"🎰 | {str(first) } | :owosloth:")
await asyncio.sleep(1)
await mag.edit(content = f"🎰 | {str(first) } | {str(second)} | :owosloth:")
await asyncio.sleep(1)
await mag.edit(content = f"🎰 | {str(first) } | {str(second)} | {str(third)}")
if first == second == third:
await message.channel.send("You win!")```
uh...
ok
do this correct?
yeah
oh wait I fix it
run it send traceback
why does the name of the function matter in if the code works or not??
ok
whats it ?
because that's the event name??
unless you specify the event name in the deco which you aren't
run the code send the error
uh ok
uh under my project were?
i just feel so slow when it comes to this it just feels like i cant keep up bro
how will it know which event you want? If you don't give it event name
bruh project files
sry mb
its working properly but i dont know why invalid syntax
which line is it pointing to
and did you run the command
ok im here
there's no character at col 26, refresh your ide and see
and did you test the command
:/
yes working correct
col 26 mean ?
26th character
So... I was testing the @commands.is_owner() and the command still works for anyone
🛌
I have already defined owner_id
did you use it on an app command?
yes
That might be why
well it's meant for text commands not app commands
That decorator is for text commands I believe
oh
!d discord.app_commands.check
@discord.app_commands.check(predicate)```
A decorator that adds a check to an application command.
These checks should be predicates that take in a single parameter taking a [`Interaction`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.Interaction "discord.Interaction"). If the check returns a `False`-like value then during invocation a [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.CheckFailure "discord.app_commands.CheckFailure") exception is raised and sent to the appropriate error handlers.
These checks can be either a coroutine or not.
Examples
Creating a basic check to see if the command invoker is you...
I guess I'll have to do it myself
oh yeah it looks like it will check in dev portal if the owner_id is not defined
but I did it to check if maybe it would work
@commands.Cog.listener()
async def on_member_join(self,member:nextcord.Member):
role = member.guild.get_role(933983900609441812)
await member.add_roles(role)
how can i make it so that it adds new members the role after 10 minutes of joining?
!d asyncio.sleep
coroutine asyncio.sleep(delay, result=None)```
Block for *delay* seconds.
If *result* is provided, it is returned to the caller when the coroutine completes.
`sleep()` always suspends the current task, allowing other tasks to run.
Setting the delay to 0 provides an optimized path to allow other tasks to run. This can be used by long-running functions to avoid blocking the event loop for the full duration of the function call.
Deprecated since version 3.8, removed in version 3.10: The `loop` parameter. This function has been implicitly getting the current running loop since 3.7. See [What’s New in 3.10’s Removed section](https://docs.python.org/3/whatsnew/3.10.html#whatsnew310-removed) for more information.
Example of coroutine displaying the current date every second for 5 seconds:
thank you, trying it now
@commands.Cog.listener()
async def on_member_join(self,member:nextcord.Member):
role = member.guild.get_role(933983900609441812)
await asyncio.sleep(600)
await member.add_roles(role)
is it like this?
10 minutes of sleep ew
doesn't matter
what if the bot stops
why would it do that
alright, so I have half of an hour to finish switching to asyncpg, or i'll leave it like it is right now and finish tomorrow, but tomorrow is a busy day so im gonna die
so possibly another approach to your problem (im not entirely sure it will work, but am testing it now) would be to set your server moderation setting to High and then once the 10 minute safety period is up the permissions for that member should update automatically to allow them to send messages. You can watch for the permission change through on_member_update
again, not entirely sure if this approach will work, but I can let you know for certain in about 8 minutes. It beats having to asyncio.sleep for 10 minutes I can tell you that.
on start:
for member in guild.members:
if role not in member.roles:
if member.joined_at > 10 minutes:
give role
else:
await asyncio.sleep(10mins-(now-member.joined_at))
and then gib role
except it should make tasks about the last else
that would only update everytime the bot restarted
making it not even close to what he wants to happen
he can keep the listener bru
if he keeps the listener there is no need for that code
yes incase the bot once shuts down
it's a fix to a possible problem
making the system more stable
and cluttered
I'll go translate that
and you will be iterating through every single member in a guild, and each one of their roles. causing a huge processing time
no
its not an efficient solution
what about looping through
list(set(guild.members) - set(role.members))
what if the guild has 100K members, and each member has 5 roles?
you are looking at 500,000 iterations to catch what, a maximum of 2-3 members that joined during shutoff?
that sucks
.
then you don't even need the first if statement
is it still too much
at that point everything's too much
and now I have to create postgres database(
Nice
so i set up a set_a and set_b by using the following: py set_a = set(i for i in range(100000)) set_b = set(i for i in range(99998)) and then used the timeit library to compare the operation times for ```py
list(set_a - set_b)
just statistically, if one iteration takes 0.16 seconds and I did 10000, I should expect to see around a 26 minute completion time.
You can do set(range(...)) btw
true
one iteration 0,16sec?
yep
that's a lot
I think for the proposed use case of 2 users, it seems like a bit much. I know 0.16 seconds is a relatively small amount of time but if you can cut processing time, you should.
the 10000 iteration test just finished with a completion time of 1480.73 seconds - or roughly 24.6 minutes
ok that's not worth it
no? also why would db take money?
i use mongodb which only give 512 mb free!!!
The engine doesn’t, but often you’ll need a seperate hoster for it
I used PostgreSQL (not async), then switched to MySQL (not async) and right now switching to PostgreSQL (async). All of them did not take any money to store certain amount of data, and I don't think mongodb would, ig that's cause of host
what was the limits ? for SQL and mySQL ?
what limits? why should there be limit?
If you’re going with a good database host they won’t limit your database sizes
yayyyy, I have good host
SQL isnt a db lol
i guess he meant Postgres
i mean postgres
does the host also provide you a database?
I've returned cuz I think I just got it
also, hi @slate swan ✌️
well postgres is based on SQL, so dont mix them up😅
you subtracted the sets 10000 times?
hi hi
ohh lul
It just provides me, like, an ubuntu terminal and certain amount of memory
hmmm is mySQL and others freee ?
or come with hosting ?
so i can host anything, bot, db, website
Anyone know if its possible to put buttons on a webhook
so you can install what you want right?
how much memory have they given you?
uhm... alright gotta remember how to check that
omg I forgot how to login there 😳
I lost access to host?
not sure what yall are talking about but if your looking for a host just for a bot, and you dont want a vps just find a host with a game panel (ptero), that comes with a mysql database for most hosts then you can upload your files for your bot
bruh now Hokker will run forever
so they provide you a VM?
on old version
yeah, smth like that ig
on a webhook you can add only url buttons, you could add all buttons to an embed sent by your Bot
or just a kernel?
damn that sucks, ight thanks
uhm idk, ig it's like a VM
i don't think it's a VM
i doubt they would give you a full on VM tho
i dont even know who they, ya know im 13, so that's my dad's host lmao
he uses it for hosting his site, idk what's that site for
in theory they use a virtualization software that create partitions and install the os, then they assign resources to it and limit some destructive actions
the copy paste tho lmao
you sure mr

i guess they use virtualization software and give you ubuntu to access the database server ig
what does that even mean
🗿
in theory they use a virtualization software that create partitions and install the os, then they assign resources to it and limit some destructive actions
I'm gonna send that to everyone so I seem smart
youre the opposite of smart


i remembered that I used a ssh command to log into the host, but I don't remember what goes after it:(
Literally just another word for sandboxed VM
bruh
space
i would love to learn linux but i would end up like you forgetting all the commands😭
remembering a command in linux is a skill
skill issue(
wasn't it like ssh:username@password? I'm not sure of :
or was it ssh? now im not even sure(
was I even wrong with just the word space
i cant remember anything when youre living in my mind rent free😔😡
gonna ask my dad when he comes home
ssh <hostname>@<ip>
sudo nano filename
E,g ```
ssh root@127.0.0.1
Except I don't know why you would allow root ssh like that for security reasons
sudo chmod +x filename 👋

im just here with windows 11
omg i somehow remembered that it's ssh dads_site_url
but now I forgot my password AHHHH
my dads site never loads
because everytime it logged in automatically without asking it
guess im fatherless
and now it is
😔
rm bin32
lmao bye
isnt rm remove?
yes it is
i know it cuz of docker 🧠
niceee my keepass is never bad
oh wait I just revealed my dad's site
but who cares anyway, it's empty

.ru are you Russian?
.ru seems sus
yes(
random question does it have HTTPS
nope
👁️👁️
Good 😈
😳
TLS certificates do be pricy
this is what happens here with my bot...
skill issue
issue skill
There are so many services that give free TLS certificates
give me the services
Instead of asking me to do research for you, why not yknow google it?
i dont have google
ill bing it
Okay
dad said when memory ends it uses Swp mem and when it ends it just kills my app. Spoiler: ||my Swp is already full, so when mem ends bot will die||
sed
im loving the 480p background😍
Do you know any good hosting site for a bot?
Deleting bin32 your memory will be free
heroku is good😳
how can bot know wather some some role have or not /
Check pinned messages in #965291480992321536
AWS >>>>>>>>>>>>>>>>>>>>>>>>
https://discord.com/developers/docs/tutorials/hosting-on-heroku#hosting-on-heroku its even recommended by discord😎
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
Because it’s a web server handling interactions over HTTP
okimi suggests replit
Heroku is decent for that
not really
Better than using it for a regular websocket based discord bots at least
how can i find a user have some role or not ?
?????????????????????????????????????
how you know?
if i have user uid
I'm spying on you 😳
Map the users roles to ID and see if they have a certain ID
why dont you show yourself, maybe i can show you something😳
i can show you my esoteric code base
😎
I can see it without showing myself
you cant sadly, the font is tiny😔
Well, this is a good reason to show myself
yup😳
Noooo I have to 'power up' a replit account to use my private repository
are you using replit to host your Bot? 😕
user.role.id will give me arry of roles right ? then i use x in y ?????????????/
for safety I will do del system32, you can't use my pc if I don't have an os
Best cybersecurity practice
who said i had a system32?
running on that system64😳
you have system36
nope im running on that system69 
Is heroku a decent site to host a bot?
Not really
[i.id for i in user.roles if i.id == your_id]
idk if its the best option
Unless you have an interaction only bot over HTTP
what does it struggle on? keeping TCP connections alive or something?
what a random number
a funny number
It suffers from a lot of the drawbacks of replit, mainly it wasn’t designed for discord bots
is this good?
i want a more elaborated answer Robin, Robin? more like Robozo
😎
Just check if your ID is in it without using the if list comp
If you want a more elaborate answer look at the pin in #965291480992321536
😒
Unfortunately “Robozo” works a lot better than “Okiibozo” so you win this round
kinda funny how my real name also starts with "Rob" and im bullying you lmao

then you're a real robozo
me and robin, were the Robozos
robozos team
you're at index 0
del robozo[1]
bye, bye robin
it's robozos
i have user id of a user how can i know he have some role or not !!!!!!!!!!!!!!!!!!!!!!!!!!!
if role_object in Member.roles:
...
or user a member object
check the user's roles
Like i said already, map the user’s role to a list of IDs, then check if the ID you want is in there
ohhhh role object
got ittt
Robin make a pr that adds a new method that returns boolean if a member has a certain role
Member.has_role()
btw a user id could be only of a user lmao😕
I just gave Robin an idea that can make him a high level contributor in dpy
Member.is_bozo()
would also be really useful
😳
im going to go, see ya guys👋
bye
Redundant
bye cute hampter
Also ambiguous
cya
youre redundant but you dont see me saying anything🤨
Rather let the user decide how they want to do it
👋
im gonna report you 😭
I'm your hamster
im sorry, i should not bully my brothers that names start with an R🫂
https://discord-edating.com/OzU8QZC4 am i dumb or, anyone have a idea how to do this?
errorColor is a str(hexcode), do i need to add 0x to the string then convert errorColor to a int for the embed colour? or what
😏
You just need like, 0xFF0000 which is red
No quotes or anything
now I can see your esoteric python
yea but, im storeing that in a var, where thats from my json config file
😩
You can still store that
oh
color = 0xFF0000
does json allow that?
And pass it in
as im getting it from a json file
hex(x)```
Convert an integer number to a lowercase hexadecimal string prefixed with “0x”. If *x* is not a Python [`int`](https://docs.python.org/3/library/functions.html#int "int") object, it has to define an `__index__()` method that returns an integer. Some examples:
```py
>>> hex(255)
'0xff'
>>> hex(-42)
'-0x2a'
``` If you want to convert an integer number to an uppercase or lower hexadecimal string with prefix or not, you can use either of the following ways...
yea so how can i convert "0xFF0000" to 0xFF0000
o
AttributeError: 'Member' object has no attribute 'has_role' ???????????????/
!d discord.Colour.from_rgb
classmethod from_rgb(r, g, b)```
Constructs a [`Colour`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Colour "discord.Colour") from an RGB tuple.
!d discord.Colour.from_str
classmethod from_str(value)```
Constructs a [`Colour`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Colour "discord.Colour") from a string.
The following formats are accepted...
@indigo pilot
No, Okimii was just making a suggestion. It doesn’t exist
ohhh lol
f
but its in check right ?
tyty
Yeah it’s a check
Which is why I said it was redundant
https://i.leaked-your.info/wgkj6skm right? errorColour is "#{hexcode}"
I spent like 20 some odd minutes writing up a monkey-patched discord.py weakref cache to lower memory footprint then I just scrapped it all
why cant i add reactions in slash commands?
By chance someone can enlighten me on how I can force send a message using pycord?
Basically today I send my self some notifications to an email, and after that I want to use pycord to send a message into a discord channel as well, but pycord seems to be very "trigger based", how can I simply just send a message without the need of some user interaction?
@bot.event
async def on_message_edit(before, after):
muted_role = discord.utils.get(after.guild.roles, id = 901514773785636905)
keywords = ["slay", "sllay", "slllaayy", "slaay", "sslay", "sl@y", "slayed", "sl@ys", "sl🅰️yed", "sllays", "sl🅰️y", "sl🇦yed", "sl🇦y", "siay", "slaaaaaaaaaaaaaaaaaaay", "sláy", "slãy"]
if after.author.bot:
return
content = str(after.content.lower())
for i in keywords:
if i in content.replace(" ", ""):
print(i)
await after.channel.send(after.author.mention + " Slay? Slay what? Can you slay this mute?")
await after.author.add_roles(muted_role)
await after.channel.send(str(after.author)+ " has been muted for 30 minutes.")
await asyncio.sleep(1800)
await after.author.remove_roles(muted_role)
await after.channel.send(str(after.author) + "'s 30 minutes is over.")```
on a normal bot.listen it works but on an on_message_edit it apparently has no attribute??
you need to do await message.fetch() first, msg = await message.fetch() will return InteractionMessage which has add_reaction method
after is type User, which means the message was either edited in DMs or it's a bug
but this bug is happening every time
well, then try getting member via user id, so like user = after.guild.get_member(after.author.id)
How do I find on_something docs
alr
what did you search for
I want to see all the events
ohh



