#discord-bots
1 messages · Page 954 of 1
ahh simple
lmao as a joke in my smol server
whatd u do name it rick roll vc
nah
i just named the vc "dont join 🗿 "
lol
i can do anyting thats funny
(not crimes or something that hurts others) 😇
true thing
yui?
?
whats her name
while True:
print("hello world") # whatever u want to loop forever
@jolly karma
they usually don't last to long, just wait it out
i need some help, lets say this is my code, so my question is if i call the function, does it automatically go through the function and then come back to the code below?
embed = discord.Embed(title="test")
await ctx.send(embed=embed)
async def function()
embed2 = discord.Embed(title="test2")
await ctx.send(embed=embed2)
but like……how do i avoid this in the future
let me see your code
dont spam 👍🏿
wait can you explain better? your wording is confusing my brain
use anti spam feature
ok uh, the code either does 2 things:
it sends the first embed and then calls the function and doesnt send the second embed
OR
it sends the first embed, then calls the function and then sends the second embed too
which one is it?
why don't you just test it..
yea im actually testing it rn lol
import discord
from discord.ext import commands
import time
from keep_alive import keep_alive
bot = commands.Bot(command_prefix="!", intents=discord.Intents.default())
@bot.event
async def on_ready():
print("online uwu")
await bot.change_presence(activity=discord.Game(name="Altera"))
channel = bot.get_channel(959704295903748137)
if not channel:
return
try:
await channel.connect()
vc.play(discord.FFmpegPCMAudio(executable="C:/ffmpeg/bin/ffmpeg.exe", source="./rick_roll.mp3"))
except discord.Forbidden:
print("Gimme perms")
keep_alive()
bot.run
``` @slate swan its not working ;-;
ok it worked
don't send more than 16-17 requests per second (no more than 10,000 requests every 10 minutes)
good
bot.run('TOKEN HERE')
don't forget to add the token when you try running it
i have that but didnt send coz it has my token there ;-;
ah ok good
error?
wait i edited a lil bit its loading dependecies
ok
btw can i do something like
if message.author == client.”Username”:
await message.channel.send(‘some text’)
why would you wanna do that
no specific reason. I just want to know.
also how can i use my bot and test it if it never will read my messages
I mean yeah kinda, you probaby need to specify the discord id of user but yes
he doesnt
wait till you're un-ratelimited
can I see your previous code?
that wont work
no im saying in discord. My messages will never be read by it. It said that your messages wont affect it when i was creating new bot
he needs to change some stuff
if message.author == user#0001:
await message.channel.send(‘some text’)
he is ratelimited
should compare ids
theirs no such thing as being unratelimited
I meant when he is not ratelimited anymore
send a ss
pip install PyNaCl```
in the replit shell
oh they forgot to install it
its just saying
Replit: Updating package configuration
and ugh, dont do stuff in on_ready
i did nothing 😭
hell yeah that takes time
replit smh
@commands.command()
async def timer(self, ctx, time_h, time_m, time_s):
time_h = int(time_h)
time_m = int(time_m)
time_s = int(time_s)
now = datetime.timezone.utc
future = now + datetime.timedelta(hours=time_h, minutes=time_m, seconds=time_s)
await discord.utils.sleep_until(future)
await ctx.send(f"{ctx.author.mention} your time is up")
Error:
TypeError: unsupported operand type(s) for +: 'datetime.timezone' and 'datetime.timedelta'```
i love this gif
now thats a lie
ikr the cat is soo cute
i literally did nothing ;-;
the error says it all
breh dont know python much
yeah but i can't understand the fix
like how do i fix it
?
async def on_ready():
print("online uwu")
await bot.change_presence(activity=discord.Game(name="Altera"))
channel = bot.get_channel(959704295903748137)
if not channel:
return
try:
await channel.connect()
nice nothing u got here
;-;
just make it print online, and then make a seperate command for it
you have the sum of those 2 objects
thats how you get blocked from discord api
no...
more like disconnected
okay but i want it to start playing the mp3 as soon as the bot starts without commands
use a task
i want the sum of values so that i can sleep_until() to that timestamp and and ping the author
im pretty sure i got blocked, cause whenever i started my bot there was a cloudflare error saying ive been blocked/banned
it would be better to check if your bot is in the channel, playing or not, every 6 hours or so, so use a task
I almost thought this code was a example from ashley
Just glanced at the channel
no thanks, I empathize on_ready
yall really dissing ash💀
maybe I'm just alive for this purpose now 😔
but you have a purpose 
It's to add uwu to stuff
but I dont do things in on_ready 😔
anyways i think im just gonna dip from the chat all i see is on ready requests and attr errors and other cursed stuff
purpur
bai
hogrider hq do you copy????
okay but my repl is literally updating packages from last 5 mins
refresh
HOG RIDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDAAAAAAAAAAAAAAA
we copy
Refresh or don't use replit
Don't use replit for hosting discord bots
its repl.it ;-;
or just code local if you are going to self-host it in the end
i am just tesing my bot there;-;
fuck wronng hog
roger that sergeant
Looks like a bear with a coat
.....? repl.it works on a webpage
🐗
Lmao hedgehog
yea
refresh the page then
we need a hog strike on c2 a1 do you copy?
roger that hogrider hq 🐗
Back to messing with flask and fastapi
why both
hog hq over and out
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
yea it worked but how do i run my code ;-; its putting it in an endless loop
🐗
To see it's differences
stop going offtopic for fucks sake
dont do stuff in on_ready,,,
And see what i prefer
flask is clean ngl especially .route deco and templates and other libs like flask_wtf
How about fastapi
Must have something good if it's named fastapi
no i meant its just loading the modules and looping the loading process
😔
thats replit for you

it really depends its just like
django vs flask vs fastapi
i personally like flask more
Okay
from discord.ext import tasks, commands
uwu_bot = commands.Bot(command_prefix="whatever", intents=discord.Intents.default())
@uwu_bot.event
async def on_ready():
print("online")
@tasks.loop(hours=3)
async def music_task():
await uwu_bot.wait_until_ready()
channel = uwu_bot.get_channel(959704295903748137)
if not channel:
return
try:
await channel.connect()
vc.play(discord.FFmpegPCMAudio(executable="C:/ffmpeg/bin/ffmpeg.exe", source="./rick_roll.mp3"))
except discord.Forbidden:
print("Gimme perms")
music_task.start()
uwu_bot.run()
My next problem after learning flask is how to publicly host a API
I have a vps but don't know how to do that shit for now
well done but it could be better
good luck on that
I'm not going to write it all out 😔 I just copy pasted of what was done in onready to a task, plus vc is undefined
Any tips 

not really
anyways goodnight its 3am and im gonna go to sleep
Good luck sleeping enough
good nighto, have a good sleep!
dream about me uwu
3hours
Don't let the uwu monsters catch you
only thing im thinking about is rins models😔
ugh
Jealousy 
better luck next time 
avatar.url
It's avatar.url
Fuck
slow
I defined member still not working help pls guyz
not the problem.
the problem is the class doesnt have that attr hence why we gave avatar with a url attr since avatar returns an asset iirc
the problem is replit D_D
nah
yup
Imagine thinking about code everyday all the time, seems like hell
It's that or uwu
Always think about rins models
Ashley comes with the uwu package
what gets me through the day sometimes i cant sleep because of this question and rewrite i have in my mind so i get up turn on my pc again and rewrite the project and sleep well
the bot probably got disconnected from the gateway
theyre so good right
I dont uwu irl 😔 ||much||
- the bot went offline
- your internet is shit
maybe you didn't defer the interaction.
you were seeing it 24 hours a day?
and the bot never gets offline as soon as its disconnected
have you considered making the view persistent?
Sacrifice social life for speed
reason im an antisocial😔
Time to eat hard water
a view bound to your bot
quite cool
does anyone know how long it takes for repl.it to unblock u from website or is it just random
around 4 hours ig
GOD DAMN
at least that was for me
try kill 1 in the shell
what does is do
it will steal all the data from your computer it resets the ip
oh ok
no?
it did that for me idk
it depends on the api and you could just change your ip because youre just being ratelimited by cloudfare to your ip
oh damn it worked thanks
i think ash hates me for correcting her all day😭
yeah, started making me dislike you now
what website u use?
i use vsc not an online editor
i said the something and you just said the same thing
im a good person trust me
doubt
o
😔
only person i correct to make them hate me is water_gazes because hes my bro😔
whats the import for utils.util
What's that
...?
The slash command is not showing up
I mean, how do I install it? I am confused
It takes upto 2 hours to show
WHAT
Yeah
Show yr requirements.txt
Okay
But in my file it even shows it like this btw
And when I do /randomnumber it doesn’t do anything
Okay
matplotlib==3.5.1
matplotlib-inline==0.1.3
mpmath==1.2.1
numpy==1.22.0
py==1.11.0
requests==2.27.1
discord==1.7.3
discord.py==1.7.3
aiohttp==3.7.4
async-timeout==3.0.1
discordmongopy==0.3.0
motor==2.5.1
pymongo==3.12.0
python-utils==3.1.0
beautifulsoup4==4.10.0
lxml==4.8.0
wavelink==1.2.4
buttons==0.1.9
.....?
!pypi utils
!d utils
can someone post an example of sending a simple dm
I get it
@junior verge what module is that
await bot.get_user(id).send()
async def cmd(ctx):
try:
await ctx.author.send("dm message")
except discord.Forbidden:
return
thats it?
Still says this
Which module...
I am not sure actually
looks like a menudocs tutorial?
u forgot to copy his utils folder
Why do u even want to ratelimit the bot?
Yeah but still do I import something or?
What are you doing lmao
And make replit worse for other people who tryna host their bots on it without getting ratelimited? Not good
lmao
hey i found an opensource discord.py based bot, and while i'm decently skilled with python i cant for the life of me get this working
anyone have tons of time to kill and willing to utterly waste it with me pls?
Ashley is getting bored 👀
no thanks, I'm sick
so doing any logical stuffs is way out of my head
But once I made a slash command and it showed up in 1 minute
well...if you really want to get ratelimited make api requests in a while loop or better use replit
60 approx
60 HOURS
I am using replit lol
minutes my bad
oh lol
Oh few
all fun and games until you get perma banned
:c
..
what is the issue
Discord likes you
guy made it for himself and then just posted it bc why not
it calls on alot of directories and .json files that simply dont exist
also a module that pip cant download
Probably shouldn't copy it as it's probably outdated and not maintained
eh, ig
ty lol
What's it github?
i would learn python and actually become competent at this but python is the worst language to learn rn
yep
Curious on what the hell you're copying
replit so idrc
Why
why what
Why is python the worst language to learn
this is gonna be a paragraph of typing so i'm not afk, just typing this out
I swear it doesnt, I literally put my phone away, started eating, my watch vibrated, and I got a notification from my bot, saying uwu, uwu backfiring 😔
Smart watch
Lmao
actually no im too lazy to fully type this out
too smart smh
Imagine checking your smart watch and seeing uwu
At that point i'd think it was hacked
tldr; interpreted, inheritance, ultra high level, dosent actually teach you shit about base level computing, every school in america is teaching python rn the market is gonna be so saturated in 5 years omfg
lmao

Why do you want to clone that github
dont rlly want to clone it just need a similar product
gonna setup a banking system
Which is what
So just need a basic understanding of how to make a bot and an understanding of a database
should i just learn in js bc discord.py is dead?
It is not dead
its not dead
It is quite alive
still
wasnt it deprecated
no
not very true, interpreted does make it a bit slow but doesnt make it low level then you say ultra high level but then say python doesn't teach you shit about base computing when its one of the top languages used for general purpose which allot of companies use i.e google
It became unmaintained then remaintained
In a span of 6 months
meta uses it too 😔
you mean Facebook
yes
😳
well....facebook is owned by meta, so same thing
its used by allot of companies but people say python is slow because its interpreted when its not really even a bad thing while in a compiled language you encounter an error and everything crashes
Is a lot actually spelled allot
and its not even slow its slower than other langs but you cant even feel the difference
Doesnt make much difference tbh
allot means to assign
from disnake.ext import components
disnake.ext.commands.errors.ExtensionFailed: Extension 'slashCommands.test' raised an error: ImportError: cannot import name 'components' from 'disnake.ext' (unknown location)
i need to use @components.component_listener()
anyways im going to sleep goodnight!
a lot and allot are different s.m.h.
bye again
thats not a thing
bye
Okimii just wakes up in the middle of sleeping if he feels the force is unbalanced here
yes i feel the cap in this channel
The Force 😔
everytime i feel that negative force i come here and im never surprised
Just springs back to awake mode
Okimii seems like that kid whom is always online
i am
You just gotta know the secret phrase
.
i have no life no friends only thing i do is procrastinate 
do you guys even go outside-
only when i have to go to school
I haven't been outside in a couple of weeks now
Well i should really say months
Atleast it got decreased by a month
4 months and 8 days I mean
I haven't touched grass in over 2 years
who would assume that
I did
First thing to pop in my head
you don't need to fetch a guild
They asleep
all guilds are cached on startup
I utilize this time frame to talk normally
I just wanted the bot to get ratelimited
shes just trying to make unnecessary requests
I'ma go eat crisps
but yes all guilds get cached when the GUILD_CREATE gateway event is dispatched
inarguable
btw messages get logged
its fine
😉
with
define didnt work
Defer the commad.
!d discord.InteractionResponse.defer
await defer(*, ephemeral=False, thinking=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Defers the interaction response.
This is typically used when the interaction is acknowledged and a secondary action will be done later.
This is only supported with the following interaction types...
how can i make the embed's color the user's top role color?
show full error
show full error!!!
that's the full error 🗿
n
that's all, stop ghost pinging me
ok
Hey @spice basalt!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
member.color?
member might be None
..
ah
yes so the error would be attributeerror: 'Nonetype' object has no attribute 'color'
how do u get the slas commands in dpy 2.0
Null check member
you are just repeating what the previous person said and the error 💀
1st u didnt show the full error
are you stupid
but if i use member = member or ctx.author, it would say this instead of "you are"
I would recommend a gaurd clause instead of the or statement
uh it didn't in the other screenshot but ok
why to use this
wait ill share what i use
I just feel it's better than the or statement tbh
and what do i do with that
async def di(self , ctx , user: disnake.Member=None):
user = ctx.author if not user else user
wouldn't that change "you are" to "member.name is"?
yes
Maybe make a string instead
by that you mean?
name= ""
if member == None:
name = "You are"
else:
#name = member.displayname
Some thing like that
Oh yeah that's litterally what you did
?
sparky what are you trying to do
Helping you :)
The color thing could be done using the same if statement
helping me how
member = member or "You are"
Stupid way of doing it but
if member == None:
color=ctx.author.color
else:
could be done better, why not compare entities and not values?
Hm
i'll try that
!e
print(0 == False, 0 is False)
@slate swan :white_check_mark: Your eval job has completed with return code 0.
001 | <string>:1: SyntaxWarning: "is" with a literal. Did you mean "=="?
002 | True False
in this case member can be literal to the NoneType class so just compare entities
wait no
that would make the color the author's color and the author's color only
nah
it won't change to someone else's color if you mention someone else
only if the condition is true
ah
just use the member variable?
yes
the variable as the one that can have the argument or the author
anyone know how to do this? im trying to make it where after u set the transactionchannel every time you run the test command it sends to the transactionschannel
if you want to make it per user just use a db and store the channel id
its for each server
its like that. once i set it everytime i run the command regardless what channel i do it in it will always send it to the transaction channel
if i ran the command in general it would just send it to the transaction channel
and yes ik i could just do channel = bot.get_channel(ID) but im trying to sell it and give away so i dont wanna be putting id's
i want it to be set to what they want
It says arrow is not defined, any ideas on how to define it?py bot_ping = (arrow.utcnow() - ctx.message.created_at).total_seconds() * 1000
Uh
Are you perhaps wanting datetime.utcnow()?
Also you could just use the latency attribute from bot
!d discord.ext.commands.Bot.latency
property latency```
Measures latency between a HEARTBEAT and a HEARTBEAT\_ACK in seconds.
This could be referred to as the Discord WebSocket protocol latency.
i tried that
Did you perhaps forget to import datetime
Also what the fuck is arrow
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: can't subtract offset-naive and offset-aware datetimes <- thats using datetime
Like the error says, datetime.utcnow() alone is not timezone aware, you need to do datetime.now(timezone.utc)
You could then subtract using created_at
It's datetime.timezone.utc
A lot of errors when you could just use the latency attribute
i know but im trying to make an advanced one
How about try to import timezone
from datetime import timezone
okay
fixed it, thanks for the help 💜
how can i make a command where people can upload pic with text
like, ?add Test (and a pic/file)
it will sent a embed where description will be Test and at down image/file.
anyone
I'm so damn confused
Are you telling yourself
That message has a embeds attribute
@slash.slash(description='Setup Tickets')
async def ticketsetup(ctx, channel: discord.TextChannel):
ticket = discord.Embed(title='Tickets', description=f'Have any problems?\n\n If you are having problems in SFL please create a ticket below so our moderation team can assist you.\n\n **Reminders:**\n > • Troll tickets will not be tolerated, doing so could get you Muted, Kicked and possibly banned.\n > • Disrespecting staff will get you Muted and possibly banned as we are trying our best to assist you.')
ticket.set_thumbnail(url=f"{ctx.guild.icon_url}")
ticket.set_footer(icon_url = bot.user.avatar_url, text='{}'.format(ctx.bot.user))
components = [
Select(
placeholder = 'SelectMenu',
options = [
SelectOption(label="SelectMenu1", value="value1"),
SelectOption(label="SelectMenu2", value="value2"),
SelectOption(label="SelectMenu3", value="value3"),
SelectOption(label = "SelectMenu4", value = "value4"),
SelectOption(label="SelectMenu5", value="value5"),
SelectOption(label="SelectMenu6", value="value6"),
SelectOption(label = "SelectMenu7", value = "value7"),
SelectOption(label = "SelectMenu8", value = "value8")
])]
await channel.send(embed=ticket)``` im tryna figure our how to add the selectoption to the embed
Oh i thought there was a yerlikaya imposter there
I've never tried to use an image as a argument but i think you can check using ctx.message.attachments
whats error ??
You can also just make the user send the image link
!indent
Indentation
Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.
Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.
Example
def foo():
bar = 'baz' # indented one level
if bar == 'baz':
print('ham') # indented two levels
return bar # indented one level
The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.
Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines
More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation
how to fix that ?
@somber sky
I agree, the amount of pride complexity certain people have is just way too much to say about their character ngl
why is image typehinted as a Message object?
you dont need no parameters for an attachment input
@slash.slash(description='Setup Tickets')
async def ticketsetup(ctx, channel: discord.TextChannel):
ticket = discord.Embed(title='Tickets', description=f'Have any problems?\n\n If you are having problems in SFL please create a ticket below so our moderation team can assist you.\n\n **Reminders:**\n > • Troll tickets will not be tolerated, doing so could get you Muted, Kicked and possibly banned.\n > • Disrespecting staff will get you Muted and possibly banned as we are trying our best to assist you.')
ticket.set_thumbnail(url=f"{ctx.guild.icon_url}")
ticket.set_footer(icon_url = bot.user.avatar_url, text='{}'.format(ctx.bot.user))
#how do i add this to the embed?
components = [
Select(
placeholder = 'SelectMenu',
options = [
SelectOption(label="SelectMenu1", value="value1"),
SelectOption(label="SelectMenu2", value="value2"),
SelectOption(label="SelectMenu3", value="value3"),
SelectOption(label = "SelectMenu4", value = "value4"),
SelectOption(label="SelectMenu5", value="value5"),
SelectOption(label="SelectMenu6", value="value6"),
SelectOption(label = "SelectMenu7", value = "value7"),
SelectOption(label = "SelectMenu8", value = "value8")
])]
await channel.send(embed=ticket)```
what if i use this type
yeah, the first ones to act up like they know too much and the last ones to even know what etiquettes are 😔
huh? i mean in the parameter , and you cant attach files like that in an embed
how can user's files will be embed ?
i am confused
one of my friend suggested me those lines
!d nextcord.Embed.set_image
set_image(*, url)```
Sets the image for the embed content.
This function returns the class instance to allow for fluent-style chaining.
Changed in version 1.4: Passing [`Empty`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.Embed.Empty "nextcord.Embed.Empty") removes the image.
sad to see disnake is still better than nextcord
nice
i still didnt understood
..
you dont understand him/her
he wants to send a file in a embed
or she
make/get an instance of an Embed object and use the set_image method on it and do
embedins.set_image(url="attachment://uwu.png")
make sure that embed's set_image in nextcord does not support full paths and need to be in the same dir
did you broke discord formatting? D_D
seems like it, phone and discord dont go together much
an image is also a file
yes but a zipped file isnt.
who talked about zips in the first place?
no one, but assuming hes trying to attach a file im guessing its not a image xd
@slate swan
its a png
plus its being used in a file kwarg in the embed constructor
which isnt a thing
then again the path is not a string
does anyone know how to make it where a certain person can run the command
like the id
just make a decorator or use conditionals inside the command
def validate():
async def predicate(ctx):
if ctx.author.id in (id1, id2):
await ctx.send
return True
return False
commands.check(predicate)
@validate
because its sending the Cog
imagine naming a class and a method with the same name
is that the issue?
why imagine when you can do it
nope, that is how you should write python code
the class, and the method are anmed the same so it wont work
the issue with this is that you don't know python D_D
if i was a professional python expert i would never come here to ask help
if u dont want to help then stay quiet.
can we not
yup but basic python and OOP knowledge is required to use d.py or any OOP based package
please?
aight sure
nice
so
name your cog something else or just capitalize the first letter, after that, tell
thats not the issue! dont worry i got it
@slate swan can u now tell me how can i sent a image with this
set_image(*, url)```
Sets the image for the embed content.
This function returns the class instance to allow for fluent-style chaining.
user uploaded image into the embed
image/file/link
Use set_image
wut, if you knew the issue, why did you ask
i didnt knew
an asterisk is used to define tgat the next parameters would be keyword arguments
i was was rechecking the whole code and got it
!kwargs
*args and **kwargs
These special parameters allow functions to take arbitrary amounts of positional and keyword arguments. The names args and kwargs are purely convention, and could be named any other valid variable name. The special functionality comes from the single and double asterisks (*). If both are used in a function signature, *args must appear before **kwargs.
Single asterisk
*args will ingest an arbitrary amount of positional arguments, and store it in a tuple. If there are parameters after *args in the parameter list with no default value, they will become required keyword arguments by default.
Double asterisk
**kwargs will ingest an arbitrary amount of keyword arguments, and store it in a dictionary. There can be no additional parameters after **kwargs in the parameter list.
Use cases
• Decorators (see !tags decorators)
• Inheritance (overriding methods)
• Future proofing (in the case of the first two bullet points, if the parameters change, your code won't break)
• Flexibility (writing functions that behave like dict() or print())
See !tags positional-keyword for information about positional and keyword arguments
bro howcome whenever i add a new slash command to my bot i have to re invite him to the server or it takes like 3 hours just for the command to go through
set the guild id kwarg in the decorator
How do I make the message delete function error if there are not enough messages in the channel?
async def create_db_pool():
bot.db = await asyncpg.create_pool(database=catchydb,user="postgres", password="test")
print('Connected to db')
bot.loop.create_task(create_db_pool())
022-04-04T11:43:36.677830+00:00 app[worker.1]: bot.loop.create_task(create_db_pool())
2022-04-04T11:43:36.677844+00:00 app[worker.1]: AttributeError: 'Command' object has no attribute 'loop'```
?
where did you define bot?
Seems like u have a command named bot
how can i make it so that the error message for commands is displayeed differently on the console?
how do i define errorclass, i want to make a custom error handlerer
anyone know how to urlopen in urllib3?
cry about it
how can i make the data in the image neat here code ```py
async def open_account(user):
users = await get_bank_data()
if str(user.id) in users:
return False
else:
users[str(user.id)] = {}
users[str(user.id)]["Wallet"] = 0
users[str(user.id)]["Bank"] = 0
with open("bank.json", 'w') as f:
json.dump(users, f, indent=4)
return True```
em.set_image(url="urltoimage")
rude much?
Custom exceptions should be derived from Exception, but you can probably also subclass one of the discord exceptions
whats bot.session?
Probably a bot var that's value is aiohttp
donut asked in #async-and-concurrency too if you want to add onto there
Any help on how to use an API? I tried looking online but none of the tutorials seem to be what I'm looking for
I'm trying to make a command that gives you a random fact
Thx!
note that lib reads from a premade text file
no issues with blocking requests at least
It says it didn't find a module named "randfacts"
pip install randfacts
It says it downloaded it, sorry for my stupidity but what do I do now
Import the module
How much facts do they have
I have no clue
..
Wym by host it
I did this, then I got the problem of it saying it didn't find it
Then I used this
Try importing other versions
how :D

pip install randfacts==0.14.0
@rocky orchid
👍 testing

persistent views have to be created and added to the bot on start up using Client.add_view(), and your buttons need to have a custom_id set in the decorator too
File "main.py", line 3, in <module>
import randfacts
File "/home/runner/CaringWrongCryptos/venv/lib/python3.8/site-packages/randfacts/__init__.py", line 46, in <module>
from randfacts.randfacts import get_fact, safe_facts, unsafe_facts, all_facts
File "/home/runner/CaringWrongCryptos/venv/lib/python3.8/site-packages/randfacts/randfacts.py", line 7, in <module>
with open(os.path.join(dir_path, 'safe.txt'), encoding='utf-8') as f:
FileNotFoundError: [Errno 2] No such file or directory: '/home/runner/.cache/pip/pool/c5/77/41/safe.txt'```
I'm doing this in replit
Maybe venv
Needed
theres an example on the repo
https://github.com/Rapptz/discord.py/blob/master/examples/views/persistent.py
explain
I think he wants his bot to respond even if he rehost it or restarted the bot or something like this
yeah thats why you set up a persistent view
Anyone tell him how to create a virtual environment pls
Replit has ephemeral file system maybe that's why
:3
Why are yall even using replit for bots
i dunno
Youtube?
yes
Oh
:>
Setup normal development environment
Do u have a pc?
Oh i see
Like vsc or pycharm
@rocky orchid do u have pc
mac
Good enough
You can install vsc that's for sure
yea i got it installed i was just trying things in replit
Why not try things in vsc lol
can anyone help me
Sure
heroku not working
Hello, This is giving me errors like function has no attribute to id, how do I fix this? https://srcb.in/pjT80hl6Ja
Cool pastebin
Anyone have an example of slash command from 2.0
I can't figure it out with all this tree stuff
Ok, but that is not important
im guessing you're using a fork of dpy right
my phone loads documentation so slowly :(
but it seems disnake should have the message content intent too
anyone have an example of slash commands in discord.py 2.0
It would be interaction.send
why dont i just link the same example from the disnake repo
I think
response works too, the issue is that dpy master flipped the button parameters so it doesnt match disnake's parameter order
What's RecursionError: maximum recursion depth exceeded in comparison?
no idea why I am getting that error
it means your function called itself 1000 times
wth
async def set_build(ctx : commands.Context, gun_name : str, msg : disnake.Message):
async with bot.db.execute("SELECT url FROM builds WHERE gun = ?", (gun_name,)) as cursor:
result = await cursor.fetchone()
if not result:
author = msg.author.id
image = msg.attachments[0].url
await bot.db.execute("INSERT INTO builds (gun, url, author_id) VALUES(?, ?, ?)", (gun_name, image, author,))
await bot.db.commit()
embed = Embed(f'Set a build for {gun_name}')
return await ctx.send(embed=embed)
else:
e = ErrorEmbed('That build is already set.')
await ctx.send(embed=e)
@bot.command()
async def setbuild(ctx, gun_name : str, message : disnake.Message):
await setbuild(ctx, gun_name, message)
why?
you called your command instead of your function
probably a good idea to give them more distinct names
whoops lol
or actually combine them into one
the function and command?
if your other commands need setbuild, you can call the command as if it was a regular function
considering the two have the same signature that is
I changed the command name
uhh you probably dont want to create another bot class
you should store that persistent_views_added = False as a bot var in your main file (also consider a more descriptive name), then check that bot var in your cog's init method and add the view there
that way if you reload the cog, it doesnt forget that the view is already added
oh wait, that also means updating your view wont work...
hmm maybe a better way would be storing your persistent view then calling View.stop() during cog_unload
Just override the start method of the bot and add the views there, it's called only once so you don't have to worry about duplicate views
how
you wouldnt be able to reload it in your cog and you might find it less organized, but that would work
what ?
Simple OOP inheritance
class MyBot(commands.Bot):
...
async def start(*args, **kwargs):
# add views here
...
await super().start(*args, **kwargs)```
are you saying to me ?
@slate swan better subclass the bot as on_ready may be called multiple times and having all those "view1_added" variables is not good at all
class HelpDropdown(discord.ui.Select):
def __init__(self, help_command: "MyHelpCommand", options: list[discord.SelectOption]):
super().__init__(placeholder="Choose a category", min_values=1, max_values=1, options=options)
self.help_command = help_command
async def callback(self, interaction):
embed = await self.help_command.cog_help_embed(self.help_command.context.bot.get_cog(self.values[0]))
await interaction.response.edit_message(embed=embed)
class HelpView(discord.ui.View):
def __init__(self, help_command: "MyHelpCommand", options: list[discord.SelectOption], timeout: Optional[float] = 120.0):
super().__init__(timeout=timeout)
self.add_item(HelpDropdown(help_command, options))
self.help_command = help_command
async def interaction_check(self, interaction) -> bool:
return self.help_command.context.author == interaction.user
class MyHelpCommand(commands.MinimalHelpCommand):
def get_command_signature(self, command):
return f'{self.context.clean_prefix}{command.qualified_name} {command.signature}'
async def cog_select_options(self) -> list[discord.SelectOption]:
options: list[discord.SelectOption] = []
for cog, command_set in self.get_bot_mapping().items():
filtered = await self.filter_commands(command_set, sort=True)
if not filtered:
continue
options.append(discord.SelectOption(
label=cog.qualified_name if cog else "Misc",
description=cog.description[:100] if cog and cog.description else None
))
def __init__(self, help_command: "MyHelpCommand", options: list[discord.SelectOption]):
TypeError: 'type' object is not subscriptable
why does it send this error
Surround list typehint with quotes
""?
options: "list[discord.SelectOption]"```
ohk

list[…] was a feature introduced in python 3.9, so that error probably means you have an older version
oh
This command is not working, the console reports a key error
for <3.9 you would have to be type it using typing.List instead
onents.py", line 261, in to_dict
'options': [op.to_dict() for op in self.options],
TypeError: 'NoneType' object is not iterable
^^^ this error is because of older version
You can also just import “annotations” from future
Basically auto forward referencing typehints
ohk
What's wrong with just surrounding it with quotes
onents.py", line 261, in to_dict
'options': [op.to_dict() for op in self.options],
TypeError: 'NoneType' object is not iterable
Nothing, but imo it looks weird and this is easy to do
So preference?
I'd recommend checking if ctx.guild.id is in sniped_messages because that's what's causing error 99% sure
i thought type checkers would still have to evaluate them
I always typehint tuple[Something], list[Stuff] etc with quotes and haven't faced any issues so far neither I have noticed any style guides going against it
that syntax is only supported in 3.9+
!pep 535
You don't even need that variable if you are subclassing
Eh hold up you can ignore the quotes now?
Ok thx for this pep
@wooden frigate
asycn def start(self):
He's overriding a method lol
@slate swan this
Remove that variable and add await super().start() with args and kwargs
Of course, otherwise how would they work?
All it just does it turn typehints into strings during runtime, just automatic forward referencing
Then the typehinter does it’s magic
so it just understands syntax from future python versions?
No
It just turns them into strings during runtime
Therefor you won’t get an error due to incompatibility
Your type checker should understand the string version fine, etc
yeah i meant if the type checker would still understand it
yeah probably, its used to convert annotations to string i.e pipes
go to sleep okimii
its 10:50 am?
and its monday 😔
i only slept 1 hour and ive been awake for 29hours
im tired😔
i have a question:
how do u send a message with spaces in them
l
ike
thi
s (without delaying)
so because you are replacing start the bot won’t call its own start function. Add *args, **kwargs to the parameters for ur start and call the bots original start with await super().start(*args, **kwargs)
Simple OOP
class MyBot(commands.Bot):
async def start(self, *args, **kwargs):
self.add_view(SomeView())
await super().start(*args, **kwargs)
client = MyBot()```
If you name it client
But better name it bot
line one \nline2
I tried installing but it doesnt install in win7
!e print("new\nline")
@slate swan :white_check_mark: Your eval job has completed with return code 0.
001 | new
002 | line
😭
button.emoji = "603673342746034176"```
trying to change a button's emoji to a custom emoji how would I format it?
<:emoji-name:emoji-id>?
!d discord.ext.commands.Bot.get_emoji
get_emoji(id, /)```
Returns an emoji with the given ID.
Changed in version 2.0: `id` parameter is now positional-only.
aint it async def setup_hook?
Anyone mind popping over to #help-mango to answer some questions about how I should layout my db tables for my logging events (ik this is sort of #databases related so I'll be asking there as well but since my question is about discord bot logging events I felt asking here would be good as well)
whats wrong with this its not sending anything?
@client.event
async def on_member_join(member):
embed=discord.Embed(title=" You have been successfully verified!", description="Thank you for joining - we hope you enjoy your stay.", color=0x00ebff)
await member.send(embed=embed)
!intents
Is members intent enabled in code and on dev portal?
Using intents in discord.py
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.
To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.
Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.
oh
Should be the same
yea
ive already done that
Sry not you
How to fix "Improper token passed"? I'm sure token is right.
it isnt right lmao
i still cant get it to work
is member.intents enabled both in dev portal and code
ok show me the code
It is, I said I'm sure
it needs member.intent = true
doesnt matter if youre sure or not cause its wrong if it says improper 😭
and ur view timeout must be None
- if you are using buttons, they must have custom ids
show me how you put the token in
Another question how do i make link buttons?
load_dotenv()
TOKEN = os.getenv('TOKEN')
print(TOKEN)
bot.run(TOKEN)
how about you try putting the token in the code?
bot.run("token")
class MyBot(commands.Bot):
def __init__(self):
intents = discord.Intents.default()
intents.message_content = True
super().__init__(command_prefix=commands.when_mentioned_or("s!", "S!"), intents = intents)
async def setup_hook(self) -> None:
self.add_view(MyView())
bot = MyBot()
then you can see if its actually improper, or youre doing it wrong as ive never used dotenv, i use configparser
try this
Improper
add something in callback?
It can't be wrong
Reset ur token from the website and copy the new one then
you should use it in main.py file and import view classes using from cogs.cog_name import MyView
man you cant stop denying things that are literal facts, its like youre denying discord is an application, same point
It's sounds like shit, but I reseted it some hours ago
I'll try again.
I've got a question about how i should structure my events logging over in #help-mango if someone doesn't mind popping over
nah hes probably copying something else
how can u possibly fail copying a discord token 🤦🏿
Does anyone know how to make a link button on discord?
if its in a cog it would be the first deco
Seems like no one has answered your question from before, hence try searching it up
it just show on how to do it on discord js
!d discord.ui.button
discord.ui.button(*, label=None, custom_id=None, disabled=False, style=<ButtonStyle.secondary: 2>, emoji=None, row=None)```
A decorator that attaches a button to a component.
The function being decorated should have three parameters, `self` representing the [`discord.ui.View`](https://discordpy.readthedocs.io/en/master/interactions/api.html#discord.ui.View "discord.ui.View"), the [`discord.Interaction`](https://discordpy.readthedocs.io/en/master/interactions/api.html#discord.Interaction "discord.Interaction") you receive and the [`discord.ui.Button`](https://discordpy.readthedocs.io/en/master/interactions/api.html#discord.ui.Button "discord.ui.Button") being pressed.
Note
Buttons with a URL cannot be created with this function. Consider creating a [`Button`](https://discordpy.readthedocs.io/en/master/interactions/api.html#discord.ui.Button "discord.ui.Button") manually instead. This is because buttons with a URL do not have a callback associated with them since Discord does not do any processing with it.
Shit lost letter
how do i add a link on that though?
.... "it was 100% correct", maybe double check if it says improper, like i said you cant deny facts
well shit
pip install -U git+https://github.com/Rapptz/discord.py update to latest
most forks have the url kwarg so just use it
the pypi version already has everything
iirc pypi and master are the same
Now regular commands have been replaced with slash commands but these are not working with self bots. Is there a way to send a working slash command throught self bot?
yeah disnake does have a message_content intent https://docs.disnake.dev/en/latest/api.html#disnake.Intents.message_content
!rule 5
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.


But what the hell are you trying to do? it's the whole day i see you asking help for this persistent view thing 😆
why isn't this giving an output? (the error is "invalid syntax")
first of all, message_content intent doesn't exists, it is Intents.messages
why did u put the embed in brackets?
message_content should tho exist in disnake
and it gives you an error when you try to set them?
type pip freeze in your terminal and tell me the version of disnake that you have installed
are you running your bot on a venv?
virtual enviroment
Are you using pycharm?
if i can't use "None" for the image url, how can i make the image url not appear if member is None?
do an if statement
message intents are enabled on developer portal?
if member is None:
...
if member is not None:
...
i did 💀
TypeError: xylo() got an unexpected keyword argument 'pass_context'
can someone help? it keeps saykng i need to pass ctx thru parameters when i call my function but idk how to define ctx
embed.set_image(url=f"{f'{random.choice(lonelys)}' if member is None else None}")
I've got a question about how i should structure my events logging over in #🤡help-banana if someone doesn't mind popping over
await xylo(ctx)
try this:
intents = Intents.all() instead of intents = Intents.default, comment the part where you set some intent to true then add the intents var to the bot constructor
dawg 💀
then try to access some message content
it says ctx aint defined
why you make ur stuff so confusing, so much unimportant stuff give me a sec
🗿
i mean to send the gifs if there isn't a member but if there is a member, it'll be None and this command will just work
i'm not sure if it would even work if i put None
show me the xylo function
wait you are not setting intents D_D
if member is not None:
embed.set_image(url=f'{random.choice(lonelys)}')
else:
embed.set_image(url=f'None')
try this, change it so it works with ur indenting
ok i'll try that 😩
I don’t understand why this keeps showing up
WAIT SO YOU DECLARED A BOT SUBCLASS IN A COG?
@client.command(pass_context=True)
async def xylo(ctx):
guild = serverid
await guild.create_text_channel(names)
for ch in names:
channelkun = discord.get.utils(guild.channels, name=ch, type="ChannelType.text")
with open("text.txt", "a")as f:
f.write(channelkun)
with open("text.txt", "r")as w:
for x in range(channelsz):
for line in w:
hook = await guild.channel.create_webhook(name=names)
if hook.status_code == 200 or hook.status_code == 201:
print(f"Created Webhook {hook.url}")```
that's the opposite of what i want and it gives the same error it did previously 🗿
Help
oh my god D_D
thats a command, not a function, you cant call a command 💀
put the url as https://1.1.1.1/ it doesnt have an embed picture xd
pythonity
replace them with that?
oh 💀 what do i do to make it worj
Hence show any of your code??
show is a couple of lines before that where the error comes
what are you even trying to do?
replace 'None' with https://1.1.1.1/
ah
create a channel and then create a webhook thgere
I see it's improved
Like yeah I don’t know how is that a intent block
https://github.com/Tvrsier/GamingNetwork
This is how subclass should work. In launcher.py you will find the bot instance, in lib/bot/_ init_.py you will find the class GamingNetwork which is the bot subclassed
youre making a raid bot arent you -__-
show some code before that....
nah
you have an ongoing one before that probably
it could be an IDE glitch or way less python knowledge than needed
ok wait
now it'll work if i mention someone but the gifs won't load if i don't mention anyone
akeno could you show code too
or the links you've put
you can see they're bad urls, they have to end with .gif or .png or something
i didn't show the whole thing earlier because i'm afraid of the minaberry one
.
idk lol
ight can u help w what im doin? or nah
mina won't ban

what are you trying to do with the hii function
i should've looked them up on the actual tenor website 🗿
my bad 😩
idk u told me to await it somewhere
...
zagzag gone
Nope
?
get your code on one screen
dawg 💀
you can create the bot class and then create the instance in the same file, it will change nothing. Making them like i did will look better, that's all
idk wha im doing in this discord shi ngl 😭
Ok
but it clearly is a syntax error
tell me what you are trying to achieve
you made an if statement and then unindented
a command that when ran it makes a channel and a webhook in it?
yh and then it gives an option to create like self roles / rules etc
does the code work?
tf is guild = serverid
how to access slash cmds in dpy 2.0?
@hybrid ravine
if ur code works then this works
@client.command()
async def xylo(ctx):
guild = serverid
await guild.create_text_channel(names)
for ch in names:
channelkun = discord.get.utils(guild.channels, name=ch, type="ChannelType.text")
with open("text.txt", "a")as f:
f.write(channelkun)
with open("text.txt", "r")as w:
for x in range(channelsz):
for line in w:
hook = await guild.channel.create_webhook(name=names)
if hook.status_code == 200 or hook.status_code == 201:
print(f"Created Webhook {hook.url}")
changes to message.guild.id
you dont need to define pass context









