#discord-bots
1 messages · Page 629 of 1
Guys, i'm making a discord bot with python, how i check if have a None value in an array?
No, to db
activity=None
as well to there*
?
Use a for loop and it's called a list in Python
oh thx
If None in list mby
another way should be, yes that ^
Try this, otherwise u have to write a for loop
Nvm yea
i can give a example wait
That's a faster way. Sorry
If None in your_list:
return True
Try something like this
tried but no help
Code
breh I have most of commands for modeation that mee6 has
Then u have enough ig
mee6sux
but the fact is @unkempt canyon > than other mod bots
It does
I have that bot blocked
i havent initialised self.bot
THE BEST EXAMPLE FOREVER
someSplitList = message.content.split(' ')
command = someSplitList[0]
firstArg = someSplitList[1]
if firstArg == None:
await message.channel.send('You need mention a user!')
Are u in a cog?
Yes?
single main.py
is a example
:/
Oh I thought you needed help
yeey
Then do it w/o self
now I got a command idea: a note command
isn't itpy bot.change_presence(activity=None)
I don’t know how to help so I’m gonna sit back and watch this
imma copy that
You know u can do message.mentions to get all user mentions in a list?
lol
A bookmark command like sir Lancebot?
bot.activity = None
haha I alrd made it yesterday
though editing is gonnn be pain but i think i can do sometthing about that
its a example i dont will use mentions
in commands.bot()???
What?
where should I put bot.activity
Damn
there are few more but these are main commands
I would like to understand if it is possible to check if there really is this value in the table
Make a tic-tac-toe and loser gets banned
nah, I'm looking for useful ideas
If “value” in list:
You may notice it's focused on moderation
Perhaps a ghost ping detector? Detects ghost pings --> stores in a database, then a user can use a command to check if they were ghost pinged or not
Bro idk, u gotta ask moderators what commands they want, not devs
helppy await client.change_presence(activity=None)not working
Or you just make on message event, inside u put wait_for(message_deleted) with certain timeout and if it gets triggered you know they ghost pinged
do client.activity = None
where should I type that
I have a event that stores messages when they get deleted if they contain mention
Same place u type this
That won't work
Did you do aliases?
await?
add custom auto responders for admins
You mean command aliases? Yes
Ok
Autorespond?
Ik, It’ s just a desperate attempt
Spam checker
Exists
U didn't send it to the API lol
F
😭
What’s the problem?
Lmao mby u can make direct request to api
When someone say the name of an admin, bot will send a message which is like```
Person: Blank
Bot: He is the one who suggested this function
Person: Yea!```
No problem, just me being dumb
No this is pure retardism from my side, dont do it 😂
Does not sound useful
:( Any other way?
What like when I ping mods literally everyday?
Occasionally
A coroutine is something that has async or needs to be awaited
mod mail??
Make a direct request to discord api

ticket open?
Whats the url and params??
I have a simple mod mail inbuilt to bot
What do you need Blank?
Go to documentation on discord developer portal
Will None work? No?
It’s not
He wants to set bot presence and after some time remove it
nope
Nope
Seems like it
We’re discussing discord bots how is that ot
Some of you
Wdym rerun?
You can make a function and run the first function and after some time run the other function
Won’t work nvm
Me being silly ignore that
Okok
Why would you?
Remove bot presence
Thats dumb
Use disnake
disnake Use
Yes
Thats my line
Not anymore
Yes looked it up on GitHub

They didn’t provide enough info
What did u find?
Cant find 😢
Myb that
I saw that already but not sure what to do
Idk
Do you just give people repos by their name
Why
Idk

Bruh just create custom activity and set It’ s name as \u200b 😂
Direct api call
Ok
No it won’t work
Or just do sudo rm -rf .
You have to use the make it work function
😂👌
Just brick the computer
Just throw it away
Brick it and throw it away
And burn it
And rm -rf
And make it explode
Sudo explode
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
How would I stop a specific command from raising an error?
use error handler
Its a fork and its all the same syntax
elif isinstance(error, commands.CheckFailure):
rightchannel = self.bot.get_channel(912978002332221470)
if str(ctx.command) == 'register':
await ctx.send(f"Please use {ctx.command} in {rightchannel.mention}.")
elif str(ctx.command) == 'deleteaccount':
return
else:
await ctx.send(f"Only registered users can use {ctx.command} in {rightchannel.mention}.")
Try and except
In the middle if statement, I'm trying to make it so if the command is named 'deleteaccount', it won't bring up the error
Not a bare except btw*
Yeah its all the same you just have to change discord to disnake
wdym by path of the command 
its:
except discord.Forbidden:
@slate swan would I do ```py
try:
ctx.command
except commands.CheckFailure:
pass
Mainly wondering about how I would try the command, like the syntax for that
use ctx.command.name
make an error handler instead
ctx.command is the command object afaik
Scroll up @sullen shoal
my answer remains the same
cool
Yeah
Yeah i think so
Im not really familiar with slash commands
I do know how to make them bot im not good with them
Yes
Disnake?
In cogs u use commands.slash_command
how do i get a message then get the context for that message
U cant, what do u wanna do
for a cog its always@commands.command()iirc
need to get a message i sent for the bot to edit inside a loop
Did you added the cog?
but i still need the message object
!d discord.ext.commands.Bot.get_context
await get_context(message, *, cls=<class 'discord.ext.commands.context.Context'>)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Returns the invocation context from the message.
This is a more low-level counter-part for [`process_commands()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.process_commands "discord.ext.commands.Bot.process_commands") to allow users more fine grained control over the processing.
The returned context is not guaranteed to be a valid invocation context, [`Context.valid`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Context.valid "discord.ext.commands.Context.valid") must be checked to make sure it is. If the context is not valid then it is not a valid candidate to be invoked under [`invoke()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke").
Didnt u say u have it?
U can do bot.get_message(msg_id)
thank you 😃
Send ss of the cog
No you can't, it needs to be on a channel object. And it's onlt fetch_message
!d discord.abc.Messageable.fetch_message
await fetch_message(id, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves a single [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") from the destination.
It's part of the 1.x migration.
Fetch message is an api call, you can get message the way I told him if message is cached
Did u install disnake?
Oh disnake, interesting that they add removed and changed functions 🤡
Got replaced for a reason on discord.py - don't get it why they would add it again, but whatever
Well it has support for components and interactions and slash so I use it
Are u in venv?
Yeah but still, it's weird
The api is nice tho
They don't have an API
Virtual environment
Or do they have an API?
How can u make a library w/o api?
You said "the" API. It's not theirs
Are u installing disnake in virtual environment
It's Discord's API
What do u think api is?
The API is what Discord provides
Api in general
disnake is an API wrapper, totally not the same
What do u think it is
Might want to check the definitions and difference between both of them.
I think you dont rly understand what an api is
Disnake isnt a api its an api wrapper for the discord api
I'm making an API myself I'm pretty sure I know what it means..
Savage
Tell me what do u think it means
It also has It’ s own api
Bro i think you dont know what it mwans either
I really doubt
Last night you told me i didnt while i know plenty about apis
Let me join their support server and ask that.
Well, you are wrong
Will come back
Is pip*
Pip should be installed with python
If you cant use it,its not in the environment variables
Wdym by run pip
is there any method to get the id of the person who added the bot to the server? i want to send them a message and also the guild owner a message referring to the bot's setup process so yeah
try py -m pip install
Find out anything?
He doesnt
He needs to check if pip is in the environment vars
I've asked about it although I know the answer and will be taken for a clown in the server.
I will get back to you once I got the expected answer, to then make you check the definition of an API and an API wrapper again.
oh
any idea about this?
You go the your computers environment variables
You need to check the definition of api 😭
No you need to do that.
Are you ok?
disnake is an api wrapper
He doesn’t know what api is, he thinks api is a restful server u make http requests to
If you've never made any REST or websockets API I wouldn't ask people that do it to check what's the difference between an API and an API wrapper is.
Yes but it also has It’ s api
Were talking about an api:
Application programming interface
disnake is an API wrapper only as it only communicates with Discord's API.
Without Discord's API, disnake is nothing.
how to get guild id inside a task ?
I made rest apis, but rest api != restful server
what?
it connects to the discord API
it doesnt have its own api
Api is a contract between two applications so they can talk to each other
Not rest service
Every library has It’ s api
i know that. im saying that disnake just connects to the official API and then when you use disnake its acting as the "middleman"(or whatever you call it) between your code and the discord API
pip installation how to add pip to PATH on WINDOWS 10 Python 3.8
THIS VIDEO PROVIDES A SOLUTION FOR THE FOLLOWING ERRORS:
fix SyntaxError: invalid syntax
File "stdin", line 1
pip install pyautogui
DIRECTIONS:
GO TO CONTROL PANELSystem and SecuritySystemAdvanced system settings
Environment Variables
N...
d.js is also an api wrapper
Api doesnt mean a http endpoint where u send requests
Bro.
Hey there! i was wondering how can i re-create the
pls fight command from dank memer but in py
can anyone help me out?

That is clear to me, but for u to use disnake, you need to use It’ s api
Technically i get his point, but for the sake of simplicity nah
You add .py as the prefix
It has
oops sorry my bad
And i wouldnt really call that an api, because its not another application interacting with it
@slate swan
Disnake is a api wrapper for the discord api can you guys get it?
bruh
Api is a contract for two applications to interact, or two pieces of software if u prefer that
Lemme give yall an article
it doesnt need its own api
It clearly explains what an api is
Discord.py a wrapper
Disnake a fork of the discord.py wrapper
They all interact with the discors api
And that's my point, the API is between Discord and disnake, not disnake.
The API is provided by Discord.
So what application is interacting with disnake?
Yall pls read this https://www.mulesoft.com/resources/api/what-is-an-api
What is an API? (Application Programming Interface) API is the acronym for Application Programming Interface, which is a software intermediary that allows two applications to talk to each other. Each time you use an app like Facebook, send an instant message, or check the weather on your phone, you’re using an API. What exactly is an API? Finall...
Python interpreter?
Ur code, It’ s not necessarily application
what
It can be a piece of software
You don't get it do you?
Then it is not an API
What is an API? (Application Programming Interface) API is the acronym for Application Programming Interface, which is a software intermediary that allows two applications to talk to each other. Each time you use an app like Facebook, send an instant message, or check the weather on your phone, you’re using an API. What exactly is an API? Finall...
Read this pls
Is someone able to tell me how to retrieve permissions from the permission integer returned by discord api?
Example: 2147483647
I want to get if the person has manage_guild
https://ibb.co/BLJ7D2L
https://discord.com/developers/docs/topics/permissions
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
Pls stop with the old tutorials
The first sentence proves you're wrong 🤡
Read everything
The first sentence is enough.
I'm back
No its not
what happened
So u consider ur software the application, interacting with disnakes api?
No, you use It’ s api to make a bot
Im done ur dumb
Try repairing python with its setup
😭
how to get the guild_id inside a task ?
APl (Discord's API) is the acronym for Application Programming Interface, which is a software intermediary that allows two applications to talk to each other (Discord and disnake).
disnake is not an API. It's not rocket science my guy...
^^^
Its a wrapper for the API u use it to simplify interacting with discord API
Yes i agree for the first time
It’ s a library and library needs to have an api for u to interact with
is there a way to get the message using its id? i need to get it after the bot restarts, please help
U are not an application
Discord api
THERE WE GO
And discord is the API
Idc if library is api wrapper or some other shit, it has an api
Datetime library has an api
Discord api
username = await client.wait_for('message', check=lambda message: message.guild == None, message.author == ctx.author,timeout = 120)
username = await client.wait_for('message', check=lambda message: message.guild == None, message.author == ctx.author,timeout = 120)
^
SyntaxError: positional argument follows keyword argument```
Like
^ help?
The devs or members?
Contributors and members.
When you're the only one thinking disnake has its API and everyone says otherwise maybe it's time to stop being stubborn and accept you're wrong.

https://stackoverflow.com/questions/3678665/is-there-still-a-difference-between-a-library-and-an-api
Here
Read pls
You dont belive everything a idiot says
who to get the guild_id inside a task
!code that looks ugly af
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.
Its stackoverflow
anyone?
@velvet tinsel
wtf do you mean by who to get?
i think he means how
sorry how
You are not an application, if you consider ur code the application interacting with it maybe technically u have a point. But for the sake of simplicity nah, its not api
My dad told me that and he is a principal software engineer, I also used to think api is only web related and u make http requests to it and he told me I was wrong
Look the second comment. It exactly shows you're wrong. Don't look at the first comment only...
Yeah im leaving
U can have non web apis
EXACTLY
Your operating system has an API
?? can i get some help please
Ty
But the key thing that makes something an API
Whatever, I give up. Stubborn people will stay stubborn.
Yes
Is an application interacts with it
wtf is happening
does this work?
Or piece of software
Are we arguing over what an API is now?
Like api is just a contract
Thats what i meant by application
A graphics driver API, as example, has nothing similar with disnake.
Im going to call mods if you guys keep with this bs
Yes, and ur bot is piece of software
can't we just get the channel ID normally ?
how to compile a python code
is there a way to get the message using its id? i need to get it after the bot restarts.
Join disnake's server and you will get another confirmation that you're wrong.
So when i asked u that question why did you say no before
"API is the acronym for Application Programming Interface, which is a software intermediary that allows two applications to talk to each other. Each time you use an app like Facebook, send an instant message, or check the weather on your phone, you're using an API."
why whenever blocked messages appear theres an argument going on
i wonder who that person is
Noobian isnt the person lmao
I dont like to get pinged but ok
Now staying stubborn is your problem not mine anymore 
When
always noobian
sry
I will come back later, y'all have a great time
Just b4 i called u dumb
Same im not dealing with this nonsense
I said bot is not software?
Idk, who is it
Bruh u cant argue disnake is an api and then bot is not software lmao
Disnake is not an api, It’ s a library
Im done wiv u
Do we agree?
will this work in a task loop?
Is disnake a library?
Like i said im done wiv u
@slate swan do we agree on this
I wanna come to the bottom of it
Yes.
It is an API
wrapper ^
[...] wrapper
It’ s an api wrapper
I don’t even know what’s happening 😂
I’m gonna send random links and hope people shut up
This dude was saying disnake has an API. So we going into semantics of APIs
!silence
✅ silenced current channel for 10 minute(s).
while teaching the difference between an API, a wrapper and an application is rather important, there are ways to do it and ways to not do it
This is exactly what we don't want to hear
Let's keep this chat friendly, please
!unsilence
✅ unsilenced current channel.
hey
lolwtf
still needing help with my question
Just let us speak we wanna do it or way
This chat has been silenced 3 times
Over the past three days
Lets be calm
Calm
Im done with this server, we having conversation and jannies get involved and adds nothing of value
Ok bye
well, you should wonder why then
Cya
I have been wondering why
Okay so can u clear it for us, does disnake have an api
How to get guild id inside a discord task ? 
I honestly don’t know sarcasm intended
I bet ur the typical fat discord mod from the memes
Thank you
no I'm not
@slate swan
Why did you DM me
✅ silenced current channel for 10 minute(s).
!ban 788098387354452060 You are right, you should indeed leave the server. Your conduct has been flagged many many times as being one of the main reason this channel is toxic, and when asked to drop a heated argument you menace to leave the server and just start pseudo-insulting everyone? I don't think you are a good fit for this server, and its mentality
:incoming_envelope: :ok_hand: applied ban to @normal viper permanently.
!mute 562359123086409729 4d Is it too hard to drop an argument, especially just after a mod tells you to? Perhaps the original statement was different, but it isn't a reason to react so aggressively. If an argument gets heated, just take a small break from Discord. There is no need to reply with bold messages just to say that there is a difference between being and having an API. Explaining slowly and calmy is the key of teaching. Please re-read our #code-of-conduct.
:ok_hand: applied mute to @slate swan until <t:1638282085:f> (3 days and 23 hours).
!unsilence
✅ unsilenced current channel.
is this 4th time this channel was silenced in 24h?
yes
.topic
Suggest more topics here!
Damn
fine grained slash commands permissions
adding more stuff I guess
ah, so only those with the permissions to use that slash commands can see it? or just better perms in general
both.
any ideas to discord bot commands, I'm again running out of them, mainly moderation
Economy bot?
connect four command
That’s what I’m working on 🤷♂️
too many imo 😂
616 lines of code I’m not even finished
Like the ones that's coming soon™ that I am very excited about 👀
is there? that would be neat.
I’m very stupid at anime so I had to join a anime discord server to ask for characters to add to my discord bot
I heard MEE6 already got them 👀
What do you want
well.. I don't find them useful at all, especially not for my bot. That feature is semi nice but takes a lot of work, like a lot
^^
Ok, tic tac toe?
builde discord music bot
my original idea was to find some moderation commands
:l
I mean it's just economy, economy is not fun at all except if there's something fun in it but economy bots overall are bad imo
Dank is ok ig
Can you test my bot out after I finish it to see if it’s ok and add suggestions?
Well, dank memer is something else
how about the silence command you saw here
sure I guess
yooo niceeeee!
simple and useful sometimes
Not really right? Are you sure you didn't just see it from the link I sent above?
I alrd have it
Should be a bot for this channel
Add users to a list and ping a mod whenever one of them comes in
what?
The problematic users
That somewhat kinda exists already, the codebase for @unkempt canyon is huge. https://git.pydis.com/bot
I guess lol
They did enter a token, it was just None
@slate swan you probably did bot.run(os.getenv('token')) but the env value wasn't found. Make sure you do load_dotenv() before the os.getenv()
O
>>> def bot(token):
pass
>>> bot()
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
bot()
TypeError: bot() missing 1 required positional argument: 'token'```this would be the error for not passing it
I made a some sort of filter for invite links but it sometimes deletes attachments as well ```py
@commands.Cog.listener()
async def on_message(self, message):
invite_is_https = re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[$-@.&+]|[!*(),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', message.content.lower())
invite_is_discord_gg = re.findall('discord.gg/(?:[a-zA-Z]|[0-9]|[$-@.&+]|[!*(),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', message.content.lower())
if message.author.bot:
return
if invite_is_https or invite_is_discord_gg:
log.warning(f"Invite sent in {message.channel} by {message.author}")
await message.delete()
await message.channel.send("Please don't send random invites")
my bad then
cause attachments have a url too?
sometimes deletes attachments as well
Because attachments sometimes use discord.gg
oh ...
damn
cdn.discordapp.com is where it usually goes
^^
Wait yeah, it's just because of invite_is_https I think
INVITE_RE = re.compile(
r"(discord([\.,]|dot)gg|" # Could be discord.gg/
r"discord([\.,]|dot)com(\/|slash)invite|" # or discord.com/invite/
r"discordapp([\.,]|dot)com(\/|slash)invite|" # or discordapp.com/invite/
``` seems like @unkempt canyon has this
How do you do regex by the way? did you do it manually or is there some kind of converter for it
not really made by myself, I could not memorize everything
o
there was some sort of converter online that worked
what is it
not sure, it's somewhere in my code or in my search history
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
give me it 😩
how am I supposed to find it if I don't remember the name
I might know 1 but it's not the one i used
nope can't find it
bruh
my bot cant play music
!ytdl
Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.
For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:
The following restrictions apply to your use of the Service. You are not allowed to:
1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service; (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;
3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;
9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
we won't help you on that
yes
do you have problem with that ?
no, but we won't help you cuz rule 5 music bots are against the yt tos
be kiram
Wdym?
I don't have a problem with copy pasters as long as they don't try to act smart or something
usually used to say "i dont give a fuck"
voice is None, you're probably not in a VC
Moderators are gonna ban you for toxicity lmfao
im not the one who said that, they asked what it meant so i answered
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
Can u send ss of code
using a compiler of it
https://paste.pythondiscord.com/ajojusokiv.py
the mo!setup work in only one server but not in the other one
dude in this server
a discord guild cant compile code
!run n = 0
for n in range(100):
n += 1
print("numbers", (n))
it is really long
Do u get error
no
Can u paste the whole code
Ok so first of all, creating a connection to database is an expensive operation, you shouldnt be doing it every time you want to interact with db, rather use connection pooling
Does it work if you just do setup?
it working in only one server where i test my bot
Also try putting bot = commands.Bot(command_prefix=“mo”)
Is the bot in both servers and does it have permissions to send messages and view channels?
ok i am dumb af, so i have a test bot where i test the new features and all the things and apparently both the bots have same pfp and username so i got confused
i am sorry @cedar stream
Lmao dw
btw how to define client in discord.py python file
client = discord.Client()?
ok thx
U will install it in an isolated environment
how can i remove user's reaction after he clicks?
guys i fucking hate my life
^
the bot isnt running 2 instances but idk abt the cog.....
!d discord.Message.remove_reaction
await remove_reaction(emoji, member)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Remove a reaction by the member from the message.
The emoji may be a unicode emoji or a custom guild [`Emoji`](https://discordpy.readthedocs.io/en/master/api.html#discord.Emoji "discord.Emoji").
If the reaction is not your own (i.e. `member` parameter is not you) then the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission is needed.
The `member` parameter must represent a member and meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.
help me pls
what is the delay between both messages
how do I search a json files list inside of an object
what
Do u have an on_message?
how do I see a list in a user object?
what list
without going through all of them
show me the list show me the object
"POR_G1": {
"username": "POR_G1",
"password": "OTTERS",
"creator": "770210759359070209",
"level": {
"experience": 0,
"level": 0
},
"economy": {
"money": 0,
"bank": 0,
"inventory": {}
},
"login": [ HERE
770210759359070209
]
}```
what do you need from here
the login list?
why is the value of creator a string
!e
d = dict(foo=None, login=[1,2,3,4])
print(type(d.get("login")))```
ohh
@sullen shoal :white_check_mark: Your eval job has completed with return code 0.
<class 'list'>
it will return the object that is set as the value of the key
not in tht cog.... i do as an event
line 74, in check_if_member_blacklisted
if any([role for role in member.roles if await DBmanager.check_is_blacklisted(role)]):
AttributeError: 'User' object has no attribute 'roles'```
any idea why i get this error , i already typehinted the member variable as disnake.Member ```py
async def check_if_member_blacklisted(message , member : Member):```
ooh lemme see
Yea, and what decorator u using in it? @bot.listen() or @bot.event
so what is foo
a key value pair
listen
just check the src code
so 2 minutes
@sullen shoal here u go
so what do you mean? in english
no its 2 seconds right?
seconds*
oh
What's snowflake?
the loop is 60 seconds tho
yeah
{key:value}```
Just a simple int, if u don't wanna go deep
So nothing useful or.?
It can be a string also iirc
Where's it used at
see i still have 90% doubt that you are running two instances of the bot
in the language made in england
how can i chec?
and commonly
that would be " a key value pair.`
you may ask anyone present here to verify that, what i said is English
;-; VSCode doesn't open up console even when I press F5
i got it so i deleted
kk
are running it locally or some server
how check i, how fix i
def it
So it generally generates unique int?
vps, vultr
yea
It could be used to create identification?
stop it then download the files and run it locally to test
Mhm
aww man.... thts gonna take a lot of time cuz every 12 hours
Have you used it at anything?
what happens every 12 hours
Well every ID (channel and user and server) is a snowflake
well see the code
Hmm
@tawdry perch
?
def key:value():``` finish this def
Ohh I see
enable dev mode
I have it enabled
what is that, what i sent was json
then copy it of this msg
help me man
Wow
Ye I now understood what that is, thx!
just remove the if statement will then work every 60 seconds
well i dont want tht
for testing
How does the thing work
i just want it to send msg every 12 hours at a time
d = dict(foo=None, login=[1,2,3,4])
print(type(d.get("login")))```
well u see, the first time i run it , it sent once...... then 2 times 😦
what does foo mean?
what i dont get is how is this discord bots?
but ok.....
I put it in a disc bot
that is same as,
{
"foo":None,
"login":[1,2,3,4]
}```
the d variable
idk then i would have deleted the entire file and make it again, thats what i prefer if i cant debug something after trying for 5 hours
nice
@gloomy coral if nextcord uses 2.0, you could just use the tasks.Loop.time param
!d discord.ext.tasks.Loop.time
property time: Optional[List[datetime.time]]```
Read-only list for the exact times this loop runs at. `None` if relative times were passed instead.
New in version 2.0.
Wdym nice it was traumatising
Oh yes I need to read the !d code for @unkempt canyon
Look up documentation for Python symbols.
easy to do
Can somebody help me here ?
Something is None
Well im not sure what to change it to
I suck at explaining
isnt this betterdiscord?
Kayle my fingers are cold relieve me
hmm
Guys i need help making commands for my discord bot
because I want to make a bot linked to my geometry dash private server
https://stackoverflow.com/questions/52464966/discord-py-rewrite-cogs-load-extensions-from-other-archive @minor panther
I think
Elaborate
no, i asked how to bot.run()
and after load this
Bot.run? You want to run the bot?
!
what type of commands
So you want to load extensions after bot.run…
yes
I want to make commands to show the stats for my gdps
i have some problems with cache
@boreal ravine will it work to run code after bot.run?
what kind of stats if you dont mind me asking?
Or whatever run()
and i have to use cogs only after the cache will be filled
I dont know if it will work after bot.run
ofc not, load them before running the bot
How do I get invite link of a server ?
No run is looping everything with the lack of a better word
Settings then invites
The levels in my gdps, the leaderboard and the players
bruh from my bot
Oh
when it joins a server
Right click the name of the server and click invite people
so you wanna display them right?
through the bot
Yes
ah do you have a database?
yes
I did all of it before hand
ah what db are u using?
GMD Private server
database.sql
I think it's better to talk about the database is the database text channel
hm yes, but i have no experience with sql lmfao
To get the bot invite, go to your Discord developer portal,
Go to OAuth2 tab,
Copy the Client ID,
Go here https://discordapi.com/permissions.html#0
Paste the Client ID into the box towards the bottom of your screen that is labeled "Insert Client ID here"
Check off all of the permissions you want the bot to have on the server
Copy the link at the very bottom
is this something that exists in dpy? ```py
self.bot.http_session
read dpy source code
that is smth that would take me for ever
welp
not really
import nextcord
import asyncio
import csv
from nextcord.ext import commands, tasks
from datetime import datetime
import os
from pytz import timezone
indian_tz=timezone('Asia/Kolkata')
class Loops(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.checkVoteTime.start()
self.csv_update.start()
self.statusandfiles.start()
@tasks.loop(minutes=2,time=[indian_tz.localize(datetime.strftime("08 30", "%H, %M")),indian_tz.localize(datetime.strftime("20 30", "%H, %M"))])
async def checkVoteTime(self):
await self.bot.wait_until_ready()
channel = self.bot.get_channel(880639248292798465)
vote = nextcord.Embed(title="This is your reminder", description="You better vote for me, here and now", color=nextcord.Color.random())
vote.add_field(name="1", value=f"[top.gg](https://top.gg/bot/864010316424806451/vote)")
vote.add_field(name="2", value=f"[discordbotlist.com](https://discordbotlist.com/bots/chad-6621/upvote)")
vote.set_thumbnail(url="https://i.imgur.com/QICgRpf.png")
await channel.send(embed=vote, content="<@&881209363077943326>")```
will this work @sullen shoal
aight, but do you mind to link me the src?
dpy > discord > http.py > ctrl f
well exactly this is not in there
how do i send an embed?
create a variable and set the value as the discord.Embed class
!d discord.Embed
class discord.Embed(*, colour=Embed.Empty, color=Embed.Empty, title=Embed.Empty, type='rich', url=Embed.Empty, description=Embed.Empty, timestamp=None)```
Represents a Discord embed.
len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.
bool(b) Returns whether the embed has any data set.
New in version 2.0.
Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty").
For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") for you.
ok and now
Send the embed..?
but how do i send the embed?
!d discord.TextChannel.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**.
ok
code... shows error ```py
ExtensionFailed: Extension 'cogs.tasks' raised an error: SyntaxError: expression cannot contain assignment, perhaps you meant "=="? (tasks.py, line 16)
Wheres line 16?
now when i send the embed it only sends <discord.embeds.Embed object at 0x00000145D0D93E20> proberbly because its empty. How do i specify the attributes?
send it like embed = embed 2nd "embed" being ur embed variable
Can somebody help me? I am trying to create a variable that represents a role but it seems im getting errors
My error/python file: https://paste.ee/p/x1xQ6
What is the coding for making commands?
client = discord.Client()
@client.event
async def on_ready():
print(f'{client.user} has connected to Discord!')
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content == "T!help":
await message.channel.send(embed = Embed)
client.run(TOKEN)``` There is something wrong
import discord
from discord.ext import commands
client = commands.Bot(command_prefix="!") # you can customize your prefix here
@client.command()
async def commandName(ctx): # whatever this function is named is the name of your command
await ctx.channel.send("Test command") # everything inside of the function gets ran when you execute the command on your discord server
Don’t spoon feed
idk i cant help with your problem, idk shit about loops
Where
Why is your embed empty
Lmao 😂
is on_disconnect triggered even if we manually stop the bot's script file?
wdym by manuallly stopping
how does this work?
Idk need to read
I forgot how to link to the piece of code
be specific what did you not understand
He wants the code
!d discord.Message.channel
The TextChannel or Thread that the message was sent from. Could be a DMChannel or GroupChannel if it’s a private message.
.
ok
all
!e
d = {"foo":None, "login":[1,2,3,4]}
print(d["login"])```
I dont even know how to run it
@sullen shoal :white_check_mark: Your eval job has completed with return code 0.
[1, 2, 3, 4]
You want to copy it?
@twin moon now?
!e print(“like this?”)
@velvet tinsel :x: Your eval job has completed with return code 1.
001 | File "<string>", line 1
002 | print(“like this?”)
003 | ^
004 | SyntaxError: invalid character '“' (U+201C)
Anybody?
@velvet tinsel :white_check_mark: Your eval job has completed with return code 0.
Hello world!
What errors
On the link I sent
Default role seems to be None
What im asking exactly is how to use the getrole() properly because im obviously using it wrong
No that’s not the problem
Something seems to be None in your code
does anyone know how to get discord slash commands working with cogs? I've imported using
from discord_slash import cog_ext
then I added it to my help command and I've invited the bot with the commands permission but it won't run my command when I call it
Idk
@flint cosmos The guild is None
😭
Ok thanks for clearing that up
how do i change the style of the text for my bot?
what is the value of line 16
What do I have to make the guild var then?
I have no idea how to do any of this stuff
{
"roleIDs": {
"defaultRoleID": 912534307443183646
},
"channelIDs": {
"systemMessagesChannelID": 913090699254190110
},
"serverID": 911418973118165042
}
Probably the guild isn't in the cache, or check the id or valid type which should be passed into get_guild method
What version u r using?
Of discord.py ?
yes
hello
Im not sure, I just did python -m pip install discord.py
guys can you tell me, how to load all cogs only after the cache will be filled
It should be 1.7.x iirc
How do I find a list in a json object without manually searching for every file
pretty sure you need to grab the server using
guild = client.get_guild(serverID)
after the bot initializes in the event "on_ready"
That is exactly what I have
Try converting your guild_id into integer
@client.event
get the guild on the event you're going to use it, the cache might not be ready when line 17 is executed
Client is not recommended to use
or the id is invalid
@flint cosmos
@client.event
async def on_ready():
guild = client.get_guild(serverID)
how can i arrange my commands in catergories. on google stuff is old and confusing
Oh yes, your bot isn't started completely when you're fetching the guild
Yeah but I dont wanna redefine the variable everytime I check for the defaultRole, I just want to do it once
You mean cogs?
Oh ok
How do i change the style of the text for the bot?
You mean cogs?
Wdym
then save the instance in the Bot instance
as an attribute
use tasks to do the stuff
does anyone know why I get this?
I am confused
how does your function work?
try the slash command again
?
Like when i type in s!help It shows all of the commands in a different text style instead of
This
json files d = dict(foo=None, login=[1,2,3,4])
Is discord really going to force us to implement slash command
You need to replace help command
ok
but I'm setting up like this
when you get the Role instance, set it as an attribute of your Bot instance
@somber tree
#discord-bots message
show helpme command
How do I do that?
!botvar
Python allows you to set custom attributes to most objects, like your bot! By storing things as attributes of the bot object, you can access them anywhere you access your bot. In the discord.py library, these custom attributes are commonly known as "bot variables" and can be a lifesaver if your bot is divided into many different files. An example on how to use custom attributes on your bot is shown below:
bot = commands.Bot(command_prefix="!")
# Set an attribute on our bot
bot.test = "I am accessible everywhere!"
@bot.command()
async def get(ctx: commands.Context):
"""A command to get the current value of `test`."""
# Send what the test attribute is currently set to
await ctx.send(ctx.bot.test)
@bot.command()
async def setval(ctx: commands.Context, *, new_text: str):
"""A command to set a new value of `test`."""
# Here we change the attribute to what was specified in new_text
bot.test = new_text
This all applies to cogs as well! You can set attributes to self as you wish.
Be sure not to overwrite attributes discord.py uses, like cogs or users. Name your attributes carefully!
tbh im confused with what you exactly meant by redefining Role or whatever
I changed it to helpme shortly to see if it was even getting the name right, but it seems to update extremely slow
it's the same function I showed before
i gave you the new code, check that is that confusing you
sad
hm.. you sure the module your using takes ctx as a parameter
where?
Lets say I use the defaultRole in on_member_join but I also wanna use it in on_member_remove, if I define the variable inside of those functions, then I am redefining it each time ??
Show help info
NOW I UNDERSTAND EVERYTHING
hmm what module r u using
Will this help solve the problem Kayle?
isn't whats causing the error, but it's probably a list
use tasks then. one sec i gotta link you a page you may check that for the solution to this
it's just a string
Obviously a list
It has an index 🤷♂️
it's a list with strings
Yes
Apparently that’s not what the problem is, I’m gonna go
the command works fine without the slash stuff
guys, do you know how to once get roles, and save them somehow and after use them from different cogs
can i hide commands(some) from appearing in help command
Bye kayle 😂
obviously.. but that isn't the issue
Oh it would return an indexerror
remove the help command after creating your bot then make a custom one
If the list wasn’t there
?1
https://discordpy.readthedocs.io/en/stable/ext/tasks/index.html
check "Waiting until the bot is ready before the loop starts:".
get and set them as attribute of the bot instance there
typehint it
Hard coding a help command is a bad idea
it requires a certain context, not commands.Context
.bm
Don't big bots do that though?
i dont want my dev commands to show
This seems very confusing, what is a "cog"
command group
a very nice way to organize your commands
I'll try it
Don't most big bots just have a website?
True
Im still confused on what a cog is
A command group
!d discord.ext.commands.Cog <= read this
class discord.ext.commands.Cog(*args, **kwargs)```
The base class that all cogs must inherit from.
A cog is a collection of commands, listeners, and optional state to help group commands together. More information on them can be found on the [Cogs](https://discordpy.readthedocs.io/en/master/ext/commands/cogs.html#ext-commands-cogs) page.
When inheriting from this class, the options shown in [`CogMeta`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CogMeta "discord.ext.commands.CogMeta") are equally valid here.
how does website help ?
@bot.command(hidden=True) will hide it iirc
wait a sec, theres a page to explain it
thanks
@sullen shoal No seriuosly what is foo
a key i defined in the dictionary object. it has the value None
what if I assign it to something
cog is more of an category a group is something different.
!d
d = {"foo_or_whatever_you_can_imagine": None}
print(d["foo_or_whatever_you_can_imagine"])```
literally what it means
!e
d = {"foo_or_whatever_you_can_imagine": "can be any object"}
print(d["foo_or_whatever_you_can_imagine"])```
I'm so confused right now
@sullen shoal :white_check_mark: Your eval job has completed with return code 0.
can be any object
Me too 
How
🤔
class MyHelpCommand(commands.HelpCommand):
async def command_callback(self, ctx, *,command=None):
if command:
await ctx.send(f"This the help page for the command {command} ")
else:
await ctx.send("This is the front pagea for the bots help command")
bot.help_command=MyHelpCommand()```
I don't get this code
Well did you copy it?
read the documentation
Yes but now I don't know what I'm doing
Don’t copy code
ok
!d discord.ext.commands.HelpCommand
class discord.ext.commands.HelpCommand(*args, **kwargs)```
The base implementation for help command formatting.
Note
Internally instances of this class are deep copied every time the command itself is invoked to prevent a race condition mentioned in [GH-2123](https://github.com/Rapptz/discord.py/issues/2123).
This means that relying on the state of this class to be the same between command invocations would not work as expected.
You don’t learn like you might writing it yourself
be sure to have to basic knowledge of OOP and python classes
Yep HelpCommand has a lot of OOP going on
Stella's git helps covering it.
do you know how to once get roles, like on_ready, and save them somewhere to use from different cogs