#discord-bots
1 messages Β· Page 770 of 1
I meant json as a database
show me in dms or #databases
ahhh
Sqlite3?
well you cant really read data but you can use the browser of sql
Yes
Search up db browser
^^^^
i downloaded their db browser or some shit, i have it but idk how to read ze data stored inside
Click open database
youll need to use aiosqlite
i imported my file into it aswell
yes I do
ok wait gimme a bit till I go on my pc then we can move to #databases
just use https://inloop.github.io/sqlite-viewer/ , or there's a VSC sqlite extension too if you use VSC
sqlite file viewer
would be awesome if you could link me the extension
how to make a modlogs system?
im just gathering suggestions right now, later I'll take a look at all and decide
alright if you need anything i got youπ«
thanks sensei
β€οΈ
Well once the command is executed you would get the channel the commands are supposed to be logged in and send the appropriate information
and is it really for moderation
cause discord doesnt like when you store allot of data
about users
you need a** good reason** for it
never do this thank you
its bad practice and not really expandable
select the extension from the popup when you read it
not bad practice
I know?
thanks!
yea
i knew json wasnt for storing data and was for formatting it after i made my api wrapper lol
since the api when i make a request its response is always formatted in json
im bored so i just make wrappers for random apis
same
So looking at this example, https://github.com/DisnakeDev/disnake/blob/master/examples/views/select/dropdown.py. Do I have to create 2 classes or is there a way around it?
they arent useful or already have better wrappers but i love making http clients
lol my birthday is tomorrow and i start school tomorrowπ
You directly subclass Select maybe? Idk I'm not good with views and stuff lmao
same here
youll need to classes because each class inherits different classes
basically theres no way around it
you can see it on it
i mean u can try inheriting both of them into one but that might be a mess
one subclasses select for the dropdown and one subclasses View to add the component to the view
What happens if I wanted to make 2 commands that use dropdown menus. Would I have to create 4 classes?
no you can reuse the class
yes
can you?
https://github.com/DisnakeDev/disnake/blob/2b5635fb4bb2d864624332e63cb2e09bf78b3e8d/examples/views/select/dropdown.py#L44-L49 this can be replaced by using the veiw class directly ```py
view = View()
view.add_item(Dropdown())
examples/views/select/dropdown.py lines 44 to 49
class DropdownView(disnake.ui.View):
def __init__(self):
super().__init__()
# Adds the dropdown to our view object.
self.add_item(Dropdown())```
yea unless u want the menus to be different
yeah thats what he said
well then youll have to make new classes
he probably wants it different
^
oh i thought he meant something else
yep ^^
Alright
yeah thats just an instance of the class
yeah , until you dont want to apply something like on_timeout methods you can just use the instance
yeah
@slate swan why do we we have to do ctx.bot.text
can't we just dopy await ctx.send(bot.test)?
yes , we ofcourse can do that !
but if you are in some cog you'd have to use ctx.bot or self.bot if you defined it in the init
ctx.bot gives u the bot variable
weird syntax
what if I don't use init, should I still have to use ctx.bot.var??
!d discord.ext.commands.Context.bot
The bot that contains the command being executed.
yes you can
since you dont have the bot in the cog file ;)
self.bot is just the bot arg in your init dunder
or magic method
is it necessary to create a class to create init?
yea , but you dont use an init if you're a weirdo like me
nope
yea
oh sorry i misread it
I don't use init
init is for classes
init means initiate
you dont use it if you are nt in a class
^
makes sense
kk
well you can just bot.var
thx
wherever u get the bot from
Are we three weebs?
the init Constructors are used to initialize the objectβs state.
yea I have read in java thx
yw
same
romance mostly
π³
i like anime but im not too much into it
i barely can watch it lol
i have no time
exactly
yea same, I have just watched only 74 animes (all seasons) only till now
class, homework, programming is allot
im doing notes and texting at the same time rn
\π
ive only watched like 10
smort
"only"
LMAO
:)
yeah only 74 not allot
you Indian right?
thats what I think :)

Me more than 100
why does everyone assume sarthak is indian its funnyπ

new weeb among us
Lol seems like that
Cause it's a Indian name
lucky smh
sarthak is an Indian name
my name is an indian one
yes
You got 3 replies lol
luckyπ
kekw
cant be me
im an average american

well , lets wait for someone to !ot

Nice
hunter: π
ikr
I'm asian with asian parents π
!ot not here

Off-topic channel: #ot2-never-nesterβs-nightmare
Please read our off-topic etiquette before participating in conversations.

thats nice
Dude don't hate parents just because they are asian and because of memes
π
!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)
thx
Nah bro, I feel normal
I don't hate anyone
it breaks yt tos and as discord said if you break tos in there platform you break theres
you guys get memed so much lmao
Is there any way I can remove a menu when it has been clicked on once?
That's pretty smart

if some website don't have robots.txt and has no mention about scraping in any page, the we are allowed to scrap?? :}
π§
wait, music commands break youtube tos?
yes
yea
edit the message and remove the item from view class
ytdl takes music from yt which yt doesnt like
!d discord.ui.View.remove_item
remove_item(item)```
Removes an item from the view.
aka view = None
Ughh
cant you do this^
That's why many music bots are banned
it removes everything , not just the select
ahh i thought he wanted all of it
I got rejected cause my bot was not online at that moment lol
Guys any website where I can create a GUI by something like drag and drop method and the python code is automatically generated in the background??
dang
Damm sadness
it can be abused by searching nsfw gifs like nd!gif okimii being cool
π³
Remove the command -> Reapply -> Get accepted -> Add that command back
I know
Nah, I will make that command NSFW
use a nsfw filter
hunter you have one job
!ot do it
π³
.
kinda on topic but idk
im pretty sure the api gives you a nsfw bool too
yeah most do
!pypi tkinter-designer
trypy if not ctx.channel.is_nsfw(): return
Bruh
is_nsfw()
...?
yea
Ghost ping?
the praw api has it
@slate swan
what can it do?
Can I get an example? I don't really understand
Use figma to create GUI and convert it to Tkinter python code automatically
Tbh I have never made a gui in python and never knew what tkinter is
@final iron
!d tkinter
Source code: Lib/tkinter/__init__.py
The tkinter package (βTk interfaceβ) is the standard Python interface to the Tcl/Tk GUI toolkit. Both Tk and tkinter are available on most Unix platforms, including macOS, as well as on Windows systems.
Running python -m tkinter from the command line should open a window demonstrating a simple Tk interface, letting you know that tkinter is properly installed on your system, and also showing what version of Tcl/Tk is installed, so you can read the Tcl/Tk documentation specific to that version.
It's an stdlib
async def meme_cmd(ctx: Context):
"""Meme command"""
nsfw = True
while nsfw == True:
"""Avoiding Nsfw"""
data = await fetch_meme()
if not data["nsfw"]:
nsfw = False
async def fetch_meme():
async with ClientSession() as session:
res = await session.get(
f"https://meme-api.herokuapp.com/gimme/{choice(['memes','dankmemes','me_irl','wholesomememes'])}"
)
data = await res.json()
return data``` i used this to avoid nsfw , any better way around?
I know I just don't understand
sure , 1 moment
why not use is
!d discord.ext.commands.is_nsfw
@discord.ext.commands.is_nsfw()```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that checks if the channel is a NSFW channel.
This check raises a special exception, [`NSFWChannelRequired`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NSFWChannelRequired "discord.ext.commands.NSFWChannelRequired") that is derived from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
Changed in version 1.1: Raise [`NSFWChannelRequired`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NSFWChannelRequired "discord.ext.commands.NSFWChannelRequired") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure"). DM channels will also now pass this check.
while nsfw is True:
im checking if the response has nsfw bool set to True
I HAVE BEEN SEARCHING FOR THIS
Just use a custom check
lol why didnt you ask
@lost vine .
π
Lol I was checking the docs
LMAO
!serverinfo
#bot-commands
oh
make a var and compare the random value it got
and use wait for
Is that emoji too cringe or is it just me 
wdym?
@final iron read this , the VIew implementation remains same for all forks so it doesnt matter what library u r using
just you
It is cringe
no
I'm using disnake anyway
Lmao
You code it?
ashley youre way smorter then me for sure
Im a psycho for sure
no youre smort
you mean if the command used by the user is not really a command , the bot must process a command with similar name?
uhuh
like if someone type +welp
bot would say
did you mean +help?`
yes
use fuzzywuzzy
and get the command
Fuzzywuzzy, welp
!pypi fuzzywuzzy
!d discord.ext.commands.Bot.wait_for
wait_for(event, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.
The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.
In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
boi wut the heck boi
This is for buttons. Is it the same for dropdown menus?
eh?
We are not making guess the number, oki
yea , its same!
not related to anything but alr
are you replying to me?
how does wait for help in guessing which command I wanted to type??
is it related to wait for??
you wait for a event in this case a msg
nope
Its nothing, forget to remember
how is that nothing its a guessing game
okimi , read their problem again pls
@slate swan misread the question I guess
prob
ye
(edited) 
wtf no , they mean if something like commands.CommandNotFound happens , the bot gets a command similar to the command that the user used and invoke it
Lets save okimii further humiliation and @slate swan use fuzzywuzzy
mhmmmmm
how the msg was edited?
cof cof
they applied markdown
(edited) :bleh:
make me
But in the example its inheriting disnake.ui.View for the class when I'm inheriting disnake.ui.Select for my class
bet
Sorry if I'm asking dumb questions. Never worked with this stuff before
maybe because you named the classes same?
ill give you a short example wait
you want to disable the select as soon as a option is selected right?
Yup
I need help
with
Python code for this discord bot im making
error?
it dosent have one just wont work
!traceback
Please provide the full traceback for your exception in order to help us identify your issue.
A full traceback could look like:
Traceback (most recent call last):
File "tiny", line 3, in
do_something()
File "tiny", line 2, in do_something
a = 6 / b
ZeroDivisionError: division by zero
The best way to read your traceback is bottom to top.
β’ Identify the exception raised (in this case ZeroDivisionError)
β’ Make note of the line number (in this case 2), and navigate there in your program.
β’ Try to understand why the error occurred (in this case because b is 0).
To read more about exceptions and errors, please refer to the PyDis Wiki or the official Python tutorial.
show
cringe
okay hold on please
Be more precise, what code do you have, what are you trying to do, what is the error (if any)
hey my cat looks like the one in the pfp
thonk
it IS your cat
wut.......................
yeah sorry buddy
-1
Hi so I am currently working on a command in Discord.py where if you do ".methodss" it will show every single method that has been put into a json file here is a better example: .methodss <--- command Method list method 1 method 2 method 3
I hope that gave you a better view of what im trying to do but its not working also there is NO ERRORS IN THE CMD here is the code
#Add a Method to the json string command
@bot.command()
@commands.has_role('Reseller')
async def addmethod(ctx,api, method):
methods = await get_method_data()
api = methods
methods = {}
methods['Method'] = method
methods['api'] = api
with open("methods.json", "w") as output:
json.dump(methods,output)
await ctx.channel.purge(limit=1)
embed = discord.Embed(title=f'{method} has been added to list', color=0x000000)
await ctx.send(embed=embed)
And then here is the command that will print all of the methods from the Json file
@bot.command()
async def methodss(ctx):
methods = await get_method_data()
method = methods['Method']
em = discord.Embed(title = "B")
em.add_field(name = "Methods", value = method)
await ctx.send(embed = em)
Also here is the "get_method_data" function
async def get_method_data():
with open("methods.json", "r") as f:
methods = json.load(f)
return methods
Please help me find where I messed up in this code thank you so much!!
π
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
guys give me command ideas
when you started using json as a db
worldwide weather
When you thought json as a database was a good idea
Whats wrong
Economy system
that is the most useless command i've ever seen
-1
Hi so I am currently working on a command in Discord.py where if you do ".methodss" it will show every single method that has been put into a json file here is a better example: .methodss <--- command Method list method 1 method 2 method 3
I hope that gave you a better view of what im trying to do but its not working also there is NO ERRORS IN THE CMD here is the code
#Add a Method to the json string command
@bot.command()
@commands.has_role('Reseller')
async def addmethod(ctx,api, method):
methods = await get_method_data()
api = methods
methods = {}
methods['Method'] = method
methods['api'] = api
with open("methods.json", "w") as output:
json.dump(methods,output)
await ctx.channel.purge(limit=1)
embed = discord.Embed(title=f'{method} has been added to list', color=0x000000)
await ctx.send(embed=embed)
And then here is the command that will print all of the methods from the Json file
@bot.command()
async def methodss(ctx):
methods = await get_method_data()
method = methods['Method']
em = discord.Embed(title = "B")
em.add_field(name = "Methods", value = method)
await ctx.send(embed = em)
Also here is the "get_method_data" function
async def get_method_data():
with open("methods.json", "r") as f:
methods = json.load(f)
return methods
Please help me find where I messed up in this code thank you so much!!
@final iron something like that should work https://paste.pythondiscord.com/fafotuvuxe.py
go out side is what you have to do

make an rbnb server π§
??
Anime search / Spotify Artist Search / Manga Search / COVID - 19 Updates
whats an rbnb
what did i do wrong??
@fervent fable
whats that for
scroll up sift
google is a thing
a
api related stuff lol
Yes
bnruj
lol
Use APIs is fun
"not working"
whats not working exactly
??
making an api wrapper is more fun
read it
how do i make a command which makes commands for me
Lmao must agree
loll
ITs nhot printing out all the data from the json string
Save in Json the command name and what will it reply
my guy what would an airbnb server even do?
roleplay?
nothing π§
exactly
which command
that would be a lot of on_message events shit lol
But you wanna make custom commands right?
THen you have to
no , i want the command to make commands for me 
π€
What is the difference
That is some real adv shit

wait @slate swan your kakashi sharingan banner put me into magic
You changed your pfp 3 times in a week 
stop going off-topic
its epic ikr
Is there a way to make a bot where i use a command in a different server,
it searched my server and checks if they are in that server,
then send the response at all?
@slate swan It doesn't disable the menu
stalking meπ³
Lol fr fr
any errors?
what
No lol, we are always chatting here so I noticed
LOL
You can't if the bot is not in the same other servers with you
did you try to use the disnake docs examplle though?
send the class in pastebin
Say the bot is in both servers
The just get the channel's ID and send the message there?
anyone has apis i can make a wrapper for?
discord
Manga Search
you didn't wrap the whole api
need to make the async bridge but i dont want toπ©
no plsπ
wow nice
what?
good idea
Yeah its not disabling it
not the point
:V jIHI
!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.
Yeahh do it fast and I will use it for my bot lol
thats what a wrapper means mate
Ik how to do that but I mean say
A premium it checks if you have paid a patronage.
I want It to check if the user running the command in server 1. Is a user that is also found in my server
i should wrap the whole api and make the async bridge but im to lazyπ©
https://paste.pythondiscord.com/aqavicokoz.py @slate swan
you wanna make a wrapper for an api but your lazy
π
async def on_ready():
guild = bot.get_guild(ID_OF_GUILD) # find ID by right clicking on server icon and choosing "copy id" at the bottom
if guild.get_member(ID_OF_MEMBER) is not None: # find ID by right clicking on a user and choosing "copy id" at the bottom
# the member is in the server, do something #
else:
# the member is not in the server, do something #
like this?
not really
You on phone ?
Kinda but on certain commands
no
no
just no
@boreal ravine Not sure if you wanted to see but...
Lmao
π
?
dont make a request on ready and no need for the else
discord doesnt like it when the bot is connecting to the gateway and you make a request
which part isn't working exactly
so it disconnects you
Disconnect
yes
that makes me remember replit
You got angry with your reply 
As I said above it doesn't disable the menu
which line
Which line what
where you disable the view
U have to edit the msg too, did u do that

no?
yes?
on_ready triggers when the bot is fully connected to the gateway
line 42 iirc
still youre making a request discord doesnt like that so it disconnects you from the api
did you even call the method?
Someone request me a good API for Manga Searching please!
How do I keep appending to a list
loops
right but you shouldn't make requests on_ready becuase that's when all the GUILD_CREATE events get dispatched and there's a high chance of getting disconnected
Which method?
hence why people recommend against changing presence in on_ready
ive heard of guild creates but what do they do im not sure
Does it provide Manga?
Not in discord.py on_ready is dispatched when the cache is populated, on_connect is when the bot is fully connected to the gateway
The edit method?
It's a library abstraction
GUILD_CREATE is the dispatch called when your client "detects" a new guild, it can be either your bot was invited to a server OR it happens at startup when discord tells your bot, "hey these are all the servers you're in" and the bot is like "oh okay thanks just saw that"
Idk just check lol
Just did it, it doesn't
I want to add to a list when I execute a command, and I want to keep repeating when I execute the command
but Called when the client is done preparing the data received from Discord. Usually after login is successful and the Client.guilds and co. are filled up.?
I think mangadex has one but doubt they provide all manga pages, you will have to scrape the site most likely
!e
# like this?
x = []
x.append("test")
print(x)
@sick birch :white_check_mark: Your eval job has completed with return code 0.
['test']
ah ic thank you
Basically yea when the cache is populated
ic
what
They do iirc
Yeah but when I execute the command again, I want it to append to the list so the executed code will be ['test', 'test]
I just want it to provide the link where we can read, the description and some basic info
Well yeah then use that
@final iron isn't it obvious already? did you call the disable_select method
Idk how to do that
Hmm k let me have a try
https://animeapi.com/docs.html has good docs ngl
Wanna get vn data too?!
Is it not called calling a function?
thats outside a class
functions inside of classes are called methods
@sick birch do you get what I mean?
Ah
Yeah it will do that by itself
every time you call the command .append gets called and a new element gets added again
I did the anime already, im trying to do the manga
nice
im gonna make a wrapper for that api maybe make it async and actually wrap the whole api like kayle said
!e
x = []
def appendToList:
x.append("test")
appendToList()
appendToList()
appendToList()
@sick birch :x: Your eval job has completed with return code 1.
001 | File "<string>", line 2
002 | def appendToList:
003 | ^
004 | SyntaxError: invalid syntax
Will the list revert back to its original stage?
hmph
parenthesis
i did a dumb
!e
x = []
def appendToList():
x.append("test")
appendToList()
appendToList()
appendToList()
@sick birch :warning: Your eval job has completed with return code 0.
[No output]
methods are like that in ruby lol
lol
Not if you use a bot var
Wdym
Where would I call the disable_select method to disable the menu?
bot = commands.Bot(...)
bot.x = "Hello, world!"
Oh good luck 
thxβ€οΈ
Np 
@client.command()
async def buy(ctx,item):
with open("economy.json","r") as f:
users = json.load(f)
users["bag"] = []
users["bag"].append([x, x]])
with open("economy.json","w") as f:
json.dump(users, f)
this is what I'm trying to do
@commands.Command()
async def cmd(...):
print(ctx.bot.x)
Out:
Hello, world!
@sick birch
Oh you're loading from json?
yeah
you didnt pass the view in the select as i asked to , neither did you call py await self.view.disable_select()
Obligatory but it's highly discouraged using json for this
it's fine
the bot is used on one server
instead of setting users["bag"] = [] just append without resetting it first
if that user doesn't have a bag make one
mmm
I see thank you
THANKS FOR SOLVING THE PROBLEM
I have been trying to figure the problem out for a while
the solution is as simple as I thought
but my knowledge of python is a bit limited, thanks
Thanks. It's getting pretty late and since I'm missing things like these I'll go to sleep
If soemone leaves my server how would i get the bot to delete their information off my Json file?
!d discord.on_member_remove use this event
discord.on_member_join(member)``````py
discord.on_member_remove(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") leaves or joins a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").
This requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be enabled.
it gives you a member object
use its attributes and remove the data just like you added
mlk thank you
I tried deleting the data, but it came back with but i got this error:
in on_member_remove
del users[member.id]
KeyError: (member.Id was here)
the user was not in the json
it is in json that was the thing?
The json held their info
{"Their ID": {"wallet": 0, "bank": 0}}
hmm
why use JSON as a database
don't use JSON as a database lol
yep
Im doing it because after i started using a database i couldnt get any errors from failed commands
im sure there's a way
JSON is definitely not the way you wanna go tho
thats what i was using
what problem are you facing?
Idk cause after i started using it no errors would go through my terminal even though there were errors
i even made it so it would send errors and nothing came through
huh thats weird
thats what i thought
that never happened to me
maybe google it
i did try nothing came up
hmm ill have to try that
hello, iv been trying to work on a discord bot, and am currently facing quite a big problem. im using pycharm and am trying to install the discord module to proceed with my bot, although im not that famailiar with pip, im actually following a guide and when i look at the guide it says to install pip i must do curl https://bootstrap.pypa.io/get-pip.py > get-pip.py altho it doesnt work and says this ERROR: This script does not work on Python 2.7 The minimum supported Python version is 3.6. Please use https://bootstrap.pypa.io/pip/2.7/get-pip.py instead.
so i have been trying to fix this with some friends for around 2 hours
and i have no clue what to do
if anyone can help me that would be much much appriciated
iv been struggling with this for quite a while
My dms are open
I am not using python version 2.7 nor do i have any files related to it
I tried uninstalling but nothing works
@cerulean quest do you have python installed in your computer?
Yup, im using macOS
Yessss
In the terminal?
mac has python 2.7 by default iirc you gotta install python 3.6
Oh that explains it
oh idk about that
i don't think dpy works with python 2.7
Well i also have pycharm 3.10 could i run anything in that?
Bruh this entire time i was running commands in my terminal with version 2.7
Ok, sorry im a little new to programming so i am slow
you sound like you're very new, you shouldn't really be making discord bots right now
its an intermediate library
So i just install 3.6 and then run the pip install discord.py cmd?
learn about OOP and asyncio first
yes just download the latest version of python from python.org
Yeah lol, i know the basics tho im trying to get familiar with pip
Ok, will do
yes
good luck!
Thanks!
I have actually made quite a few programs, my next one is this bot, so thats why i seem kinda low level, never worked on something like this before
Anyway, thanks for all the help!
Cya
How do I reset the cooldown of a certain command? (Nextcord)
!d discord.ext.commands.Command.reset_cooldown
reset_cooldown(ctx)```
Resets the cooldown on this command.
i doubt thereβs any difference since itβs a fork. Just change the names.
get command object
use reset_cooldown method
get context
pass it inside the reset_cooldown's postional arguments
?
hey, can we use slash commands in dissnake? like if we put a slash then our bot should show in the menu and not a prefix"/"
yes
okk
I need the same thing did you get it working?
i figured it out you need it?
hello. I have a command with a button whick works just fine. But when i restart the bot, i have to resend the command in order for the button to work. How can I fetch the message id and if that id exists, then add the button?
just fetch the msg and edit it with a new view
how is it not working?
Nah I figured it out
!d discord.ext.commands.Context.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.
Why to fetch...
doing ctx.command.reset_cooldown(ctx) fixed the issue
you cant get a msg from cache
Just do
msg = ctx.send(...)
await msg.edit(...)
no he said after the bot resets
Hmm, I guess he should also look into persistent views
the heck is that
ic thats easy
mhm
pretty cool
Β―_(γ)_/Β―
okay i am lost. What should i do?
....?
.
from discord.ext import commands
ImportError: cannot import name 'commands' from 'discord.ext' (unknown location)
^^^
Reinstall discord.py
how to fix this shit?
ok
cry about it

