#discord-bots
1 messages · Page 64 of 1
ahh
alright so it works now but it shows ** ** as footer text
They are taking the piss 😭😭
is there a way to only send a footer image
you can't have an avatar without text
rip
I think you can
idk that should have worked
@commands.command(name="kick", description="Kick a user from the server.")
async def kick(self, ctx: commands.Context, user: discord.Member, *, reason=None):
if ctx.author.id != self.bot.owner_id:
await ctx.send("author id does not match owner id!")
return
if reason is None:
reason = "No reason provided"
embed = discord.Embed(
title=f"Kicked user {user.name}",
description=f"Reason: {reason}",
color=0xFF0000,
)
embed.set_footer(text="** **", icon_url=user.display_avatar.url)
embed.set_author(name=ctx.author.name)
# await ctx.send("kick command called")
await ctx.send(embed=embed)```
!d discord.Embed.set_footer
set_footer(*, text=None, icon_url=None)```
Sets the footer for the embed content.
This function returns the class instance to allow for fluent-style chaining.
did i write something wrong
Can’t you do description = “ “
remove the text kwarg completely, and it'll work 
Or what do you want it to do @sacred minnow
well now it doesnt send a footer at all
Ye it should be display_avatar.url
huhhh, any errors?
What do you want to be in the footer
the user avatar
just the avatar
Oh
nope
Ok
Since it’s in an embed you can do
Can someone send me the backsticks
I’m on mobile lol
`
nvm im using set_thumbnail and it works better
it indeed does
I was about to tell you to do that lol
wel.set_thumbnail(url=f"{member.display_avatar.url}")
why the f string
That’s how I did it but with welcome
wrong chat lol
!e py s = "string" print(s == f"{s}") # what the hell for
@vale wing :white_check_mark: Your 3.11 eval job has completed with return code 0.
True
How can I make a discord button only usable by an admin?
Do you know how to make buttons
Yes
is this from discord or a straight import?
from discord import has_permissions
!d discord.ext.commands.has_permissions
@discord.ext.commands.has_permissions(**perms)```
A [`check()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member has all of the permissions necessary.
Note that this check operates on the current channel permissions, not the guild wide permissions.
The permissions passed in must be exactly like the properties shown under [`discord.Permissions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions "discord.Permissions").
This check raises a special exception, [`MissingPermissions`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.MissingPermissions "discord.ext.commands.MissingPermissions") that is inherited from [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
???
idk feels wrong
Wait. So All I have to do is put the has permissions before the buttons class?
you might already have commands imported
just use commands.has_permissions
these checks have nothing to do with button classes, they are for prefix commands
They are to check if they have the permission admin
for commands, yes
for buttons, a big fat No
Ah
Anyway. back to my issue. How can I make a button only usable to lets say.. Admins?
interaction.user.guild_permissions.administrator will be True if the user who used the interaction has admin perms
I tried making a !whois command with interactions but when i try it it gives me an error
How do i fix this:
async def whoiscmd(ctx, member: interactions.Member = None):
embed=interactions.Embed(description="<@%s>**'s Profile**"%member.id)
embed.set_thumbnail(url=member.avatar_url)
await ctx.send(embeds=embed)```
ERROR:
```AttributeError: 'Member' object has no attribute 'avatar_url'```
[<Relationship user=<User id=126891288518721536 name='Xaniel' discriminator='5634' bot=False system=False> type=<RelationshipType.friend: 1> nick=None>]
How could I extract the users ID from this?
@slate swan Have you defined intents?
What is that?
@hidden violet
🙂
and add intents=intents
@hidden violet
yes
just add a line intens = discord.Intents.default()
it's impossible for me t read this sorry
saul
yeah can do that too
BRUH
?
Done
@tawdry tendon can you help me with this?
[<Relationship user=<User id=126891288518721536 name='Xaniel' discriminator='5634' bot=False system=False> type=<RelationshipType.friend: 1> nick=None>]
I need to get the users ID from this, do you know how to?
No sorry
But Wdym by take users if
Still now working
I want to store the user ID in a variable
this_object[0].user.id?
What’s wrong now can you show me the code and error
Sorry Im dum how should I use this?
So what’s wrong
your commands won't work
Why?
you don't have message_content intent enabled
it's required for message command and getting message content at all
Bro @slate swan I told you to do intents to all
Where?
^
it's .default()
Don't be mad at him I told him the wrong thing
Ok
Shimi change it and should be fine
intents = discord.Intents.default() -> intents = discord.Intents.all()
MY PCCCCCCCCC OMD ITS SO ANNOYING WTF
Don't use so much capital letters btw
Ok
Oof
read the error
Go on dev portal and turn on intents
it says to enable intents on dev portal
windows?
Yep
ctrl alt del?
Stab it
hm....
…
This one?
turn off psu
the best way is to throw it in window ig
Too strong
Ok thanks
I’ll take out the Gpu
yes, and dont forget to enable message contents intent below
UGH
Put kobid 19 virus
@silk fulcrum are you good with windows
@client.event
async def on_user_update(before, after):
if before.id in client.user.friends:
# do stuff```
Ahhhh still not working
@silk fulcrum that's what I am trying to do but how should I change it to make it work?
Error?
and client.user.friends returns what I sent earlier
[<Relationship user=<User id=126891288518721536 name='Xaniel' discriminator='5634' bot=False system=False> type=<RelationshipType.friend: 1> nick=None>] But with all friends
NVM IM QUITING AS A DEVELOPER
there is no such event as on_user_update
Bro…
yes there is
😳
on_user_update is triggered when a user changes their username discriminator or avatar
^
What?
usre
burh
burh
dude ur using replit on phone & already have "discord bot developer" in ur bio
just enable intents and you're good
Oh because there is something wrong
no need to "quit being a dev"
NAH BRO im not quiting 🙂
What would tis do?
are u raiding a server
u just did it
Thats my server
when proccessing your query (INSERT INTO ...) you didn't specify a value of lastuserID which is a required column, since it doesnt have a default value
ok
I just want the ping
if lastuser variable is an ID of that user, then yes
What will happen?
Sooo my bot is now active 24/7?
why are you so stupid
i've never seen this level of autism
seek help
Hold up-
not worth paying for
Idk what to dooo
^^
Ik
i use aws
it's great
my bot averages 16-20 ms
yep
the dpy version on replit is locked to 1.7.3 btw
u can't use anything like buttons or select menus
unless u use a fork or some shit
Yes ik but im just typing my bots command their and deleting it
or even worse get u and ur bot terminated
only thing i would use replit for is to clear unused imports
literally the only thing it's useful for
Why other bot is still running even i dont have intent turned on?
..
what would you recommend as a paid host?
buy a bigger aws server
or contabo
contabo gives u like 8gb ram for 7$
forgot other perks
Nice ty man will look it up
aws gets me 16-20 ms & it's 24/7
free tier btw
u just need to add a cc as a payment method
Sweet will check em out
👍
https://www.scaleway.com/ EU https://www.linode.com/ US/EU/Asia
https://www.digitalocean.com/ US https://www.vultr.com/ US
https://www.ovh.co.uk/ EU/Canada https://www.hetzner.com/ Germany/US
https://www.time4vps.eu/ Lithuania.
Is heroku bad?
Very
terrible
It’s not like replit is it? I want it to be 100% private
VPS’s are private by nature
obv private
Welp i dont have a choice
Virtual Private Server
They’re getting rid of their free tier soon
Yeah my bad 😆
So good luck with that
seen on reddit
no more free heroku 🗣️🗣️
How to use this?
shimi why dont u use an actual vps
ok i give up
Whip out your credit card
Teach me then
I DONT HAVE MONEY
step 1 is as djj said
u can get a free trial
How don’t you have $3 minimum?
That buys you a month
You’re literally setting pool to none in the init
Its just like what you said to heroku
You’re also creating a second bot inside the first bot for no reason?
?
The free teir is removed soon?
yes
Bro teach me to use vps
look up a tutorial
@slate swan can u send me an invite to a server with ur bot in it
Can u use google cloud?
@slate swan
2H wasted
this the correct website? https://sparkedhost.com/discord-bot-hosting
kk
import discord
from discord import ui , app_commands
from discord.ext import commands
import discord.ui
class Modals(commands.Cog):
def __init__(self , client = commands.Bot):
super().__init__(
"Modals",
)
self.client = client
self.emTitle = discord.ui.TextInput(label= "Embed Title", min_length = 2 , max_length = 124 , required = True ,placeholder= "Enter Title")
self.add_item(self.emTitle)
self.emDes = discord.ui.TextInput(label= "Embed Description", min_length = 5 , max_length = 4000 , required = True ,placeholder= "Enter the embed description" , style = discord.TextInputStyle.Paragraph)
self.add_item(self.emDes)
async def callback(self, interaction:discord.Interaction) -> None:
title = self.emTitle.value
des = self.emDes.value
embed = discord.Embed(title = title , description = des , colour = discord.Colour.purple())
return await interaction.response.send_message(embed = embed)
@commands.command()
async def embed(self, ctx):
await self.callback(ctx)
await ctx.send("Embed Created")
async def setup(client):
await client.add_cog(Modals(client))```
Can you run 2 different .py files on sparked? And do they also provide a database?
ok sweet
um, i can see the command; why the bot cannot
@client.command()
You forgot the ()
GOD!!
lmao, It's okay to forget those things
-_-
i thought it was client.event
client events don't need the () btw
why isnt this working
so command is a function?
and event is decorator?
I'm not that experienced to answer this question :')
botinfoembed = discord.Embed(title="Bot Information",
description="This bot was made by HelloHello#0729 you can contact him through discord. The creator of this bot lives in London",
colour=discord.Colour.magenta())``` i get this error even though it isnt a command``` botinfoembed = discord.Embed(title="Bot Information",
AttributeError: 'Command' object has no attribute 'Embed'```
wdym
heyy i need help
a command is a command and an event is an event
commands need () and event doesnt
class Modals(ui.Modal):
def __init__(self , client = commands.Bot):
super().__init__(title="New suggestion:")
self.client = client
self.emTitle = ui.TextInput(label= "Embed Title", min_length = 2 , max_length = 124 , required = True ,placeholder= "Enter Title")
self.add_item(self.emTitle)
self.emDes = ui.TextInput(label= "Embed Description", min_length = 5 , max_length = 4000 , required = True ,placeholder= "Enter the embed description" )
self.add_item(self.emDes)
async def callback(self, interaction:discord.Interaction) -> None:
title = self.emTitle.value
des = self.emDes.value
embed = discord.Embed(title = title , description = des , colour = discord.Colour.purple())
return await interaction.response.send_message(embed = embed)
class Utilities(commands.Cog):
def __init__(self, client = commands.Bot):
self.client = client
@commands.command()
async def suggestion(self, ctx):
suggest = Modals()
await ctx.send(suggest)```
fix your code and send it again
i am not getting the modal
wdym???
just know its @client.command() and @client.event
You sent your code very weirdly
<Modals timeout=None children=2>
this is the response
infoembed = discord.Embed(title="Bot Information", description="This bot was made by HelloHello#0729 you can contact him through discord. The creator of this bot lives in London", colour=discord.Colour.magenta())```
send your whole code
what... why
Just send the embed's block
You probably forgot something
botinfoembed = discord.Embed(title="Bot Information", description="This bot was made by HelloHello#0729 you can contact him through discord. The creator of this bot lives in London", colour=discord.Colour.magenta())
@bot.command()
async def botinfo(ctx):
await ctx.send(embed=botinfoembed)```
why do u have the embed defined outside of the command
i called the embed later in the command
it's outside of the command
I think it's not possible...
it would still work
move it in & try
Either it's a function, Or it won't work
ya it got to be inside command to call it i thought
@crystal glen Per Rule 6, your invite link has been removed. If you believe this was a mistake, please let staff know!
Our server rules can be found here: https://pythondiscord.com/pages/rules
oh shit, My bad
@client.command()
async def botinfo(ctx):
embed = discord.Embed(title=f"{client.user.name}", color=0x00FF00)
embed.set_thumbnail(url=client.user.avatar_url)
embed.add_field(name="ID", value=client.user.id)
embed.add_field(name="Created at", value=client.user.created_at.strftime("%d-%b-%Y-%H:%M"))
embed.add_field(name="Prefix", value="?")
embed.add_field(name="Developer & Owner", value="ArasoOsara69")
embed.add_field(name="Guilds", value=len(client.guilds))
embed.add_field(name="Users", value=len(client.users))
embed.add_field(name="Version", value="1.6.9")
embed.add_field(name="Dev Language", value="discord.py")
await ctx.send(embed=embed)
@tawdry tendon
still dont work
same as before
AttributeError: 'Command' object has no attribute 'Embed'```
@bot.command()
async def botinfo(ctx):
await ctx.send(embed=botinfoembed)
botinfoembed = discord.Embed(title="Bot Information", description="This bot was made by HelloHello#0729 you can contact him through discord. The creator of this bot lives in London", colour=discord.Colour.magenta())```
shouldn't it be embed = Embed?
no why would it be
why would it be...
my embed is named botinfoembed
^
I didn't see that
your calling me stupid telling me to move it above ctx.send
that would give an error saying that i havent defined the command
bruh
so you cant be calling me stupid
You're... No offense
@bot.command()
async def botinfo(ctx):
botinfoembed = discord.Embed(title="Bot Information", description="This bot was made by HelloHello#0729 you can contact him through discord. The creator of this bot lives in London", colour=discord.Colour.magenta())
await ctx.send(embed=botinfoembed)
THANK YOU
Indentation error... Not a real define
plz change your name
no thanks
define main.py
You clearly don't know what is main.py
why cant i send the code
what are u trying to prove
it includes an invite link
oh it has a discord link
He thinks he knows everything, And I don't think he is
@bot.command()
async def discord(ctx):
await ctx.send("[MATHER's discord](thelinkhere)")```
@tawdry tendon whats a subclass
i'm chilling
my name can be anything i want wtf
nobody said it can't
but...
you shouldn't have it when you don't know what's main.py
i'm just saying this, because it's annoying in my opinion
idc about your opinion
damn
if i want my name to be main.py then ill leave ir like that
k.
look, i dont care if he wants me to change my name then thats his problem
not mine
why are u talking to me about it
you @ ed me and sent me a picture
doesn't have anything to do with him asking u to change ur nickname
are u stupid or something
ur autism is even worse than @slate swan's
seek help bud
😂
and how would you know if i have autism or not
and if anyone would need help it would be you
especially with that image in your files
chill mate no need to respond
116 123 you should call them @dim cosmos
😵
main.py is literally just a Python file
Python does not treat it specially
thats what i was saying
why is it called main.py
because why not
it doesn't matter...
it typically serves as an entrypoint, but it can be anything
fr
It wasn't initially why I told him to change it
print ("Goodbye") quit()
wtf is this
I'm back
and wtf is your pfp
It's a meme
Yes, It's something going on with my friends
yes because you're autistic
says you
<@&831776746206265384>?
guys calm down 😅
I dare you
nah you will probs @ the mods
I already did
DM me then
Don't ping them twice
why would i want to dm your ass
Both of you will probably get muted or banned
.topic
Suggest more topics here!
they need new topics someone needs to make a pr
how about you do something that doesn't annoys others
i stopped and he carried on
and it was almost over....
omfg
you carried on
that was a while ago
lmao
bro i beg just shut up about it
bruh
add message content as an invite scope instead of intent 😔
thats like a genius idea
then what would happen if you only used prefix commands
i know right, but discord is an stable platform
if they dont hav msg content they can't use prefix command?
sarth should be on discord dev team
you can't read message content?
simple enough
if the bot was invited with the scope, it could read the content
if it was not, it can't
and they claim slash commands will stop self bots and stuff which person tries to verify himself as a self bot and req for message content
discum: hold my beer
being unable to read content means unable to detect/use prefix commands though
and that would be a problem for prefix-only bots
why would someone not invite the bot with that scope if they want to use prefix commands
eh good point
there's no such method in discord.py what library are you using
its create_activity_invite , not link
hello
i need help
@bot.listen()
async def on_member_join(member):
wel = discord.Embed(color=discord.Color.magenta(), title=f"Welcome {member.name}!", description=f"Welcome {member.mention} If you don't know the commands type in '.help', this will tell you all the commands. I am a math bot so if you ever need help with math, I am the one to use. I can do other things aswell, test me out in. Enjoy your stay!")
wel.set_thumbnail(url=f"{member.display_avatar.url}")
wel.set_author(name=f"{member.guild}", icon_url=f"{member.guild.icon.url}")
await member.send(embed=wel)
File "/home/runner/MATHER/venv/lib/python3.8/site-packages/discord/client.py", line 409, in _run_event
await coro(*args, **kwargs)
File "main.py", line 205, in on_member_join
wel = discord.Embed(color=discord.Color.magenta(), title=f"Welcome {member.name}!", description=f"Welcome {member.mention} If you don't know the commands type in '.help', this will tell you all the commands. I am a math bot so if you ever need help with math, I am the one to use. I can do other things aswell, test me out in. Enjoy your stay!")
AttributeError: 'Command' object has no attribute 'Embed'
anyone know why?
You named one of your functions "discord"
i swr its discord.Embed
Everything is allowed but same name for different things will cause overwrites and malfunction consequently
ok
thanks
Rename your function to something like discord_cmd
and use name kwarg of command decorator
;-; use the name kwarg
you're calling acquire() on None
use an env file
for passwords
also are u doing self.pool = None just so u don't get error? from ide?
u can typehint with pool: aiomysql.pool
then in setup hook declare pool
how to make a bot send a message in a channel in some other server
like if i run a command in this server, it should send a message in another server
wdym
Your bot should be in that server, if no then you can’t
my bot is in it
Get the channel’s id and send message
is that it
await chn.send(“hi”)```
oo tysm
Lmao
:kekwhat:
how were you installing it before?
github lol
Zeffo forgot that there was a depressing period where we had to use the master branch to use views in discord.py
you were cloning the repo into you rporjects everytime? 😳
pip install git+url
that is installing with pip !!
Pip+git
🙄 pedants
And that difference is a fine demarcation between the depression and happy period!
🙄 non-pedants
happy period is me finally installing arch on my laptop
imagine having all intents enabled (in code) and then disabling them again just to do nothing
My happy period is never gonna come because it will come when Windows 11 performance issues get fixed which is never gonna happen
!pip pip
Me happy with my crappy windows 10
Ik
!pypi pip
W11 came pre installed lol
hm..... where's difference?
what difference
between pip and pypi
pip and pypi are command alises
im looking for a way to create a saved instance of my bot, but one that doesnt break when i add new attrs in the instance class.
Currently the save system works by using these 2 funcs
# save
state_json = jsonpickle.encode(state)
def write_json(filepath, data) -> dict:
with open(filepath, "w") as f:
json.dump(data, f, indent=4)
return data write_json(os.path.join('saves', f'{str(ctx.author.id)}.json'), state_json)
# load
def read_json(filepath) -> dict:
with open(filepath, "r") as f:
data = json.load(f)
return data
state = ctx.bot.game_states[str(game_channel.id)] = jsonpickle.decode(read_json(os.path.join('saves', f'{str(ctx.author.id)}.json')))
however using this current system, it overrides any new attrs not in the old save. When it then asks for said attrs the bot crashes as the attrs dont exist in its instance
but irl, pip is the tool used to download packages from pypi
Nice, json db
@vocal snow all yours
holy shit
I suck with JSON
no thanks lmao
Only u r the JSON God here
that last line is really tangling my eyeballs
Same
wait what is jsonpickle

!pypi jsonpickle
Nice
im ngl, this was not written by me; it was written by a friend for me when i was still using ifs and elifs for the majority of my code
it doesnt serve any useful purpose tho anymore, for the reason described above
damn, it also has numpy and pandas support
And apparently it also has a JS port which is.... nice
i have absolutely 0 experience with json, if json is even the way to go here
whatever is happening here is def not the way to go
it seems like you're saving a new file for each user as well
however, the thing that needs to change is allowing for additions to the instance class
well..
from my knowledge i do; each file is supposed to represent a players saved game file
i dont want saved files to stack, hence each is keyed to a user id
yes but why don't you just use a database
will this also deal with my other big issue regarding old saves having out of date attrs?
i also have no experience with databases either :l
so how/what would you suggest replacing the json db system with?
what exactly are you storing
each game instance has a number of variables and instanced references
this is a small snippet of it
class NewGameState:
def __init__(self):
self.name = 'Player'
self.c_arena_count = 3
self.valid_game_options = []
self.Factions = game_info.Factions()
but theres hella more items
ah i see, an rdbms would be fine, but it's going to take a hell lot of time for you to refactor
well lets ignore the possible atomicity and file corruption issues and see what the issue on hand is
alr
so what is happening exactly
u mean wheres the issue with my json one?
you store an instance of the NewGameState in one of those files
and when you read it, it's attributes are overidden by another instance?
yes
thats correct
its like u copy paste the save over the existing file
which removes everything that is new since the game was saved
when u then run the bot, when the code (which refers to the NewGameState), hits somewhere it needs one of those new attrs, it crashes
because in that old saved instance, that attr never existed
so yes, like u said
ok, so essentially if you had py attr1 = 1 attr2 = 2 in the original save and then you tried to write ```py
attr3 = 3
also this might help;
ctx.bot.game_states[str(game_channel.id)] = NewGameState()
state = ctx.bot.game_states[str(game_channel.id)]
yes. Don't do that tho
this is where the 'state' is coming from
why , i want to promote something to my server users
hmmm
but why any reason ?
yup
it's API spam and a trashy thing to do
i think 🤔
i will loop it vai all memeber with 2 seconds sleep
you're going to need to first read the old state, modify it with the new attrs, and then dump it
tbc i think its more accurate to say if u had
attr1 = 1
attr2 = 2
in the original save and then you tried to load over the current game that has
attr1 = 1
attr2 = 2
attr3 = 3
itll only keep 1 and 2
how are you loading and dumping the states, can you share that code again
hmm wot about 100 ppl at once ?
# save
state_json = jsonpickle.encode(state)
def write_json(filepath, data) -> dict:
with open(filepath, "w") as f:
json.dump(data, f, indent=4)
return data write_json(os.path.join('saves', f'{str(ctx.author.id)}.json'), state_json)
# load
def read_json(filepath) -> dict:
with open(filepath, "r") as f:
data = json.load(f)
return data
state = ctx.bot.game_states[str(game_channel.id)] = jsonpickle.decode(read_json(os.path.join('saves', f'{str(ctx.author.id)}.json')))
no.
😳
mind u, this isnt all in 1 spot; i just chucked it together so it makes sense
gotcha
rn the save/load is hella screwed lol
coz it means every time i update NewGameState, i have to force people to start new games from scratch.
good thing its mostly private still
how would i go to convert from normal commands to slash commands
i mean this sounds like itd work; i dont have the background knowledge to say for sure tho, as i havent done this b4
im using discord.py
when you modify an attribute on the game state are you sure you're dumping it to the file?
I'm not sure how your system is set up, a DB would've been so much easier 😭
can you be more specific?
do u mean does it update live ?
when you modify an attribute of someone's state, do you immediately save it to their file?
no
they have to use a save command (the write part)
well command is the wrong word; its not a python command
more just a keyword that is set up to do x when typed while within the bot
i see, and when they run that save command what happens exactly
the old data in the file is lost?
if this is on github or some online repo could you share it
elif state.choice.lower() == '&save':
# Converts from python object into a json string
state_json = jsonpickle.encode(state)
# if the dir ./saves/(author_id).json is in the save folder (meaning they have saved before)
if os.path.exists(os.path.join('saves', f'{str(ctx.author.id)}.json')):
await game_channel.send(
'Save file already exists. Do you wish to overwrite existing save? __(Yes/No)__\n'
'**Warning: This action cannot be undone.**'
)
confirm_msg = await bot.wait_for('message', check=lambda m: m.content.lower() in ['yes', 'no'] and m.channel == game_channel and m.author == ctx.author)
if confirm_msg.content.lower() == 'yes':
write_json(os.path.join('saves', f'{str(ctx.author.id)}.json'), state_json)
i left the comments my helper wrote when designing it (they have since ghosted me, else id be asking them for help)
choice just equals msg.content
so basically if its a message
i havent got that organised :l
yes
Whats going on people 👋
ello
no idea, hi
Ayyyyyy
master32 can you take over with this ^
i need to go fix my cycle
for like 20 min
Zeffo is helping redesign my save system :l
I honestly think it's not too late to shift to a db!!
my rather broken save system*
I will help you with all the setup if you want
but this json pickle file thing is not very good !
how many users do you have currently
honestly, i need someone who actually knows what they r talking about to run through my code, at least a once off
there is so many things that i dont know i dont know ngl
what is the problem wit this ?
i will even contribute to your code, but it needs to be on some repo like github
How can I get all the commands in a bot and add them to an embed secreted by ,?
move to a db, it will make it easier
wdym
oh
I mean command name*
.
it's just saying you declared the function but didn't access it, it's not an error
you never called help
meaning ?
got any experience with online hosting...?
you make variable but didnt use it
",".join([cmd.name for cmd in bot.commands])
because thats been on my list for quite some time, but i have no idea where to start
but I did
usually the hosting part comes after the development part 😄
well this is a project with an indefinite length
I know, but no point wasting resources in hosting it before it's in a working condition
so i kinda want to host it so i can let people give feedback without my laptop on 24/7
oh it works
its just constantly being expanded
nps
feel free to ping/dm if you need anything
yo how do I fix it though
you could host it on railway.app temporarily and get a proper server for hosting the bot once it is all fine and dandy
I have the whole command, but it just says that
it's like
def foo():
...
def bar():
...
bar()```
here I'm calling bar and therefore **accessing** it while foo is never accessed, i.e. never called/referenced
but then when I use the command it just says command not found ?
no it won't show that
or show the command
code
inb4 he forgot the command decorator
what about the parantheses 😔
@self.bot.command()?
you create commands in a cog using commands.command
idek how youre accessing the self either
and there needs to be a self argument
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.
async def help(self, ctx, etc…)
doesnt work
railway app now added a bunch of limitations like 500 hrs per month and .2$ limit
2$
💀
@slate swan what do you think the problem is
wow
that sucks
used to be my go to for hosting purposes
I'm.....scarred, I'm sure somebody can help
you should look at the examples though
i wanted to enter space the . is right next to it
discord.gateway: Can't keep up, shard ID None websocket is 50.1s behind.
what does this mean?
wtf
!intents
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 Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, 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.
what intents do i need for buttons?
its still not working.
thats not the error though
use @commands.command() decorator
self is not defined in that scope
and your class isn't subclassing commands.Cog
@vocal snow
self.bot is defined
your command callback is in the init
that is a very... unusual way of doing things
and how are you running the bot
[2022-08-28 08:18:42] [WARNING ] discord.gateway: Can't keep up, shard ID None websocket is 50.1s behind.
ive tried multiple things and its not working, aswell as my intents are correct its still, doing, this.
on visual studio for now
no, where are you calling bot.run or bot.login or whatever
your using self
isn't that a coro
in the init
!d discord.ext.commands.Bot.login
await login(token)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Logs in the client with the specified credentials and calls the [`setup_hook()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.setup_hook "discord.ext.commands.Bot.setup_hook").
it needs to be awaited. So you cannot call that in the init
!d discord Intents
In order to work with the library and the Discord API in general, we must first create a Discord Bot account.
Creating a Bot account is a pretty straightforward process.
why do you think intents are related to this error 
because of the gateway im assuming
!d asyncio.sleep
coroutine asyncio.sleep(delay, result=None)```
Block for *delay* seconds.
If *result* is provided, it is returned to the caller when the coroutine completes.
`sleep()` always suspends the current task, allowing other tasks to run.
Setting the delay to 0 provides an optimized path to allow other tasks to run. This can be used by long-running functions to avoid blocking the event loop for the full duration of the function call.
Deprecated since version 3.8, removed in version 3.10: The `loop` parameter. This function has been implicitly getting the current running loop since 3.7. See [What’s New in 3.10’s Removed section](https://docs.python.org/3/whatsnew/3.10.html#whatsnew310-removed) for more information.
Example of coroutine displaying the current date every second for 5 seconds:
Is this error from my side or discord's end
do you have a NOT NULL constraint on those fields?
you need to call await bot.login(...) in some async finction
maybe make an async login method of your runner class
ok, you can remove those with DELETE FROM Table WHERE guildID IS NULL
as for why the database isn't "saving" anything, you'll need to elaborate a bit on that
The original problem of it not registering it as a command is still there
doesnt want to work
you cannot just make the init an async function
like i said, make an async method of the Runner class and log the bot in there
I didnt get you ?
which part of the sentence
you know what a method is right
I know you don't, I'm telling you to run that query to get rid of the NULL records
not really.. :/
im quite new to coding so..
ok so method is when you define a function in a variable ?
!d display avatar
display [expression]```
Display the value of the expression if it changed, each time execution stops in the current frame.
Without expression, list all display expressions for the current frame.
New in version 3.2.
How can my bot google something and provide the top most text from the search and send it in an embed?
hmmm
#bot-commands
using requests
!d requests
This part of the documentation covers all the interfaces of Requests. For parts where Requests depends on external libraries, we document the most important right here and provide links to the canonical documentation.
google has a search api, although I'm not sure if it's free
you can use an async http client like httpx or aiohttp
you can use requests,
everyone in this channel expects stuff to be free
@vocal snow could you help me out ? how would I do it.
not in a discord bot
you would get detected
im using requests for my google command for top search, no apis at all
although it is laggy
- requests is blocking, you risk blocking the heartbeat
- It's against google ToS
so in general, a really bad idea
aiohttp vs httpx, who will win
then?
speed wise, httpx
Is this error from my side or discord's end
Learning about classes would be a good place to start
both, your internet, connection error.
can be both
My internet ??
it can be both
I use a separate host
are you usng replit?
No
how would I use my runner class ro make a method ?
how to create one variable in one command. And then transfer it to another command?
I'm not here to teach python, you may want to ask for help regarding classes in a help channel: #❓|how-to-get-help or check Corey Schafer's tutorial series on OOP on YT
It's better not to watch someone doing something on YouTube because everything always works for them. Since he is showing it on another bot
so your basically telling me to do this right ? @vocal snow
How do i check if a channel object is a text channel and that the bot has permission to send messages?
yes but make login an async def
and call await self.bot.login(...) in there
@vocal snowit seems to me if I called the video tutorial and everything is done incorrectly and it is not clear. Then you need to block such authors and not let them upload videos
didn't understand you, sorry
you could use isinstance
This is still a problem what do I do 😭
thats not an error, just ignore it
or remove the decorator
and use self.bot.add_command(help)
Isinstance has one mention in the entire docs of discord.py
isinstance isn't a discord.py function
it's a builtin
!d isinstance
isinstance(object, classinfo)```
Return `True` if the *object* argument is an instance of the *classinfo* argument, or of a (direct, indirect, or [virtual](https://docs.python.org/3/glossary.html#term-abstract-base-class)) subclass thereof. If *object* is not an object of the given type, the function always returns `False`. If *classinfo* is a tuple of type objects (or recursively, other such tuples) or a [Union Type](https://docs.python.org/3/library/stdtypes.html#types-union) of multiple types, return `True` if *object* is an instance of any of the types. If *classinfo* is not a type or tuple of types and such tuples, a [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "TypeError") exception is raised.
Changed in version 3.10: *classinfo* can be a [Union Type](https://docs.python.org/3/library/stdtypes.html#types-union).
isinstance(obj, discord.TextChannel)
No idea how that would help
😭
it checks if the channel object is an instance of TextChannel
which is what you asked for
man i have no clue what you're doing
You're really new to python im guessing
yes . but whats wrong here
Many many things
there's way too many thing for me to pinpoint
like . ?
how do I make the command work when the button is pressed ? That is, I clicked on the button it was written enter the text you entered the text and it was saved to the variable
The if statement is messed up
And many other things
Looking at it, about half the lines have issues
@onyx cipher look at some examples of discord bots
brother everything looks to be working fine however idky it doesnt want to define help as a command
That screenshot has only one if statement in it and its messed up, what do you mean everything is fine
there is no error ?
Yeah, because the other error gets there before it
You will see many errors as you fix each one
`where did the if statement go wrong
what do you think I should do to it ?
!intents
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 Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, 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.
how do i get the authors current avatar in python 2.0?
Cool
Traceback (most recent call last):
File "C:\Users\user\Desktop\main.py", line 22, in <module>
@lua.commnad()
AttributeError: 'Bot' object has no attribute 'commnad'. Did you mean: 'command'
@lua.command
why tf uses python 2.0 in 2022
you mispelled it
dpy 2.0 rewrite
you need to use User.avatar.url
ctx.user.avatar.url?
ctx.author
ctx.author.avatar.url
alr
its not defined in the code... not the database
@slate swan
"@lua.command" or "@lua.command()"
second
its a corro
So what's the error in my code @slate swan
Aaah ok
Stop pinging smh
AttributeError: 'Bot' object has no attribute 'commnad'. Did you mean: 'command'
an AttributeError
well the error explains itself
you spelt it wrong ;-;
anyone know the issue with this
you didnt save the file or something because the error says msg but in the screenshot i see message
i dont understand
why is the error saying msg
btw its obvious that you didnt define message
There is no msg variable in this context. If you wanted the id of the user who made the interaction, just do interaction.user.id
Code in normal ide to see errors like this
you just didnt define it
strange why is the linter not screaming
🙏
how do i give someone a role by coding?
Probably because there is none. That looks like a basic text editor from a Pterodactyl instance
they are literally coding on their hosts' file upload page
!d discord.Member.add_roles
await add_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")s.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
i must have the manage roles permisson or the bot needs to?
i wish i could do that like be so pro that u code 1k lines without an error in some text editor or something
bot
just give it admin
alr
whats Atomic?

it's gonna be a private bot most probably
yeah, probably'
just use notepad
and token leaks are amateur mistake also if i am coding a public bot i would run private tests everything has its pros and cons but for beginners it's best to have intents and admin to avoid beginners problems
indents are a pain in the ass i was thinking of something like sublime ig
is this where i should use role ID?
u need role object
wdym
!d discord.Role
class discord.Role```
Represents a Discord role in a [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild "discord.Guild")...
sublime is nice yeah
anyway hbu how is ur day going 👀
I don't know what intents or how to add..
Traceback (most recent call last):
File "main.py", line 7, in <module>
client = commands.Bot(command_prefix = "!")
TypeError: __init__() missing 1 required keyword-only argument: 'intents'
intents=discord.Intents.all()
!intents
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 Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, 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.
omw to kota, waiting for trainnnnn lmao
its already 30 mins late
i see nice
u took ur laptop no? 🙏
no
🥲
dw ill join replit on phone gang for you
kek sure
atleast i have my persistent manjaro installation with me, ill find a system for sure
u might as well download pydroid 
man on a mission
indeed
