#discord-bots
1 messages · Page 853 of 1
YeA
It’s literally bad design. Id rather have nothing than hot garbage in my bot.
Isnt that what everybody did-
anyone know why sleep is like that prob did sum dumb
So here is why
It doesn't have any kinda of new feature's
!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:
Poggo
And all the forks are very horrible
Serious talk Ashley.
Pycord best-
Not really
My apologies
That's the worst choice you could have picked bucko
I don't want to just use some fork of discord.py
Disnake is crispy
Lmaoooo, who even takes pycord seriously anyways .-.
Pretty nice
That is why i use jda now
Honestly sleep_until is probably just this tbh
Anyways its getting late for me i gotta sleep or my mom and dad will kill me
MOm is shouting now i gotta go
Good nighto, have a good sleep
asyncio.sleep(datetime.datetime().seconds)
Gn
You don’t need to, I’m with you on this one
Don’t like the forks all that much
Pain
Can I also be with you? I don't use any fork to dev bots anymore 🥺
Gladly
......
¯_(ツ)_/¯
Lmao Hunter, stop using that emoji
can you use the same function names if they're in different classes?
!rule 7
7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.
My bad. This is wrong
Yes, the methods are bound to their specific classes
It’s probably a timedelta between the datetime.datetime() passed in and datetime.now()
ah awesome thanks
and?
Yeah of course, even dpy uses that
Obey it
can anyone help me making a verify bot
What are we gonna do? Boost the process?
just help me
idk what to do next
Help with what
code
So it’s like
asyncio.sleep((datetime.datetime() - datetime.now()).seconds)
Something along those lines
I see
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
keys = ["124790", "128946", "855295", "456789", "235782", "1256341", "123456", "239851", "275690"]
@commands.Cog.listener("on_message")
async def on_message(message):
if message.author.id == (427399578720141312):
return
if message.channel.id ==(938474842573910119):
return
if any(word in message.content.lower() for word in keys):
await message.channel.purge(limit=1)
verifyRole = discord.utils.get(message.guild.roles, name = "Member")
await message.author.add_roles(verifyRole)
await message.channel.send("You have now been verified", delete_after=10)
else:
await message.channel.purge(limit=1)
await message.channel.send("Please type the correct number")
def setup(bot):
bot.add_cog(verify(bot))
Oh hell no, I'm out
?
Use the delete method....
?
What issue are you getting?
idk how to make a bot dm
!d discord.Member.send
await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.
To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.
To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
just use the send method on the Member object
and how can i make it send randomly one of the keys on join
!d random.choice
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").
import random
await Member.send(random.choice([options]))```
why [KEYS]
Ahhhh my brain rotten
u r just sleepy lol
But i'm not able to....
Rip i cant think clearly now
sleeping pills anyways let's take this to #ot2-never-nester’s-nightmare
you switched to hikari?
please tell me you're trying to say you switched to hikari
i don't dev bots tho
the last time I opened HunAI's source code was like 3 months ago
Can relate. Bot development isn’t as fun as it used to be.
Indeed. There are hundreds of bots for literally the same thing
Really, welp
Carl bot supremacy
Lol
can i ask something about a whois command?
sure
No
👀

go on
Don't ask me the API it uses cz I never seen one
@bot.command(name="whois")
async def whois(ctx, user: discord.User=None):
guild = bot.get_guild(901481491337465928)
if user==None:
user=ctx.author
if ctx.guild.get_member(user.id) != None:
user = ctx.guild.get_member(user.id)
roles = []
for role in user.roles:
if role == ctx.guild.default_role:
pass
else:
roles.append(role.mention)
embed = discord.Embed(description=f"{user.mention} | `{user.id}`", colour=user.colour)
embed.set_author(name=f"{user}", icon_url=user.display_avatar)
embed.set_thumbnail(url=user.display_avatar)
embed.set_footer(text=f'Author: {ctx.author} | {user.id}',icon_url=ctx.author.display_avatar)
embed.add_field(name="**Display Name**", value=user.display_name)
embed.add_field(name='**Created**',value=user.created_at.strftime("%a, %#d %B %Y, %I:%M %p"))
if user.public_flags.hypesquad_brilliance:
embed.title += f":HypeSquadBalance:"
if user.public_flags.hypesquad_bravery:
embed.title += f":HypeSquadBravery: "
if user.public_flags.hypesquad_balance:
embed.title += f":HypeSquadBrilliance: "
if ctx.guild.get_member(user.id) != None:
embed.add_field(name='**Joined**',value=user.joined_at.strftime("%a, %#d %B %Y, %I:%M %p"))
embed.add_field(name=f"**Roles** [{len(roles)}]", value=" ".join(roles))
await ctx.reply(embed=embed)```
why wont the bot send the embed that contains the roles etc, for someone who is in the server?
Okay
but now, its a bit messed up..
What is the error
Imagine printing the error with an else
and what is yr definition of correct embed
else:
raise error
ftw
No, print
I do that. Keeps the console clean
Nvm its raise
when i do ,whois on a member in the server it sends the embed on a member who isnt in the server, whereas i want it to send an embed containing what roles and what their display name is.
a member who isnt on server? How is the person even a member?
i mean user
Lmao facts
if ctx.guild.get_member(user.id) != None: @final iron would like to have a talk with you
Lol
Wish it was C ;-;
It doesn't work like that in C and stuff. U gotta assign it to a variable first and then compare
with pycord ^
alright
What would be a good database for the userbase of a discord bot
sqlite
You know that Ash is quarterly aware of what is happening right now, right?
I am not even quarterly aware. Got a headache anyways
i got menstrual cramps and pain, wanna compare?
uhhh no thanks
mhm
Sqlite, you can use the internal package sqlite3 for synchronous programs and the external package aiosqlite for asynchronous
anyways #ot2-never-nester’s-nightmare before someone comes here
I’m happy to go cooking with Alexa
You dont want to, also ot as hunter did the honours
@slate swanfriend
@bot.command(name="whois")
async def whois(ctx, user: discord.User=None):
guild = bot.get_guild(901481491337465928)
``` why guild = bot.get_guild
u have ctx.guild
i don’t know i thought it wouldn’t work because i hadn’t defined guild
if user.public_flags.hypesquad_brilliance:
embed.title += f":HypeSquadBalance:"
if user.public_flags.hypesquad_bravery:
embed.title += f":HypeSquadBravery: "
if user.public_flags.hypesquad_balance:
embed.title += f":HypeSquadBrilliance: "
``` you can only have 1 of those, so do elif
else: None
why f-strings
i don’t know it’s just something i found
@bot.command(name="whois")
async def whois(ctx, user: discord.User=None):
guild = bot.get_guild(901481491337465928)
if user==None:
user=ctx.author
``` into
```py
@bot.command(name="whois")
async def whois(ctx, user: discord.User=None):
#guild = bot.get_guild(901481491337465928)
guild = ctx.guild
#if user==None:
# user=ctx.author
user = user or ctx.author
ok
if user==None:
user=ctx.author
then u have this
if ctx.guild.get_member(user.id) != None:
user = user or ctx.author
huh?
@maiden fablewhy u repeating?
What?
Okay didn;t read
so instead of:
if user==None:
user=ctx.author
i should have:
user = user or ctx.author
basicly does same
ok
anything else i should change?
hey guys I making a command to pick a winner for me like if i say !wonder it should say you won or better luck next time but the chances should be very low of winning what should i write in if statement or is there an another way to do that?
i dunno i gave u little but it will shorten down ur code alot
depends how % winchance u want?
1%
if u want 50/50 wich i said no then u could have a toss a coin
random.randint(0,1) if 1== u win if 0 u lose
or use 3 numbers pick 1 as winner and u have 33%
i don't want to pick from numbers
random.randint(0,2) if number is 1 winner
@leaden plazaeeh how u thinking now?
i just tried help u but whatever
How do I make a script where python recognizes the file extensions of all the files in a folder/directory and print them? os.path.splitext()?
Thanks for ur help man i really appreciate that
or check if last last dot n split
cause there can be myfile.lol.txt.py
or if only checkif its py
string[:3].lower() == ".py"
so
files=os.listdir().split(".")
print(files)
if files=="".......
if files[:3].lower() == ".py"
if files == "*.{file extension}"
yes but what if a file ext is 4 chars
ignores first n last after 3rd
if ext has 4 chars its not py
thats where . spliit dot comes in then
check last .
split make to lower() and fit it
0 to 2*
I mean I want to recognize every file ext not .py
wait nvm
wrong
indexes from the position 3 to right
yea mb
!e
string = "monkey"
print(string[1:2])
@honest vessel :white_check_mark: Your eval job has completed with return code 0.
o
!e
string = "monkey"
print(string[1:4])
@honest vessel :white_check_mark: Your eval job has completed with return code 0.
onk
It doesn't include the element at the stop position
!e
string = "monkey"
print(string[1:len(string)])
@honest vessel :white_check_mark: Your eval job has completed with return code 0.
onkey
hm
Good Evening — Today at 7:58 PM
so What is the final code?
every file extension
ur in discord channel but this is a python question
😤 id id it wrong
!e
string = "monkey"
string2 = "u do dis?"
print(f"{string[-1:]} {string2}")
@dull terrace :white_check_mark: Your eval job has completed with return code 0.
y u do dis?
if file[:4].lower() == ".exe"
is it correct
that would work
haha np i just hope u learned how to sub a string
🗿
!e
string = "slicing hurts my brain"
print(string[4:])
@dull terrace :white_check_mark: Your eval job has completed with return code 0.
ing hurts my brain
!e
string =" brain hurts"
print(string[:4])
💀
@honest vessel :white_check_mark: Your eval job has completed with return code 0.
bra
!e
string = "slicing hurts my brain"
print(string[-4:])
@dull terrace :white_check_mark: Your eval job has completed with return code 0.
rain
there is no option for .split() though if the os.listdir() is users input. I mean, you ask the user to enter a dir to list. os.listdir(user input).split() doesn't exist
is there a way to bass boost voice chat audio on my bot with pafy?
positive numbers kinda make sense because it's as if each letter is a list entry
str(word).split()
negative hurts brain
lol
🗿
created_at = member.created_at
formatted_initial_date = discord.utils.format_dt(created_at)
subtracted_days = datetime.timedelta(14)
almost_final_date = created_at - subtracted_days
final_date = almost_final_date
formatted_final_date = discord.utils.format_dt(final_date)
current_date = datetime.datetime.utcnow()
if final_date < current_date:
await ctx.send("Bad.")
elif final_date >= current_date:
await ctx.send("good")
i require assistance
i need something for current_date because can't compare offset-naive and offset-aware datetimes if i compare created_at and final_date works fine but there's no point in that, i don't like working with time 
almost_final_date
thats a cute mf varaiable tho :D<3
final_date = almost_final_date <- no need?
current_date = datetime.datetime.utcnow() should been run first tho
enterpath=input("Enter the path of the file: ")
invis_RBT.say("Enter the path of the file") #Ignore that, it is texttospeech yk
invis_RBT.runAndWait() #this one too
files = str(os.listdir(enterpath)).split()
if files[:4] == ".exe":
print("There is an executable file in the directory you entered. Watch out!")
else:
print("Clear.")
``` Returns clear even though there is an exe file in 'Downlaods'
try avatar.url
OH IT IS [4:] not [:4]
first int means from right to left and the second means from left to right
so what is correct? I tried both ways and both showed clear instead of 'there is an exe file watch out'
lol
idk what helps you lol
more like what fits
grammarly
I didn't split damn
lemme try again
!e print("hello"[:-4])
@slim ibex :white_check_mark: Your eval job has completed with return code 0.
h
maybe for file in files
wtf
it's the same thing
@honest vessel Yooo I did it look:
enterpath=input("Enter the path of the file: ")
invis_RBT.say("Enter the path of the file")
invis_RBT.runAndWait()
files = str(os.listdir(enterpath)).split(".")
for file in files:
if file[:3] == "exe":
print("Executable File Detected!")
else:
print("File clear.")
why am I proud lol
what does pep even stand for
Python Enhancement Proposal
i always forget it🏃
How do you delete the invocation command with the bot?
what a nerdy acronym
guys, in an on_command_error event, the error param is an object of what class?
@mainunban.error
async def mainunban_error(self, ctx: commands.Context, error):
if isinstance(error, commands.CommandNotFound):
await ctx.send("This command has a bug! DM @unkempt yacht about it. Sorry for the inconvenience.", delete_after=5, ctx.message.delete())```
like that?
oh wait, why did i put an f string
now
no
does the 8 just stand for the eighth proposal
if you want it to delete the message 5 seconds later you have to manually sleep
ok
anyone know?
too lazy to read docs
discord.ext.commands.CommandError
!d discord.ext.commands.CommandError
exception discord.ext.commands.CommandError(message=None, *args)```
The base exception type for all command related errors.
This inherits from [`discord.DiscordException`](https://discordpy.readthedocs.io/en/master/api.html#discord.DiscordException "discord.DiscordException").
This exception and exceptions inherited from it are handled in a special way as they are caught and passed into a special event from [`Bot`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot"), [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error").
is there anyway to check why the error occurred? like Attribute error, user input...
alr
@slate swan awesome
How to make a table for one server? Sqlite3
#wrong-databases
wish there were like
What......
tables and subtables
im trying to convert a string to a discord member object. does anybody know how to do that?
Is that possibleew
why a table for each server lol
Hey, I just rebuilt my rootserver and tried using the pip3 install -U git+https://github.com/Rapptz/discord.py command,
however I am getting this error: ModuleNotFoundError: No module named '_ctypes'
Can someone help?
!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...
it does not let me use strings
use the place to get the member from, then name kwarg
wdym
developer mode off prob
@slate swan I want to make a table for one server only
it has to be a member object
it's better because ids can't change, names can
thats what im using
Hey, I just rebuilt my rootserver and tried using the pip3 install -U git+https://github.com/Rapptz/discord.py command,
however I am getting this error: ModuleNotFoundError: No module named '_ctypes'
Can someone help?
how
be-row no need spam
oh
did you try installing ctypes manually
ok so how do you get the id from a username
I'm not sure where you're getting the user#tag thing, but if it's a command param, you may be able to use a converter through a typehint
just use ID's in the first place, no need for a username
just turn on developer mode in settings
@slate swan I want to make a table for one server only
Otherwise, then yeah discord.utils.get
ok but all i need to know is how to convert a string to a discord.member datatype
😂
you can't convert a string to a discord.member
oh well
oh cool
get_member_named(name, /)```
Returns the first member found that matches the name provided.
The name can have an optional discriminator argument, e.g. “Jake#0001” or “Jake” will both do the lookup. However the former will give a more precise result. Note that the discriminator must have all 4 digits for this to work.
If a nickname is passed, then it is looked up via the nickname. Note however, that a nickname + discriminator combo will not lookup the nickname but rather the username + discriminator combo due to nickname + discriminator not being unique.
If no member is found, `None` is returned.
or discord.utils.get
always works
this is why u single n not marry one
!d discord.ext.commands.Bot.get_user
get_user(id, /)```
Returns a user with the given ID.
but the id would still be a string right
Yeh, it can't be found for some reason..
are you trying to get a user or member
thanks for the help
discord loves ids not so fan of nicks

so can you get an id from a username and discrim
i was first
yes but why would you need to do that
you can get the member using the username#discriminator, then member.id
but why would you ever need to do that

im making a on_message based kick command
why...
ik its stupid
an*
you should probably be using bot.command for that
lol u stilll can play with if
I am being
so basically
variable = get_user(id, /)
the variable would be a member object?
use id
@bot.command()
@commands.has_permissions(kick_member=True)
async def kick(ctx, id: int):
member = ctx.guild.get_member(id)
await member.kick()
await ctx.send(f'{ctx.author.mention} {member} was kicked from the server')```
its independed
6 lines
@slate swan prob shitty copy pasta not workin
Just tell them the answer
@indigo ledge , kick command
answe is 42
😔
@slate swan spoon him
what are you talking about
Jajajajajja i'm ded i cant
just make sure you have the right perms and bot = discord.ext.commands.Bot(command_prefix='!', intents=discord.Intents.all())
there is a reason im not doing that
Don't spoonfeed
I cant
why?
🥄
its complicatd
wtf does even mean
can't become more complicated than it already is
Don't just give people code
@quaint epoch feeding
okay okay
It doesn't help anyone learn
Imagine
variable = get_user(id, /)
the variable would be a member object?
thats all i want to know
bot.get_user*
big copy pasta
using the id for kick is meh since you can pass an id even using member: discord.Member
it would be a User object
You don't need the /
both ways work
get_user
i dont have 'bot' defined
like he imported bot enough
@indigo ledge if you except someone to help you, you have to give context and answers to what they are asking, and people who are helping here have probably more experience with d.py then the person asking the questions, so just listen to them.
you NEED to use a command to get a member_object, otherwise the user would have to insert the member AND guild
because i dont want anybody to steal it
do you use client?
@slate swan its russian code
lmao we won't
Then use the variable where you defined the bot/client
also don't name your variables like built-in functions

