#discord-bots
1 messages Β· Page 732 of 1

Alr. What should I do now?
if its related to this channel sure
im learning py, like basics
Let me test it
this gets him ratelimited, he knows, right?
I don't think he knows tbh
welp
there's not even a loop break or anything π€·ββοΈ
Did I get bamboozled? What should I do about ratelimit
π
don't run now, you'll tell him
oh no i wontπ π¨
and you're very slowly getting ratelimited
Ratelimit is when you reach 75 request per minute right?
different for every event / request
some requests can for example be only made every 10 mins etc
just don't count, that's useless asf
I want too tho..
I'd say maybe every 30 secs, edit the message
but have a limit of like 10
so it'll only count till 10
Message sending ratelimit is 5/5s
Global ratelimit is 50/1s
As of speaking right now at least
well, and counting that shit will make it very close to that limit
think about 10 users using that command at the same time
boom, ratelimited in no-time
fix= use a cooldown on certain commands etc
This bot is literally useless. It's the only command and it will only be counting in a channel
Just for the sake of it
best thing you could do, is something like this
..
Message edits are also 5/5s
<t:1624385691:F>
which makes it even worse for him
<t:1624385691:t>
<t:1624385691:T>
<t:1624385691:d>
<t:1624385691:D>
<t:1624385691:f>
<t:1624385691:F>
<t:1624385691:R>
choose and win
What's happening?
nothing, those are just ways of displaying certain times
Either way, so as long as you don't go above 50 requests a second discord.py will handle the ratelimit buckets
If a bucket is depleted it will wait until it is filled back up
Cool thing is... That's my birthday
so five requests per 5 seconds?
I knew that ofc, based on your IP and current location, I was able to track where you lived, the rest was simple
what does that mean? a request a second?
Lmao
Yes
ah ic
..
Ratelimits are a bit different in discord though it's just just a straight 5/5s
Because you also have ratelimit buckets
E.g if I send a message in a diff channel it will have a different bucket
If it werent for buckets the bot would be limited to sending messages in one channel at a time if it's a lot of messages
Well logically it's the most sense thing to implment
Otherwise you'd be bottlenecking
for sure, would suck if one loser spammed the bot in 1 guild and ALL the other guilds suffer from it
yeah
anyways, if you put cooldowns on that, that won't even happen
it would just be a problem if your bot became big
No not really
It's more lenient
Bigger bots have different ratelimits
They get allowed more requests
I personally just use bots to make stuff easily accessible for my phone as well as my PC by using API's
I'm not using them for public purposes. But it's always handy to know the possibilities
- public transport schedules
- twitch streamer schedules
- ebay~ish notify tool the second a new item is listed with given query and specifications
- automating daily tasks and monitoring them, ...
no idts
it can work for only one person
but it won't work in grp DM's
because you can't invite bots in grp dms
yes
by using a global check
global check in the dpy docs will tell you
you can make the bot notify users in a guild (when they try to use a command) that it can only be used in DM's tho
lots of options
thats cool
kinda gave me ideas ngl thank you
I just searched for a notifying system that could be used for my PC and mobile phone.
whatsapp and fb etc weren't option, then I stumbled upon discord and here we are, a few yrs later
I wanted to make it public, but found that discord isn't really user-friendly for users with no coding background: commands etc are a no-go.
but nowadays with the buttons, select options and slash commands (which basically can't be more clear), I might give it another shot someday
by select options you ment dropdown menus?
mhm, I mainly want to use them to give users roles and to go to a specific section in a help menu (the arrow buttons βοΈ could help me with that too tho )
They are called select menus
wut
Idk why there are so many names for it
i thought they were called that
But on the official discord docs its select menu
I'm staying on dpy v1.7.3 for now, and I don't go indept in any other fork or version or whatever
I mean , even in discord.py it's discord.ui.Select
Would be better for SelectMenu
called them dropdown cuz in disnake examples its called drop down
dropdown reminds me of HTML
just integrate what discord calls them (in their API), can't be too hard...
examples/views/select/dropdown.py line 10
class Dropdown(disnake.ui.Select):```
ikr
Select π€¦ββοΈ SelectMenu π§
buttons > reactions
stay mad
then you haven't seen a decent implementation
I have :) , and I use it too
bruh
Yea, until discord makes the ratelimits for reaction add sky high
can't wait for the fun to begin, especially the message intents
Discord 2022 , now you cannot acess what emoji the user reacted with
I mean, discord seems to be publiclly trying to eliminate bots imo Β―_(γ)_/Β―
I don't want to interupt the discussion that is going on here, but I have a question loosely related to bots.
I'm currently in the process of learning python (I'm using the Python Crash Course 2nd edition by Eric Matthes [currently on chapter 5]). The first few 'large' projects I want to build are discord bots. I'm not looking for any help with code at the moment, but more pathway wise. Should I be looking into the processes of coding a bot while still being such a beginner?
For reference, I really only know the basic basics of writing anything. Only having mild experience with for loops and going somewhat in depth with print, lists, and variables.
Imagine emojis as a privelaged intent
i like your style
Naw, imagine connecting to the gateway as a privileged intent
The next step would be researching async programming and OOP, since discord.py uses it
imagine making api calls a privileged intent
well , if you know some basic object oriented programming , aware of python syntax
Asynchronous programming and blocking/not blocking methods. you're good to go!
Thanks I assume π
that's useless, the bot won't work without it
thats the point
^
a complete beginner should not jump into discord.py, you need to know basic python, have a basic understanding of asynchronous programming, and a basic understanding of Object Oriented Programming.
Python is actually my first real experience with programming, I've dabbled a bit with HTML and CSS, but I wouldn't consider that to be on the same level.
So basically , request discord for permissions whenever you make a bot
I remember the good old days when bots didn't exist and you had to use a user account via email and password, not even token
listen, if you want to start with libs that change often, don't follow YT tutorials about those subjects
they will maybe give you a grasp of what you can do, but they will affect your coding style by making you implement methods that mostly aren't good or are only for one purpose.
Not really, you can make a REST only bot
wow your old
Wow
Imagine using that these days
Do you have any resources you would recommend once I'm through learning the basics I'm working with now?
that's v1, no?
always go to discord servers of the libs you're learning, they can help out a LOT, but make sure you talk to the right people, beginners can help out beginners and lead you the wrong way
make sure this gets confirmed by some (helpers/mods/...)
Awesome, I appreciate all the insight you guys have given!
you don't want to implement a method that just works, you want to do it good on the first try
temporarily fixing something stinks
A tutorial on how to use discord.py to create your own Discord bot in Python, written to fix the flaws of many other popular tutorials.
Good tutorial written by a competent coder
Which can just send requests to Discord but not receive data right?
!pep8 this can help a bit with your coding style
PEP 8 is the official style guide for Python. It includes comprehensive guidelines for code formatting, variable naming, and making your code easy to read. Professional Python developers are usually required to follow the guidelines, and will often use code-linters like flake8 to verify that the code they're writing complies with the style guide.
More information:
β’ PEP 8 document
β’ Our PEP 8 song! :notes:
I did have someone recommend code wars to me, but the site seems more geared toward someone at a little bit of a higher level than I'm at right now.
make sure your project has a purpose tho, you don't want to blindly work on something.
we get bored quickly
Depends on the endpoint, most return data anyways. Of the top of my head you won't get live messages, presences and guild chunking
You also won't be able to set your client's connection state
E.g being "connected"
As that's only on the gateway
My main field of interest is infosec, so I'd be looking to make it have some features semi related to the field, stuff like whois, tracert, etc.
A virustotal command maybe?
Of course I'll try to have some 'fun' features, but it's not the main focus, but moreso to learn.
Oooh that's not a bad idea.
if you know basic python, and you know how to read documentation, you're on a good path
https://developers.virustotal.com/reference/overview They have a RESTful API as well
he doesn't know how to use API's via python tho I think
Maybe a command that translates shortened URLs too
mhm, that's like 2 lines of code
(I don't know most things about python yet)
if you know what you're looking for, you'll get helpful answers
questions like "I need help with my code" or "it's not working" are trash
"doesn't work" is equally as bad
When you get to requests just make sure to use an async library for requests, E.g aiohttp httpx's AsyncClient
that's the async part of dpy π
Right, I've always been one to try to find why something isn't working, and then search for help if I'm not sure of the solution.
yeah, but fatigue makes you blind sometimes, ngl
I'm still learning at the moment, so my code is pretty messy. My most recent lab was to make two lists, then append them a few times, then do a for loop to print a message about the items in the lists.
don't waste too much time on simple errors, especially if you're a beginner, ask for help as much as possible
There was a bit of slice work thrown in too. I feel like I'm moving at a snails pace, but I am definitely enjoying myself so far.
I appreciate that!
I've learned some coding through https://www.edabit.com/ but nowadays, they ask for fucking Pro memberships etc
Codecademy used to be really useful too from what I've heard, but now all of their good stuff is locked behind a paywall too.
simple examples mostly have a "test" at the bottom
a small exercise on that subject
nvm, I'm talking about w3schools
I'm not opposed to getting courses on Udemy, but it's a bit sketchy for me to spend money on a course without having some preview or something to know if it's worth the purchase.
Code Academy is totally unbearable for me
I just read project source codes on github and the documentation on python
A lil stackoverflow here and there hasn't killed anyone yet, but that's a last resort for me
i mostly learned by annoying andy
I feel that, I have a friend in my main server that is really familiar with python and I make him help me out when I'm struggling with something.
also, I highly suggest you to learn shortcuts (in the IDE), they're lifesavers if you can make them muscle memory
thats a good way to learn aswell but he needs ofc when he shows you stuff proof on why to back his claims
vsc is my gf
Bloated
I'm using pycharm with a couple of custom keybindings for run and new file, but I haven't explored many other IDEs
you exit by turning off the pc
oh
No just go into command and type q
Why can't you get a real gf π
Not that hard lmao
should i stop using discord.py
no need
and just move on to pycord
disnake
is it better than pycord?
yes
ok ill look into it
Pycord is prob the worst fork out there
you gotta do like 50commands to shutdown your pc mr linux man?
No
pycharm is great! make sure to know about what a venv is in that case
I just type poweroff in the terminal π€
i just press shutdown
nah, it's just common for starters that use VIM as a texteditor to not find how to exit
I can also do that
I've seen mention of it on startup everytime, and know what it means, but don't exactly know what it does and why it's important.
π
it's a virtual environment, you can learn more about it later on
does disnake use slash commands : (
but i can still make classic commands?
Yes
yes why wouldnt you?
π
No??
it's default, mhm
I just use anacondaπΆββοΈ
first thing devs come crying about "module not found"
I like portable projects, always have
I can't stand it if I were to see errors on a different OS
Another general question, what's the general opinion on "Automate the Boring Stuff". I saw that it's published for free online and I was considering adding it to my list.
it is, yeah
It's just a general educational book. It's published free on a website with the same name
hmm, you don't have to read books per se
I rather like exercises
That's true too, but since I'm just starting out I really don't know enough to do many exercises in a productive way
Finally, it works
well, you'll have to find some kind of website to generate exercises for you
I used edabit, but you'll stumble upon a paywall one day, it's a great starter tho
Yeah, I was looking at codewars, but they were a bit more advanced than I am at the beginner level.
you can select which difficulty of exercise you want etc
Try out advent of code
You can do all solutions in python
I'll look into edabit real quick, and advent if I'm able.
don't forget to unsubscribe from the email list, those always sucked
Anyone have any idea why discord returns member as None in their Message Reaction Remove gateway? (on_raw_message_remove event)
Member is only given on reaction_add
I am aware, I'm asking on more a technical reason
I don't think it's a discord.py thing rather a discord gateway thing
They just don't send out that data
Do they have a reason listed why anywhere or do they just do what they want without giving a reason?
I don't see it listed anywhere in the docs
get_or_fetch_member is a pretty nice disnake feature imo
I'd assume it's like delete message, discord will send out a partial message object
There is no apparent reason? At least not publically
But partial models in itself omit certain data
how to change server avatar of bot to imitate initiator of cmd?
!d discord.ClientUser.edit
await edit(*, username=..., avatar=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the current profile of the client.
Note
To upload an avatar, a [bytes-like object](https://docs.python.org/3/glossary.html#term-bytes-like-object "(in Python v3.9)") must be passed in that represents the image being uploaded. If this is done through a file then the file must be opened via `open('some_filename', 'rb')` and the [bytes-like object](https://docs.python.org/3/glossary.html#term-bytes-like-object "(in Python v3.9)") is given through the use of `fp.read()`.
The only image formats supported for uploading is JPEG and PNG.
Changed in version 2.0: The edit is no longer in-place, instead the newly edited client user is returned.
you cant edit server avatars yet, you can only edit your global one
how would i go about using a link as the argument for the avatar?
rather how would i get a users avatar first?
!d discord.Member.avatar
property avatar```
Equivalent to [`User.avatar`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.avatar "discord.User.avatar")
!d discord.Asset.url
property url: str```
Returns the underlying URL of the asset.
(:
you dont
it only takes a bytes-like object
not a string/URL
Make a request using aiohttp or any other async http library to the avatar url. Then use .read() on the response to get the bytes
could you write out how we make a request?(sry very new TwT)
!d discord.Asset.read no need
await read()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves the content of this asset as a [`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes "(in Python v3.9)") object.
Does the same thing internally anyhow
yes
so i would use
await edit(*, username=..., avatar=ctx.author.avatar.read)
yes?
!d discord.Member
class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").
This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User").
x == y Checks if two members are equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") instances too.
x != y Checks if two members are not equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") instances too.
hash(x) Returns the memberβs hash.
str(x) Returns the memberβs name with the discriminator.
no
but yes
you use that method on your bot instance
it from from the ClientUser class
use the edit method on your discord.ClientUser instance
sorry i didnt get that could you rephrase my syntax how its intended to be used?
It's not an attribute it's a method
you use the edit method on your discord.ClientUser instance https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.user
so bot.edit ye?
property user: Optional[discord.user.ClientUser]```
Represents the connected client. `None` if not logged in.
if any(word in msg for word in char1):
embed = discord.Embed(title="Ganyu Build")
embed.add_field(name=" ", value="https://media.discordapp.net/attachments/879736909969113178/928855398520328192/Character_Ganyu.jpg?width=1025&height=683", inline=(False)
await message.channel.send(embed=embed)
``` How is this giving me an invalid syntax error at the `await` line
inline=(False)??
Oh that was bc I had it as (True/False) as an example for a friend
Thats causing the error
if any(word in msg for word in char1):
embed = discord.Embed(title="Ganyu Build")
embed.add_field(name=" ", value="https://media.discordapp.net/attachments/879736909969113178/928855398520328192/Character_Ganyu.jpg?width=1025&height=683", inline=False
await message.channel.send(embed=embed)```
Yea, you didn't fix it
You still need to close the add_field call, your missing one paraenthesis now
Yeah I saw
Before you had an extra one
Ty
- you cant have an empty field name
- if you wanna add an image to the embed, use set_image
set_image?
!d discord.Embed.set_image
set_image(*, url)```
Sets the image for the embed content.
This function returns the class instance to allow for fluent-style chaining.
Changed in version 1.4: Passing [`Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty") removes the image.
url is a kwarg and yes
how to add role on_message
no idea
TypeError: set_image() takes 1 positional argument but 2 were given
embed.set_image("https://media.discordapp.net/attachments/879736909969113178/928855398520328192/Character_Ganyu.jpg?width=1025&height=683")

anyone to help me with help command description ?
url=...
embeds and title is done by me I need help with description
Ohh makes more sense
description=... when creating the Embed
but the thing is I wanna write the commands and work like below each other but it is coming in one line
see this @valid perch
how can pls say me?
!e ```py
print("foo\nbar")
@pliant gulch :white_check_mark: Your eval job has completed with return code 0.
001 | foo
002 | bar
You just put the newline char into the string
!d discord.ext.commands.Command.description
The message prefixed into the default help command.
thnx its working
url is a kwarg
@cerulean osprey
?
you made it into a positional argument when I said its a keyword argument ok
they means its a key word argument , u need to do argument_name= value . not just value
Yeah I fixed it already lol
epic
how do you end something
so like if there is a certain condition that is completed and you want to stop the command
It happens
Help
yes?
hey
@slash.slash(name="test")
async def test(ctx:SlashContext,member:discord.Member):
await ctx.guild.kick(member)
await ctx.send("Kicked")```
TypeError: test() missing 1 required positional argument: 'member'```
i am getting this error
what library do you use?
is pycord help available here?
couldnt quite get this working can someone help?
i mean yeah its a dpy fork but i dont see allot of pycord users here
Hi sir, kindly want to ask how to combine multiple dictionary in 1 variable
X = {"x" : 1} {"y": 2}
To
Y = {"x": 1, "y":2}
!ot
Off-topic channel: #ot2-never-nesterβs-nightmare
Please read our off-topic etiquette before participating in conversations.
i putted my phone on charge but forgetted to turn the switch on for 5 hours
ooof π€£ i am not kidding
ot aswell
It's not really a bot related question, should take a look at #βο½how-to-get-help
So can u tell me how to like set permissions restrict...
Like we use to do...
@bot.command()
@commands.has_permission...
How to do it now?
Now?
@commands.has_permissions(administrator=True)
example
How is it related to Python? An off topic channel is more appropriate.
Well it's more of a general talk, so, uhhh
#python-discussion is about Python, see the channel topic.
We don't need to import from discord.ext import commands...
so that is weird
This is the randomly counting bot. The top one starts from 0 but I want the second command to start from a certain number. How do I do so?
its a decorator what?
Hi Everyone,
I am not getting any error in the terminal and if a error happens it skips it.
Thank you in advance
Yeah
Use n instead of int
bcs int is a keyword
@bot.command()
async def hmm(ctx,n):
a = n
while True:
await ctx.send(a)
a += 1
await asyncio.sleep(5.0)
Good?
Yeah
What is a?
A is just a number
Yes but it doesnt work
A guide for how to ask good questions in our community.
i did
parameters*
It will ALWAYS be a string
what is the unload counterpart of setup() in dpy extensions?
ik
to unload a cog?
orrrrr wdym
no, generally function naming scheme
ah well im not sure
There's none
like, every dpy ext has setup()
!d discord.ext.commands.Bot.unload_extension u gotta use this
unload_extension(name, *, package=None)```
Unloads an extension.
When the extension is unloaded, all commands, listeners, and cogs are removed from the bot and the module is un-imported.
The extension can provide an optional global function, `teardown`, to do miscellaneous clean-up if necessary. This function takes a single parameter, the `bot`, similar to `setup` from [`load_extension()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.load_extension "discord.ext.commands.Bot.load_extension").
yeah but thats a global function to add a cog isnt it?
yes i am aware of it
add a cog != load a cog
Yea
Huh?
what will happen if one tries to load a dpy ext when it doesnt have setup()
it will not find it
noted
you need to add the cog
i am trying to nick bot to the same name as whoever used the command
await discord.ClientUser.edit(nick=str(ctx.author))
but this gives me
await discord.ClientUser.edit(nick=str(ctx.author))
TypeError: ClientUser.edit() got an unexpected keyword argument 'nick'
can someone help?
bot dont have nickname
only username
or something
oh
πΆ
discord.ClientUser represents an object. So use on your object of this instance.
all yours brotherπΆ
im attempting to do weird stuff
Haha
like what
await discord.ClientUser.edit(username=str(ctx.author))
TypeError: ClientUser.edit() missing 1 required positional argument: 'self'
replacing with username i get this error
import dpy extension from installed module
Again, you need to use on your object. Not on the class.
my object would be? bot.ClientUser?
!d discord.ext.commands.Bot.user
property user: Optional[discord.user.ClientUser]```
Represents the connected client. `None` if not logged in.
And you have a discord.ext.commands.Bot object that is likely named bot, or client. Just like when you create commands.
So simply bot.user or client.user
assume you installed a module called meow in your python
you want to load an dpy ext from a python file which is inside meow
something like that
My Bot object is named HunAI
well you load the cog?
yep
You can't load cogs within installed libraries/packages.
so i did it with weird way
how can i read a user's nick?
yeah it would be missing allot of stuff
!d discord.Member.nick
The guild specific nickname of the user.
bot can have nick?
^
huh.
Well yes, why not?
member.nick ( it can be None) , member.display_name shows nickname and if its not found it shows the username
Bots are also member of guilds.
can i use ctx.author for member?
ooo
Koi py sika do
The guild specific nickname of the user.
name it waffleπ
4. Use English to the best of your ability. Be polite if someone speaks English imperfectly.
cant bot change its own nick on the server even if it has perms?
property me: discord.member.Member```
Similar to [`Client.user`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client.user "discord.Client.user") except an instance of [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member"). This is essentially used to get the member version of yourself.
Yes a bot can change its own nickname if it has permissions, just like you can change yours.
and use .edit(nick=)
oh-
Hi is there any code to untimeout someone?
just set one of the kwargs as none lol
says guild is not defined ;-;
!d disnake.Member.timeout
await timeout(*, duration=..., until=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Times out the member from the guild; until then, the member will not be able to interact with the guild.
Exactly one of `duration` or `until` must be provided. To remove a timeout, set one of the parameters to `None`.
You must have the [`Permissions.moderate_members`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.moderate_members "disnake.Permissions.moderate_members") permission to do this.
New in version 2.3.
To remove a timeout, set one of the parameters to None.
ohk thx
yw
It's always the object and then the attribute. If it's discord.Guild the object and me the attribute, then it's most likely guild.me.
You haven't defined it then :shrug:
Without code we can't help either way.
bot = commands.Bot(command_prefix='?')
@bot.event
async def on_message(ctx):
if ctx.author==bot.user:
return
print(ctx.content)
if 'media.discordapp.net' in ctx.content:
await guild.me.edit(nick=(ctx.author.display_name))
await ctx.channel.send(ctx.content.replace('media.discordapp.net','cdn.discordapp.com'))
use something like ctx.guild or any object u have with a guild property
this is what im working with so far
on_message takes a message argument, not ctx
on message does not take context ( ik it works but bad naming convention)
ah yes should fix tht
So it's message.guild.me.edit(...)
hey Florian

!d discord.Message.guild # Since you can see a message object has a guild attribute
The guild that the message belongs to, if applicable.
heyyyyyyyy
It's however None in private messages, since the message doesn't belong to a guild.
@slate swan im talking to youπ 
await msg.guild.me.edit(nick=(msg.author.display_name))
File "C:\Program Files\Python310\lib\site-packages\nextcord\member.py", line 795, in edit
raise TypeError(
TypeError: Timeout must be a `datetime.datetime` or `datetime.timedelta`not _MissingSentinel
that broke
π₯²
(replaced ctx with msg in my code)
no lol
You need to set the kwarg value to None.
the what?
pls show example TwT
I'd recommend to learn Python a little bit more though.
Your knowledge seems very limited ^^
and only one
is a lot more limited than it seems i assure you
or
one of the two but only one
!resources might help
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
As I said, x or y as parameter.
BUT YOU CAN ONLY USE ONE OF THEM
So for you, x or y can be 2?
you can use x and y but not at the same time
comprende
For me if you need to choose between x or y, you only choose one :)
and ( not (==x and ==y))
that way it should also not satisfy both
!d disnake.Member.timeout
await timeout(*, duration=..., until=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Times out the member from the guild; until then, the member will not be able to interact with the guild.
Exactly one of `duration` or `until` must be provided. To remove a timeout, set one of the parameters to `None`.
You must have the [`Permissions.moderate_members`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.moderate_members "disnake.Permissions.moderate_members") permission to do this.
New in version 2.3.
from discord import Client, Intents, Embed
from discord_slash import SlashCommand, SlashContext
import interactions
import discord
bot = Client(intents=Intents.default())
slash = SlashCommand(bot)
who meπ§ββοΈ
I said
duration=Noneoruntil=Noneas parameter.
Not and
yes but exactly one can be used not both
And that's why the "or" is here...
@slash.slash(name="test")
async def test(ctx:SlashContext,member:discord.Member):
await ctx.guild.kick(member)
await ctx.send("Kicked")```
yeah but im just clarifying smh
If you need to choose between 2 or 4 you can't choose 2 and 4

``py
i pick or
Doesn't seem like it needs clarification for me.
for u
TypeError: test() missing 1 required positional argument: 'member'```
i am getting this
k
And you need to provide a member when executing the command, such as !kick @slate swan
It's a different method.
disnake.Member.edit() and disnake.Member.timeout()
!arg-kwargs @timber crescent
*args and **kwargs
These special parameters allow functions to take arbitrary amounts of positional and keyword arguments. The names args and kwargs are purely convention, and could be named any other valid variable name. The special functionality comes from the single and double asterisks (*). If both are used in a function signature, *args must appear before **kwargs.
Single asterisk
*args will ingest an arbitrary amount of positional arguments, and store it in a tuple. If there are parameters after *args in the parameter list with no default value, they will become required keyword arguments by default.
Double asterisk
**kwargs will ingest an arbitrary amount of keyword arguments, and store it in a dictionary. There can be no additional parameters after **kwargs in the parameter list.
Use cases
β’ Decorators (see !tags decorators)
β’ Inheritance (overriding methods)
β’ Future proofing (in the case of the first two bullet points, if the parameters change, your code won't break)
β’ Flexibility (writing functions that behave like dict() or print())
See !tags positional-keyword for information about positional and keyword arguments
await msg.guild.me.edit(until=None,nick=(msg.author.display_name),)
TypeError: Member.edit() got an unexpected keyword argument 'until'
and
await msg.guild.me.edit(duration=None,nick=(msg.author.display_name),)
TypeError: Member.edit() got an unexpected keyword argument 'duration'
As I said, those are different methods.
.timeout() != .edit()
So call .timeout() once and.edit() once.
Not if you don't give more information.
wait why would i need to call .timeout()
i just wanna steal a users nick and make bot imitate them
Please stay in the help channel. They are the most active.
isnt timeout that moderation thingy
Simply be patient :p
i did but the person in help said go to discord bots
i never knew this was a thing
lol
Well, you should stay in the help channel, since someone is there.
welp im slow lol
For the next time you can ask here, but you're allowed to use help channels for bot related questions.
was this for me?
See #help-cupcake @green bluff
And stay there ^^
why the ping im right hereπ§ββοΈ
Xd
@slate swan pls help TwT
async def on_message(msg):
if msg.author==bot.user:
return
print(msg.content)
if 'media.discordapp.net' in msg.content:
await msg.guild.me.edit(nick=(msg.author.display_name))
this much should work yes?
what did i miss in the msg.guild.me.edit
cus i get this
Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Program Files\Python310\lib\site-packages\nextcord\client.py", line 414, in _run_event
await coro(*args, **kwargs)
File "C:\python scripts\#embed fixer.py", line 12, in on_message
await msg.guild.me.edit(nick=(msg.author.display_name))
File "C:\Program Files\Python310\lib\site-packages\nextcord\member.py", line 795, in edit
raise TypeError(
TypeError: Timeout must be a `datetime.datetime` or `datetime.timedelta`not _MissingSentinel
bot is commands.bot here , are you trying to make a global check?
well , then just self.bot.add_check(function) inside the init
Β―_(γ)_/Β―
Errors?
the dunder lol
.
Where is the .timeout() call?
nowhere in my code TwT
Save your file correctly and restart the bot.
msg.guild.me.edit()
with nick kwarg
wew
i did this
tried
they use nextcord it does not have a Member.timeout method
Oh well this explains things
whats the issue then? why's it giving that error?
how can i set a cooldown within a command? currently, i have a command where an arg = None when invoked, however in the actual command its set so that "if arg == None:" then does a fancy embed of how to use the command, if this is executed, the cooldown will take place (15 seconds) how can i make the cooldown for the command only AFTER that specific if statements execution is complete and set the cooldown to 5 seconds
Koi py sika do
Try to add timeout=None
!rule 4
4. Use English to the best of your ability. Be polite if someone speaks English imperfectly.
in the arguments?
You don't import bot.
code?
It will be
bad
that was an example
function is nothing
Can anyone help me to learn py
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
needs to be an actualy function , and remove the @bot.check
It will be, see how classes and cogs work again.
it worked
but it raised an exception too and didnt proceed ahead
lemme add a try except that should be good enough ye?
Error says all
Bot doesn't have permissions to edit nickname.
Not even its own nickname.
but it did it
?
the exception says it failed but in discord i see it changed its nick
Can you help me to make antinuke bot
You trying to do something else then
We help you with issues you face and guide you, we don't code for you.
What is your entire code of the event?
@slate swan :smiling_face_with_tear:
tysm try except worked out
@bot.event
async def on_message(msg):
if msg.author==bot.user:
return
print(msg.content)
if 'media.discordapp.net' in msg.content:
try:
await msg.guild.me.edit(nick=(msg.author.display_name),timeout=None)
except:
return
await msg.channel.send(msg.content.replace('media.discordapp.net','cdn.discordapp.com'))
Oh well, bot can't timeout members.
What if you remove the timeout argument now?
Maybe your previous error is gone
i mean , i can guide u with errors and how to fix them
but i cant write a complete bot for u
wait no
it wont change the nick as well
the try except didnt fix it TwT
Yeah it didn't
!d nextcord.Member.edit brb
Remove the timeout kwarg, maybe your previous issue is gone
@slate swan how to start py
oh wait
run the file?
π€¦ββοΈ it stops there cus it quits at the except
!resources Is what you need.
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
@slate swan but I dont have pc I have phone only
whats the api equivalent for server avatars? can bots even access that?
like changing pfp but only on a server
Do bots also have to pass the NSFW filter??
Bots do not have access to this endpoint.
?
The NSFW warning which happens with users
No they don't need to, they have free access to the channel and can send any messages there.
Oh cool so even if you send a NSFW message in SFW channel it will be sent?
But...
Yes
Just note that your bot can get reported and deleted if you do so.
Oh hmm and no filter?
It changes its pfp to the user and Nick as well
And your account can get terminated as it's breaching the developers policy to send NSFW messages in SFW channels.
It's not a bot, it's a webhook.
It uses webhooks lol
Yes it also has the "Bot" tag next to its name, but it's a webhook.
Hmm
I spend 3 days learning discord python and python and whatnot for trying that out π€¦ββοΈ
You are responsible for what your bot sends, you need to implement the filter.
And it's not even close to what I thought it was π₯²
Yeah... sometimes my bot sends NSFW images by mistake
I expected Discord to stop that
I would disable the feature until you've built a filter. It's not Discord's job to check everything you send.
It checks it for the user
The filter of Discord is very bad
True
You can easily send NSFW messages in SFW channels, so I wouldn't rely on their filter. That's why making yours or removing/limiting the feature is the best.
Hmmm
How to make your own NSFW filter?
Without using any API ofc
Never went into image analysis myself, there is definitely more information on the Internet available. And you have a high chance of having a library/API.
APIs got rate limits
Not good enough uh....
In the end I'd recommend to use an API otherwise your bot will be slowed.
Make your own API that analyses the image.
I will but how to analyze it still
Well, there must be multiple guides on how AI and image analysis works ^^
Alright
I will try checking them
Sounds great, good luck 
is guild none? you can do guild.get_member
Then you can use get_member on a guild object, you will need to also use get_guild on the bot object to have that guild object.
You have both, user and guild id given back at all times: payload.user_id and payload.guild_id
Guild is also none.
The reaction remove event returns only the following:
β’ user_id
β’ channel_id
β’ message_id
β’ guild_id
β’ emoji
i still doesn't work
How do you execute the command?
/test member.mention
member.mention?
You mention a user right?
ye
ex:/test @slate swan
how can I host my bot for free
?
You don't, all free hosting services are bad and limited
wtf?
why?
many of them do
why can't I ?
Doesn't matter if someone uses it or not , but what Krypton said is correct
As I said, most hosting services are bad and limited.
;-;
You risk your token , since they have acess to all your files...
oh ic
what abt uptime robot?
Replit is not a host.
Some cloud platforms have always free tiers which may be sufficient for your bot if it's not a resource intensive one
yes , like AWS or Google cloud
I am sayin' I just wanna make my bot online 24/7 so that it can easily get used by users while my pc is shut down
simple
If it's not a too big bot , you can use replit
I'll still not suggest using it as your host tho
I use replit for some single server bots and it fulfills the requirements
It's not a big bot it's just like when u say any animals name it can say u it's sounds name
K
Which hosting I need to buy?
.
hm I am thinking to apply for student pack
I can get a host for free I think
can I use heroku? @slate swan
can u help me?
Messages with colors:
Discord is now slowly rolling out the ability to send colored messages within code blocks. It uses the ANSI color codes, so if you've tried to print colored text in your terminal or console with Python or other languages then it will be easy for you.
To be able to send a colored text, you need to use the ansi language for your code block and provide a prefix of this format before writing your text:
\u001b[{format};{color}m
The \u001b is the unicode for ESCAPE/ESC, see http://www.unicode-symbol.com/u/001B.html. If you want to use it yourself without bots, then you need to copy paste the character from the website.
After you've written this, you can type and text you wish, and if you want to reset the color back to normal, then you need to use \u001b[0m as prefix.
Here is the list of values you can use to replace {format}:
β’ 0: Normal
β’ 1: Bold
β’ 4: Underline
Here is the list of values you can use to replace {color}:
The following values will change the text color.
β’ 30: Gray
β’ 31: Red
β’ 32: Green
β’ 33: Yellow
β’ 34: Blue
β’ 35: Pink
β’ 36: Cyan
β’ 37: White
The following values will change the text background color.
β’ 40: Firefly dark blue
β’ 41: Orange
β’ 42: Marble blue
β’ 43: Greyish turquoise
β’ 44: Gray
β’ 45: Indigo
β’ 46: Light gray
β’ 47: White
Let's take an example, I want a bold green colored text with the very dark blue background.
I simply use \u001b[0;40m (background color) and \u001b[1;32m (text color) as prefix. Note that the order is important, first you give the background color and then the text color.
Alternatively you can also directly combine them into a single prefix like the following: \u001b[1;40;32m and you can also use multiple values. Something like \u001b[1;40;4;32m would underline the text, make it bold, make it green and have a dark blue background.
[0;40m[1;32mThat's some cool formatted text right?
[1;40;32mThat's some cool formatted text right?
Raw message:
```ansi
\u001b[0;40m\u001b[1;32mThat's some cool formatted text right?
\u001b[1;40;32mThat's some cool formatted text right?
```
The way the colors look like on Discord is shown in the image below ^^
Note: If the change as not been brought to you yet, or other users, then you can use other code blocks in the meantime to get colored text. See this gist: https://gist.github.com/matthewzring/9f7bbfd102003963f9be7dbcf7d40e51
https://media.discordapp.net/attachments/739937507768270939/969283562731872306/ANSI-Colors.png
Yeah I guess , it would let u host your bot for 20 days in a month free
winrar
remember the weird error some guy had
that we couldn't figure out
@slash.slash(name="test")
async def test(ctx:SlashContext,member:discord.Member):
await member.kick()
await ctx.send("Kicked")```
what's wrong?
TypeError: test() missing 1 required positional argument: 'member'```
what did you type
as a command
/test @slate swan
any help here?
iirc?
bruh
spelling mistake
bruh
i mean you should've noticed they werent colored 
bruh my brain hurts
rest ig
Hi i am trying to create a dashboard for my bot i have a problem with it can i ask it here or where should i ask?
can anyone help?
i get this error
thanks
can u help?
disnake is a library that is better than py-cord
@manic wing
this'
dont ping me, ive seen the message
Discord.py is a library that is better than disnake and py-cord
Errors?
this
What lib is this
from discord import Client, Intents, Embed
from discord_slash import SlashCommand, SlashContext
import interactions
import discord
these
Idk discord_slash
?
this
@random vine
@dusk dock
sorry for the ping
@strong crow

this
What library are you using?
this
π
I recommend using disnake for slash commands instead of this third party library.
or you can use e-discord.py its easier and even follows the name of discordpy so you wont have to change alot
it also converts all the commands u want to slash commands without having to implements stupid stuff
if you are interested
https://discord.gg/W3PFmADm
You should give the GitHub link instead of a Discord server.
You can't do anything with a Discord server invite beside joining it and then continue searching, if you give the GitHub link directly people can install it without having you to advertise a Discord server.
import disnake
from disnake.ext import commands
bot = commands.Bot(
command_prefix='!')
@bot.slash_command()
async def test(ctx,member:disnake.Member):
await member.kick()
await ctx.send("Kicked")```
now what's wrong?
its still not working
@slate swan
is there a permissions kwarg(i think) to use / make slash commands? Like im making a setup command for slash commands and i need a permission decorator so the right people can use it
@light violet can u help me?
with this
say what help do u need
oo i dk about py slash
What's the error
nothing happens
i have to read docs then i will be able to answer
are ur roles higher than bot
? does bot has permission to kick?
yep
bruh then how can u be kicked
admin
not me'''
does he have higher role than bot
no
ok
why do we need intents?
may be ok lemme see me too a py beginer
@bot.slash(
name="kick",
description="Kick a member",
guild_ids=[guildids],
options=[
create_option(
name="user",
description="The user I should kick",
required=True,
option_type=6
),
create_option(
name="reason",
description="Why should I kick them?",
required=False,
option_type=3
)
]
)
@has_permissions(kick_members=True)
async def _kick(ctx:SlashContext, user.mention , reason:str="None Given"):
reason = str(reason)
usr = "<@"+str(user.id)+">"
await user.kick(reason)
await user.send("Kicked from "+ctx.guild.name+" for "+reason)
embed = discord.Embed(title="Kicked a user", description="Kicked "+usr+" for reason: "+reason)
await ctx.send(embed=embed)
```@slate swantry this once
;aw;

do u want to see my bot? if u r interested. adding new feature ban on discord custom presence as selfbot user
reason not accesed?
no quick fixes available
any way i can fix this
#suggest command
@client.command()
@commands.cooldown(1, 600, commands.BucketType.user)
async def suggest(ctx, *, reason='noreasonprovided'):
channel = client.get_channel(928380965787676804)
await channel.send('suggestion idea: {reason}')
oh okay
@slate swan
oh
@slate swan
f string
oh thats what the f does i alwayss wondered what it did
i have programmed for around 4 - 6 hrs now
and for 2 days
!f-strings
Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.
>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."
Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.
niceeee also what does the * do
Here you have a small but good explanation
thanks
Here it's explained
And if you scroll above you see how it acts without the *
or if you do*reason instead of *, reason
what did u import here?
wait @slate swan can u do an f string on an embed
Everywhere, it's Python
Whenever you need to provide a string as parameter, you can use f-strings
hey is there any way to auto check discord users status every 10 seconds and ban them if they have streaming status
@slate swan how to get the name of the person who sent the suggestion
can anyone help me with getting the name of the person who sent me the suggestion here is my code
ctx.author
thank you
Make a task loop
so like {ctx.author}
Yup

still nothing
bot doesnt reply
embed.set_thumbnail(url=member.avatar.url)
this right
Are you sure you've restarted the bot?
#bot-commands for random commands :)
!p leaderboard
Converting to "int" failed for parameter "pep_number".
Ok sry
Can you show the code again? And what version of discord.py are you using?
That's Python version, not discord.py version.
oh i see
from pypi?
What if you print the avatar url?
where did you install discord.py from?
Oh well yeah
can anyone help me with some py error?