Β―_(γ)_/Β―
lmao

discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended nded to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, thenider consider disabling the privileged intents instead.```

enable them on the developer portal
Integrate your service with Discord β whether it's a bot or a game or whatever your wildest imagination can come up with.
How would I get the channel to be a live a counter? I thought a code like this would work
@commands.Cog.listener
async def on_guild_join(self):
channel = self.client.get_channel(ChannelID)
await channel.edit(name=f"Counter: {str(len(self.client.guilds))}")
Do people even read errors now a days.
why is there no guild argument
?
ok
Can command names start with a number?
Sure
Perfect
Yeah
Just use the name kwarg in the decorator
??
no
Async def 3:
You're also missing a set of parenthesis. listener is supposed to be called
That's not possible
but how? and where? i m not able to figure it out
Python doesn't allow you do that
yea
The most descriptive an error can be
@bot.command(aliases=['3'])
async def three(ctx):
pass
that should work, I believe
why. If he actually wants the command name to start with a number he should just use name.
@spring flax
go to the app and go to the bot page of your app, scroll down and toggle intents
Why alias , when the name kwarg exists
ok
Thatβs what I said 
sorry'I didn't read that 
sorry! but i m still not able to find it
cry about it
send screenshot of what you are looking at
Β―_(γ)_/Β―
select the application of the bot you are using which you ran your code and it raised that error
then press Bot on the side
scroll a bit down
and enable these intents
done! thanks buddy
Would repeatedly calling guild.emoji_limit and guild.emojis get me rate-limited? or is it fine since it's not a api call?
iis it possible to make a bot that runs the whole server??
so it could log actions and stuff
why?
oh ok
well i just want a bot for my server but im struggling to code it
damn.
i did but my command prompt aint working
idk why
huh?
go on...
how do i import a module
what is a module π
yo idk what you mean im just gonna try something else
nope.
im slow
Im Trying to make a counter Like a member Count Channel but for the amount of guilds my bot is in, I can get it to send me a message telling me that its in how many servers:
@commands.command()
async def server(self,ctx):
await ctx.channel.send("I'm in " + str(len(self.client.guilds)) + " servers!")
So i tried implementing that to make this code:
@commands.Cog.listener
async def on_guild_join(self):
guild = self.client.get_guild(ID) #idk how im gonna use this
channel = get(self.client.get_all_channels(ID))
await channel.edit(name=f"Counter: {str(len(self.client.guilds))}")
return
i havent been able to work that out
install pip, google how to do it
...
@slash.slash(name="BotInfo", description="Shows Bot Info.")
async def BotInfo(ctx):
embed=discord.Embed(color=0x8400a8, title="PexiBot Invite Link!", description="Join PexiBot server and report bugs!")
components=[[Button(style=ButtonStyle.URL, label="β
Support Server", url="google.com"), Button(style=ButtonStyle.URL, label="π Website", url="google.com")]]
await ctx.send(embed=embed, components=components)
why does this not create a new slash command? the other slash commands i do appears
iirc slash commands take a bit to appear globally
@slash.slash(name="BotInfo", description="Shows Bot Info.")
async def BotInfo(ctx):
embed=discord.Embed(color=0x8400a8, title="PexiBot Invite Link!", description="Join PexiBot server and report bugs!")
components=[[Button(style=ButtonStyle.URL, label="β
Support Server", url="google.com"), Button(style=ButtonStyle.URL, label="π Website", url="google.com")]]
await ctx.send(embed=embed, components=components)
why does this not create a new slash command? the other slash commands i do appears
what is iirc
(if i remember correctly)
Do not bump your messages, not even more than 2 messages have been sent after you sent your first one
how do limit the wlr to only 4 letters including decimal
bump?
You sent it again even though we can clearly see the first one
If someone has an answer for you, they will respond
i set it only one time
oh
bruh, it doesnt even work when i send the command without slash
Anyways end this topic now
Hello!
Hi, do you need help
Yup
import hikari
import lightbulb
bot = lightbulb.BotApp('My Beautiful Token Here',
default_enabled_guilds=(923476093414039584)
)
@bot.listen(hikari.StartedEvent)
async def on_started(event):
print('Bot has started!')
@bot.command
@lightbulb.command('ping', 'Says pong!')
@lightbulb.implements(lightbulb.SlashCommand)
async def ping(ctx):
await ctx.respond('Pong!')
bot.run()
What wrong is that?
No idea how hikari works, sorry
okay
I do know someone who knows his ways with hikari, they are active here aswell so I guess you just gotta wait since I don't want to ping them
): im upset
i am not able to create commands anymore.. sigh
@client.command
async def Inf(ctx):
embed=discord.Embed(color=0x8400a8, title="PexiBot Invite Link!", description="Join PexiBot server and report bugs!")
await ctx.send(
embed=embed,
components=[
Button(style=ButtonStyle.URL, label=":white_check_mark: Support Server", url="https://google.com"),
Button(style=ButtonStyle.URL, label=":globe_with_meridians: Website", url="https://google.com")
],
)
bu i made the command!! ):
Why this doesn't seem to work?
have you got from disnake import Embed?
or discord - same shit
@client.command()
Still got those others.
!pypi dotenv
What is the parameter for options when using a subcommand in slash commands (discord-py-slash-command)?
@slate swan I've been using the system but it's not waterproof. Sometimes if u delete a message it doesn't show up in audit log
I am looking for someone to make a really good bot together and grind dm me know something about database for python as well
!rule 9
@slash.slash(
name="private",
description="Manage a private voice.",
guild_ids=[798251886951399487],
options=[
create_option(
name="create",
description="Create a private voice.",
option_type=1,
required=False
),
create_option(
name="remove",
description="Remove a member.",
option_type=1,
required=False
),
create_option(
name="add",
description="Add a member.",
option_type=1,
required=False,
options=[
create_option(
name="member",
description="Choose the member you want to add.",
option_type=6,
required=True
)
]
),
create_option(
name="transfer",
description="Transfer private voice leadership.",
option_type=1,
required=False
),
create_option(
name="list",
description="List added members.",
option_type=1,
required=False
)
]
)
``` Can anyone help? I'm receiving back: ``create_option() got an unexpected keyword argument 'options'``
what lib is that?
it seems create_option doesn't take an options keyword argument, as the error states
Well of course...
create_option(
name="add",
description="Add a member.",
option_type=1,
required=False,
options=[
create_option(
name="member",
description="Choose the member you want to add.",
option_type=6,
required=True
)
]
),
didn't you mean to put the options outside of the create_option
yeah, you already did
so just remove the second options variable
Wdym?
create_option(
name="add",
description="Add a member.",
option_type=1,
required=False),
create_option(
name="member",
description="Choose the member you want to add.",
option_type=6,
required=True
)
)```
how to reply with member name
something like this
ok
So you're saying not to involve it in the options parameter?
not working
ok
how do i make a command work with replies? ive tried to do
if message.reference:
``` but this brings up the issue of missing arguments
I'm saying that you already have an options param
Eggy it depends how the argument passed through the function is branched off.
it wraps all the create_option's
If your using a command, it should be ctx.author.name
if message.content == "e":
if message.author.id == 499973767846428694:
await message.channel.send("No {author.name} :p")
await message.delete()
if message.author.id, here you used message.author
OOHHH
anyone?
Should it not be await ctx.respond()?
await message.channel.send("No {message.author.name} :p")
yes
Yes.
Yesth.
No.
yes
Because you haven't passed the fstring.
fawk
await message.channel.send(f"No {message.author.name} :p")
error: code coming shortly
How can i check specific a server for a message?
message.guild
Im trying to make a live server counter on how many servers my bot is in but im getting an error
@tasks.loop(seconds = 90) # repeat after every 90 seconds
async def myLoop():
channel = client.get_channel(**ID**)
await channel.edit(name=f"Counter: {str(len(client.guilds))}")
myLoop.start()
Im getting this error please help:
await channel.edit(name=f"Counter: {str(len(client.guilds))}")
AttributeError: 'NoneType' object has no attribute 'edit'
Channel is not defined correctly.
there's no channel with **ID** id
it is a general answer but i need "when a specific user send "hello" on my server, bot will answer" (only my server btw)
you don't have to convert your length to str
The argument should be a discord.TextChannel.id passed as an int
check if the message.guild is the same as your guild
import os
import discord
import time
import datetime
import asyncio
from discord.ext import commands
class Events(commands.Cog):
def __init__(self,client):
self.client = client
@commands.Cog.listener()
async def on_ready(self):
for guild in self.client.guilds:
print(guild.name)
print(guild.me.guild_permissions)
print(
f'{self.client.user} is connected to the following guild:\n'
f'{guild.name}(id: {guild.id}) \n'
)
members = '\n - '.join([member.name for member in guild.members])
print(f'Guild Members:\n - {members}')
@commands.Cog.listener()
async def on_member_join(self, member: discord.member):
if member.guild.id == 804864012184977438 : return
channels = member.guild.channels
for channel in channels:
if ('welcome' in channel.name.lower()) or ('joins' in channel.name.lower()): #or ('testing' in channel.name)
embed=discord.Embed(title=f"Welcome {member.name}", description=f"Thanks for joining {member.guild.name}!")
embed.set_thumbnail(url=member.avatar_url)
assert isinstance(channel, discord.TextChannel)
await channel.send(embed=embed)
@commands.Cog.listener()
async def on_member_remove(self, member: discord.member):
if member.guild.id == 804864012184977438 : return
channels = member.guild.channels
print([channel.name for channel in channels])
for channel in channels:
if ('leave' in channel.name.lower()) or ('goodbye' in channel.name.lower()): #or ('testing' in channel.name):
embed=discord.Embed(title=f"Goodbye, {member.name}", description=f"Bye {member.name} come again soon")
embed.set_thumbnail(url=member.avatar_url)
assert isinstance(channel, discord.TextChannel)
await channel.send(embed=embed)```
or if message.guild.id == blabla
id as integer?
yes
it doesn't matter
if it's a command, you'll take ctx.guild
Depends, do you want it to be executed via an event or via CLI usage in chat box.
i guess it should be event cus no need for send a command for answer
i posted my code
can you please do an example i dont follow sorry
wdym i didn't understand π€¦π»
Thought it was a guild for some reason.
Sure.
channel = client.get_channel(798251886951399487) #this int should be changed to your channel id
Can i add ctx param to on_message() event?
i have a problem when i try to make an client on event and make it on message but the problem is when i make this the rest of the code wont work
Nope, it has to be passed as message
put await bot.process_commands(message)
I did that though?
i want to make message waiter... i.e if a specific user send"hello" wordon specific a server , bot will dm me.
You did client.get_channel(**ID**)
K
Why does on_message make my commands stop working?
Overriding the default provided on_message forbids any extra commands from running. To fix this, add a bot.process_commands(message) line at the end of your on_message. For example:
@bot.event
async def on_message(message):
# do some extra stuff here
await bot.process_commands(message)```
Alternatively, you can place your on_message logic into a listener. In this setup, you should not manually call bot.process_commands(). This also allows you to do multiple things asynchronously in response to a message. Example:
```py
@bot.listen('on_message')
async def whatever_you_want_to_call_it(message):
# do stuff here
# do not process commands here
``` @slate swan
channel = client.get_channel(934725310027530260)
why do you need ctx for that
no i did it i just didnt add to my text
you can
but it will be a message object
not context
Ok, so what's the error?
thanks i will try now
await ctx.send() , lol
K then
you said you want the bot to DM you
Unhandled exception in internal background task 'myLoop'.
Traceback (most recent call last):
File "C:\Users\OzLaptops\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\nextcord\ext\tasks\__init__.py", line 168, in _loop
await self.coro(*args, **kwargs)
File "c:\Users\OzLaptops\OneDrive\Desktop\TTS python\bot.py", line 29, in myLoop
await channel.edit(name=f"Counter: {str(len(client.guilds))}")
AttributeError: 'NoneType' object has no attribute 'edit'
if i read it right
Yes it was for example
you might want to wait till the bot gets ready in the task
you want the channel of the message?
error: code after slowmo
You are trying to edit the channel's name?
!d discord.ext.commands.Bot.wait_until_ready include this in your task's first line
await wait_until_ready()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits until the clientβs internal cache is all ready.
No, on server's all channels
yes
import os
import discord
import time
import datetime
import asyncio
from discord.ext import commands
class Events(commands.Cog):
def __init__(self,client):
self.client = client
@commands.Cog.listener()
async def on_ready(self):
for guild in self.client.guilds:
print(guild.name)
print(guild.me.guild_permissions)
print(
f'{self.client.user} is connected to the following guild:\n'
f'{guild.name}(id: {guild.id}) \n'
)
members = '\n - '.join([member.name for member in guild.members])
print(f'Guild Members:\n - {members}')
@commands.Cog.listener()
async def on_member_join(self, member: discord.member):
if member.guild.id == 804864012184977438 : return
channels = member.guild.channels
for channel in channels:
if ('welcome' in channel.name.lower()) or ('joins' in channel.name.lower()): #or ('testing' in channel.name)
embed=discord.Embed(title=f"Welcome {member.name}", description=f"Thanks for joining {member.guild.name}!")
embed.set_thumbnail(url=member.avatar_url)
assert isinstance(channel, discord.TextChannel)
await channel.send(embed=embed)
@commands.Cog.listener()
async def on_member_remove(self, member: discord.member):
if member.guild.id == 804864012184977438 : return
channels = member.guild.channels
print([channel.name for channel in channels])
for channel in channels:
if ('leave' in channel.name.lower()) or ('goodbye' in channel.name.lower()): #or ('testing' in channel.name):
embed=discord.Embed(title=f"Goodbye, {member.name}", description=f"Bye {member.name} come again soon")
embed.set_thumbnail(url=member.avatar_url)
assert isinstance(channel, discord.TextChannel)
await channel.send(embed=embed)```
what are you using assert for
if you want to get the message channel, do
@bot.event
async def on_message(message):
await message.channel.send(**kwargs)
If you want to get the message guild, do message.guild
!d discord.Message
class discord.Message```
Represents a message from Discord.
x == y Checks if two messages are equal.
x != y Checks if two messages are not equal.
hash(x) Returns the messageβs hash.
hello,
anyone know how to get message object using message id, discord py ?
@royal oar
hmmm... it sends message?
For what do you want it?
i wanna get a old msg n delete it
without saveing obj for var
@bot.event
async def on_message(message):
await message.channel.send("test")
this sends test in message channel
idk someone suggusted to put it in there
cus i don't want to send to channel, i want to send dm to me
in a command?
yh
for what
Yea
Are you using cogs?
if i send ex: delete <msgid>
are you in the server of the message being sent?
Yes
I am yea but its not in the cog file cause i couldnt get it to work there either
tell him to put wait until ready cuz I'm clearly getting ignored π’
read it
u can fetch the user client.fetch_user
@Bot.event
async def on_message(message)
member = message.guild.get_member(put your user ID here)
await member.send("message")
not really needed
OH LOL.
ok idk, can i fetch the msg obj ?
#help-donut message
@echo wasp
Ah thx
Run your myLoop.start() in the on_ready() event
use get or fetch
meaning the isinstance is not true
@bot.command()
async def delete(ctx, message : disnake.Message):
await message.delete()
you can pass in message ID/message link for the message argument
i wasnt ignoring you i was reading the thing you sent
...
!d discord.Message.delete
await delete(*, delay=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Deletes the message.
Your own messages could be deleted without any proper permissions. However to delete other peopleβs messages, you need the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission.
Changed in version 1.1: Added the new `delay` keyword-only parameter.
hmmm ok how do i fix that
use if statements
example for that stuff
can i make bot reply for another's msg
Yw.
if isinstance(channel, discord.TextChannel)
cuz on_ready sucks
Lmao
it launches multiple times
w-
i use it and it goes once
I do not remember that.
!d discord.Message.reply
await reply(content=None, **kwargs)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
A shortcut method to [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") to reply to the [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message").
New in version 1.6.
not to mention if you do api calls in/directly after on_ready, the api will hate that
oof
π¦
the biggest chance of getting ratelimited is in on_ready
your bot can get disconnected from the discord's API if you do API calls directly on_ready
I remember spamming emojis so much I got 1 hour banned from API lmao.
ahh
and if you run the code locally, you will see in the terminal that what you put in on_ready happens like daily
hmm
yeah, on_ready is called multiple times
@cold sonnet Also your code you gave me doesn't work btw.
@royal oar what did you want to do on_ready
what's the outcome of your code
launch a task
what's the task?
just launch it before the bot runs and put wait_until_ready
The output of my task was just to keep track on how many servers my bots on
hmm