🤦
yes i do
you can't kick a user
obviously you can
so in on_message the person would have to pass the member and guild
i know
!d discord.User.kick
No documentation found for the requested symbol.
You can't. They don't have a guild associated with it.
but yk... Member objects do
we sure would steal a bricked code
😹
Yoo that code looks sick lemme just steal that even tho I already have that type of a command 😹 😹 😈
await member_object.kick(reason="because")
yes
A message object has a guild attribute
!d discord.Message.guild
The guild that the message belongs to, if applicable.
oh yeah i forgor
just use @client.command()
or whatever you defined as client/bot
@indigo ledge Look, no offense but your code is not interesting or complicated enough to steal
@mom.command()
all i need is for the program to convert part of the message to a member object
you dont even know that as i have not shared any
you'd have to splice the message, which is just annoying tbh
Type hint an arg to discord.Member
.split("")
async def commander(self, ctx):
.rsplit(" ")
what is rsplit
Doesn't matter. The point still stands
Tbh, just one of you is enough to help, stop mixing answers
alr, i'll go clean up my code someone else can help
if ctx.message.startsWith("mm"):
continue
Yes please, lets usr help for a while
its not hard
startsWith() doesn't exist
huh
i cant code am just a dreamer
@eager sorrel
Go ahead
w/ what?
i didnt, discord did lol
i mean i can make it just
await message.author.kick(reason="")
but all that does is kick the command user
okay first to make sure no one mobs to me to death
edgy commmand
what
thats what im doing
u kick the one try use command
Alright; I'll ping lemon, I'll ask hin about new server pfp, he'll say wrong channel but still give an answer, then I run the !rule 7 and !ot command on him
im getting approval first
huh
@indigo ledge just typehint an arg to disnake.Member and use that to kick the member
gn all
okay i won't
?
are you trying to kick with a username#discrimator, username, or id first?
Just right click on the member and kick them, all your problems solved

now that we're done here i gotta go back to my geo hw
username#0000
so steps are,
- splice message.content
- check if args are provided
- check if username is in format (username#discriminator)
- Try to get that member
- kick
can't help further because @final iron might ban me
how do i load cogs with a discord.Bot() (pycord)
Pycord 🗿
Thats not a thing anyways
basically my code for that part is
user = ("username#0000")
[line that converts the user variable to a member object which idk]
await user.kick(reason="")
Yes it does
don't name your member object user, its confusing
It isnt
basically
Yes it is
how?
Proof?
Look at documentation
in the code it isnt actually named user
member = ("username#0000")
member = message.guild.get_member_named(member)
await member.kick(reason="")```
thanks
thats just what i need
idk never used pycord and as far as I remember pycord doesnt have docs
it does

i found out already
If you didn't know why did you answer though
i know, i know
- it is, i said pycord
not even any checks for formatting
bruh
it does
Using on_message as a command 
Idk, whats happening to me anymore
scary, i know
A simple kick command should be only 2 lines
well, with checks and extra messages for fanciness, 15 max
Yea
mine is py @bot.command(aliases=('remove', 'kick_user', 'kick_member', 'remove_user', 'remove_member')) @commands.has_permissions(kick_members=True) async def kick(ctx, member_id: int, *, reason='None'): user = await bot.fetch_user(member_id) member = await ctx.guild.fetch_member(member_id) await member.kick(reason=reason) await ctx.send(f'''**{ctx.message.author.mention}** kicked **{member.mention}**: **{reason}**.''') try: await user.send(f'''{member.mention} you were kicked from **{ctx.guild}** by **{ctx.author}**: **{reason}**''') except (discord.HTTPException, discord.errors.HTTPException, discord.ext.commands.errors.CommandInvokeError, commands.CommandInvokeError, commands.CommandError, AttributeError, discord.Forbidden): print(f'Cannot direct message {str(member)}.')
it worked tysm
All he had to do is set an arg as discord.Member
hecc yea

except statement?
Everything in that is wrong
like -
import disnake
client = disnake.Client()
@client.command()
async def kick(ctx, member: disnake.Member, reason :str): pass```whats better

why are you fetching the user and member and making 2 request use a member param thats a member onj
to kick member and dm user
client doesnt have commands🐒
a regular discord client doesn't have commands, so why would that
youre expecting a Member obj
an id
Your bot will never send the message to the user since your kicking it before which means the bot doesn't have any servers in common with the member
bro attrs
Again just discord.Member as an arg
i could just make the member object as an arg, and get id's from that i know.
but i wanted to fetch it specifically, it feels good for some reason
member can be a member obj instance and just use all the attrs the member obj has?
making 2 request in a short time span? ha no
Yemz
no no no ash🏃
what's the request rate for the api, 60 in a minute or smth?
then what?
im not sure what the limit is but its probably short
10 rps
msg limit is 5/5s and remember that the discord api uses buckets so dynamic ratelimits
50 requests per second?
no
thats global
Imagine
read the whole description
It was 10 iirc
still why not use a Member class instance over making 2 request?

hey caeden
hello okimii
idk i just prefer fetching
Because we dont follow zen1 or 2, whatever it was
long time no see
Explicit is better than implicit.
It was 2
youre doing the same thing.
Caaaaeeedennnnnnn
youre just fetching a Member obj just use a class instance👁️ 👁️
perhaps
how you been?
Nvm all I get is a cheap reply back
Ash is so picky
Very
Sometimes
pretty good, been making some sick discord games except for the fact discord is shit on mobile
she likes the rich lovely replies
ASHHHHHLEYYYYYYYYYY
yup😔
HOWWW AREE YOUUOOUUOUOO
😭
how have you been?
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
ive been good
😔
Stop faking it 
im not 😩
!ot
i love you babes
@bot.command(aliases=('remove', 'kick_user', 'kick_member', 'remove_user', 'remove_member'))
@commands.has_permissions(kick_members=True)
async def kick(ctx, member: discord.Member, *, reason='None'):
user = await bot.fetch_user(member.id)
await member.kick(reason=reason)
await ctx.send(f'''**{ctx.message.author.mention}** kicked **{member.mention}**:
**{reason}**.''')
try:
await user.send(f'''{user.mention} you were kicked from **{ctx.guild}** by **{ctx.author}**:
**{reason}**''')
except (discord.HTTPException, discord.errors.HTTPException, discord.ext.commands.errors.CommandInvokeError,
commands.CommandInvokeError, commands.CommandError, AttributeError, discord.Forbidden):
print(f'Cannot direct message {str(member)}.')```there
i love you more no homo
oh typo
i love you full homo
no need to fetch the user
bro member has a .send method
!d discord.Member.send
await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.
To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.
To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
i know but what if it doesn't work after the member is kicked?
😩
try and except
just eat a forbidden exception
ashley come backkk
but then it will only kick and NOT give a formal message like You were kicked from {guild} you jackass wtf did you do?
it has to send that
send a msg and then kick like anybody would

but what if the send doesn't work, because user blocked dms from server
bro
read the exceptions
but if i send a message and kick doesn't work, then it just says You were kicked from {guild} you jackass wtf did you do? and NOT kick
too lazy
I'm trying to help you in the long run why not accept my help?
(dodges every possible solution to simple problem)
Inneeds
Sleepu
because i'll have to push code to github and i don't wanna
go to sleep ash
better push that code or you about to get bullied by devs or the api
ashley might i remind you that it is 8:38pm
i have my year 10 exams after this half term and i keep procasting studying
lol
Ive bevn up fom. 9 fays, Im gonnsm make it 10 in 3 houts
i do this 6 times a day can i please have a break

the typos fixed, the variable naming, permissions fixing....
work hard
or they're too easy for you
im not sure if thats very true isnt a persons max to not sleep like 5 days
What, huh how you're in year 10th?
?
Idkkkm u
because he is?
nvn, cya i gtg now
bye
im in your year babes
oh lol
nvm 😳
he probably was born in January

probably keep this to discord talk 
u born in jan? damn
ye
!rule 7 good luck for gcses next year@manic wing
7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.
I have to wait 5 months till my bday lol
year 9 I take exams to see if I move up to y10
which will be easy, looking at the curriculum now
I'll stop talking
lets go back on topic
how to make discord bot
which libs do y'all use here?
this is discord bots....why....why ping you in off-topic
disnake 100% no need to ask other people
uhh...discord & disnake
why ask in dpy channel then 
pycord disnake
lol I thought there'd be a bit more diversity here 
chat used to be very active
until most people decided to break off
Disnake, completely a bias
same, I'm a disnake maintainer
some here use hikari
Damnn
we are all not biased 😄
||and I am not being fucked up by HTML rn||
we all know that
someone links me to discord time formats
I didnt .-.
neither
!d discord.utils.format_dt
discord.utils.format_dt(dt, /, style=None)```
A helper function to format a [`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "(in Python v3.9)") for presentation within Discord.
This allows for a locale-independent way of presenting data using Discord specific Markdown...
oh i forgot this in 2.0
btw how to make discord bot 💀
imagine
copypaste
ok 
noo
too late now
Arl is a pretty cool person shes very knowledgeable in her stuff as well
i remember a guide but i forgot the link for it
nah im just joking
A collection of tips for discord.py to help make better, more efficient bots.
@slate swan you looking for this?
First make the necessary imports
import pycord as disnake
import disnake as discord
import discord as nextcord
import nextcord as pycord
lmao i wanted to link it for you
👁️ 👁️
just realized you're joking
yessir
xD

🗿
that reminds me
Then run, pip install hikari rin lefi lightbulb in your terminal
microsoft really decided to make teams notifs really good looking for windows
Ash follows pep9 🗿
lol
Okay I"m out idk wgat is im saying anymoire
youre sleep drunk
then initialize variables
bot = commands.Bot(command_prefix = '!')
client = bot
testing = client
client2 = client
bot_event = client2
test_bot = commands.Bot(command_prefix = ',')
Gn me hgonna passuout
I remember I was so sleepy I forgot to call a function
I was confused why it showed [No Output]
👁️ 👁️

Gn
passuout
@slate swan
i can make any package any other package
Then upload t to github and make it open ccoturce
go to sleep
and advertise it
make it popular
the best.
trending on github
Lmao whattt
:3
I remember being confused why -2^2 gave me -4
Rip my rbain cant handle that mch
at first I thought my calc was breaking
magic
Exponents?
no
Idk wgat im shayoinng
what
any negative number squared is a positive
it's not square
!e print((-2)^2)
@manic wing :white_check_mark: Your eval job has completed with return code 0.
-4
Yeah meths
wait whats the ^
it's ** you mean
lol
oh im thinking of **
!e 2**2
@velvet tinsel :warning: Your eval job has completed with return code 0.
[No output]
^ is normally **
shit forgot to print
What.......
!e print(2**2)
@buoyant quail :white_check_mark: Your eval job has completed with return code 0.
4
its what?
!e print(2**2)
@velvet tinsel :white_check_mark: Your eval job has completed with return code 0.
4
!e print(2^2)
@slate swan :white_check_mark: Your eval job has completed with return code 0.
0
¯_(ツ)_/¯
any negative number squared is a positive number
however it needs a FUCKING BRACKET
(-2)^2 works fine on a calc, but shit gets real when you do -2^2
gives you -4
I forgot why it does that
squared
not according to the calculator
!rule 7
7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.
i hate this pep8 phase
math class
?
everyone waffling on about pep8
shit
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
now I want to rant about SCP in ot now
don't be nerd :p
instead of focusing of "making your code look good" why dont you make your code efficient
!rule 7 rip if cooldown
7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.

good point there
@bot.event
async def on_message(message):
if message.author.id == 940652261141516370:
if message.content.startswith('$hello'):
await message.channel.send('hello')
this doesnt work why is that?
Lmao
Because it is not supposed to work, welcome
use commands pls
wdym commands?
!d discord.ext.commands.Command
class discord.ext.commands.Command(*args, **kwargs)```
A class that implements the protocol for a bot text command.
These are not created manually, instead they are created via the decorator or functional interface.
These commands
i don't know where these people watch at some tutorial because they all come here with this and be like it doesn't work 
Totally me 4 years ago
how do i convert a unix timestamp or whatever that's called to something like "2 Hours, xx minutes"
eh.. it's dpy example
totally me ~1,5 years ago when i started with dpy
What version docs are you looking at?
finished spewing shit in ot now I'm back
lightmode, ew
imagines the 12 year old me making a discord bot like a pro without any knowledge of OOP
Ah stable
hah
damn that sucks
Well what you’re seeing there is the pre-rewrite and is heavily outdated
I started with the basics :/ all I had was a book
I didn't even know what f-strings were
i don't use it, i tell where users get it
Alright
now the only thing that changed is your age
I started with free stuffs when I was 10 lol
Oh the other person just left lmao
1.x will cease working whatsoever may 1st.
my mom really wanted me to start coding
And physically, Im mentally a utopian-pampered-three-year-old
mentally speaking i'm 2k year old maybe
doubtful
mentally speaking I'm a bit confused
Please ^^^^^^^^^^^^
ashley when are you gonna fucking sleep
mods dont ban me
Tbh, its hard to guess the age of most of the people here
Idk really, I just feel like smashing my head somewhere now
ping?? mods
oop
bruh
smashing your head causes severe damage to the skull and brain
I would not recommend that
really depends on the force that you smash your head against
and the object
Rusted iron slab
I would recommend weak smashing against soft carpet
be careful, I recommend weak smashing there
if there's a pillow nearby do it as hard as you like
!rule 7 there's no point mina will birbo stabbo you
7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.

damn
guys i still didn't solved my problem with time 
please don't birbo stabbo me please 😦
damn
Fix it tomorrow
the tomorrow
🗿
which problem?
my problem
🗿
Okay bye goodnight
good night uw||definitely not u||
someone, some day
I'll let that pass and pretend not seeing that cringey stuff, take care, good nighto
🗿 👍
some year
If that's cringy, then I don't know what to think of your activity in the English server
Lets not talk about that

oh yeah, i had another question which i forgor, for how long in time the on_message_edit works, like if a message from a year ago will still be catched? 
cached*
just an extra t ok
Doesn't look like that's a limitation. according to Discord docs
totally aliv
disnake.on_message_edit(before, after)```
Called when a [`Message`](https://docs.disnake.dev/en/latest/api.html#disnake.Message "disnake.Message") receives an update event. If the message is not found in the internal message cache, then these events will not be called. Messages might not be in cache if the message is too old or the client is participating in high traffic guilds.
If this occurs increase the [`max_messages`](https://docs.disnake.dev/en/latest/api.html#disnake.Client "disnake.Client") parameter or use the [`on_raw_message_edit()`](https://docs.disnake.dev/en/latest/api.html#disnake.on_raw_message_edit "disnake.on_raw_message_edit") event instead.
The following non-exhaustive cases trigger this event...
that sucksss
@hoary cargo on_raw_message_edit
You will have to parse the data though, somehow, for which you can look at the structure here https://discord.com/developers/docs/resources/channel#message-object-message-structure
it works so:
but i recommend you remove lots of useless variables you use
useless like ?
like everythin. you can do it in 2 lines:
final_date = (member.created_at - datetime.timedelta(14)).replace(tzinfo=None)
current_date = datetime.datetime.now()
well, indeed, i could do that but i don't like to be a oneliner
not from a perspective of code readability
so basically i needed just one line to make it work
i googled it tho but i ended up installing pytz and do nothing
xd
so basically as long as the bot stays online it will be able to get the edited message
i mean it makes sense
Could you get the message probably, could you edit the message or do anything? Most likely not if discord discarded the message
you can make the cache larger
pass max_messages to discord.Client when creating your client/bot object
Not discord bot, but slack bot question. Hoping someone might had have experience building something similar
I'm trying to ping a user. I have the below code that sends a message to a channel:
client.chat_postMessage(channel=channel_id, text=user_message)
I have looked at slacks documentation page:
https://api.slack.com/methods/chat.postMessage
https://api.slack.com/methods/chat.postMessage/test
I tried username and link_names, but they dont seem to ping or mention the user.
Anyone have some good disnake example code?
There are examples in the repo
Actually figured it out.
Cloning https://github.com/Rapptz/discord.py to c:\users\nikit\appdata\local\temp\pip-req-build-u6a3_nc9
Running command git clone -q https://github.com/Rapptz/discord.py 'C:\Users\nikit\AppData\Local\Temp\pip-req-build-u6a3_nc9'
ERROR: Error [WinError 2] The system cannot find the file specified while executing command git clone -q https://github.com/Rapptz/discord.py 'C:\Users\nikit\AppDat
a\Local\Temp\pip-req-build-u6a3_nc9'
ERROR: Cannot find command 'git' - do you have 'git' installed and in your PATH?
```how do i install this
how do i install git
so i've had an issue with people spamming my bot and crashing it, i'm wondering if there's a way to cancel a command if it takes too long?
what kind of a command is it?
a text command
just like
what it does is
Input:
=foo [arguments and stuff]
Output:
an image
looking at this i finally see my other problem 🗿 the ifs are wrong and i should add 14 days to the account instead of taking them
Your bot can get rate limited if it makes too many API requests subsequently prolly
that's not what i mean
read this
yeah
add a cooldown
no not a cooldown
is the image generation async?
yeah
you could probably set up a task that stops executing commands if they take too long. But I am not sure how you would do that
That has nothing to do with it though
thats literally exactly what i said
How are you generating the image?
this isn't relevant
With an api or run_in_executor?
image geneeration not being async is a big problem
It actually is relevant
it's async yeah
so it doesnt matter if it relates or not
it's just with numpy and pil and shit like that
i've not messed with a lot of the code in a while
Yes but that wasn’t really related to the question. All good though
this is all i was asking for in the first place
@bot.event
async def on_message(message):
role = message.guild.get_role(921806885831716875)
if message.guild.id != 692305542324027424:
return
if message.author.bot:
return
with open("banwords.json") as f:
banwords = json.load(f)
with open("banwords.json", "w") as f:
json.dump(banwords , f)
if {i.lower().translate(str.maketrans('','', string.punctuation)) for i in message.content.split(' ')}\
.intersection(set(json.load(open('banwords.json')))) != set():
print('1')
name = 'server'
base.execute("""CREATE TABLE IF NOT EXISTS {}(userid INT, count INT)""".format(name))
base.commit()
warning = cursor.execute('SELECT * FROM {} WHERE userid == ?'.format(name),(message.author.id,)).fetchone()
if warning == None:
cursor.execute('INSERT INTO {} VALUES(?, ?)'.format(name),(message.author.id,1))
base.commit()
await message.channel.send(f'1 предупреждение\n{message.author.mention} по губам отшлепать?')
elif warning[1] == 1:
cursor.execute('UPDATE {} SET count == ? WHERE userid == ?'.format(name),(2,message.author.id))
base.commit()
await message.channel.send(f'2 предупреждение\n{message.author.mention} по губам отшлепать?')
elif warning[1] == 2:
cursor.execute('UPDATE {} SET count == ? WHERE userid == ?'.format(name),(3,message.author.id))
base.commit()
await message.channel.send(f' 3 предупреждение.\n{message.author.mention} по губам отшлепать?')
cursor.execute('UPDATE {} SET count == ? WHERE userid == ?'.format(name),(message.author.id,0)) # Меняет значение переменной
base.commit()
banwords.json
{
"banwords": ["тупой", "дуб"]
}
woah
gives warnas to everyone for different words, although it should be from the list ...
SQL doesn’t have ==. = is for assignment and equality
A okay, sorry
and don’t format. .format is essentially the same as f strings
i condemn you to forever break pep8 for this.
How
SQLite uses ? for placeholders, and I’m assuming you are using SQLite @slate swan ?
Yes
it still says error
a\Local\Temp\pip-req-build-ryin60d6'
ERROR: Cannot find command 'git' - do you have 'git' installed and in your PATH?
🗿
🗿 because i should've add time not subtract it
🗿
Wait I'm dumb
You don't even need to subtract them
idk)
You can just use a discord timestamp
How do you escape the code block again?
With the eval command
I need to use markdown
дуб.. за что дерево то запрещать?
Это пример
!rule 4
