#discord-bots
1 messages · Page 842 of 1
also i suggest typehint channel to discord.TextChannel
like:
@bot.command(...)
async def slowmode(ctx, args, channel: discord.TextChannel):
...
that way if channel is None then use ctx.channel
@bot.command(...)
async def slowmode(ctx, args, channel: discord.TextChannel):
channel = channel or ctx.channel
# do whatever with channel
bad code
🗿
Not a problem we're working on fixing it
definitely
I'm seeing a lot of type-uncertainty, meaning you think a variable is a certain type when its not
Who knows ¯_(ツ)_/¯
no, oldsm will be an integer, args will be a string
I ain't really following it's development, both figuratively and literally
so you're basically trying to do:
5 + "+5"
well you need them to be integers
otherwise you can't do math on it
and you won't be able to do int(args) either
actually
!e
print(int("+5"))
@sick birch :white_check_mark: Your eval job has completed with return code 0.
5
@sick birch :white_check_mark: Your eval job has completed with return code 0.
-5
this is good, typecast args to int in your function definition
then add whatever that is (regardless of sign) to the old slowmode
@bot.command(...)
async def slowmode(ctx: commands.Context, channel: discord.TextChannel, time: int):
channel = channel or ctx.channel
# set slowmode to channel.slowmode_delay + time
im trying to react the 🎲 to a message, but i keep getting an "unknown emoji" error
message = await ctx.send(f'Your roll is: {random.randrange(range)}')
await message.add_reaction("<:game_die:>")
am i giving it the wrong emoji name?
remove the <>
yeah you can't add an emoji using :emoji_name:
so it works for custom, but not discord emotes? 
afaik you can
add_reaction('🎲')
but without the <> since its not a custom emoji
let me check if you can because i don't remember
\:emojiname: to get the unicode char for it and you can just copy paste that in
just :game_die: should work
thats not unicode?
or yeah, you can also get the unicode
alright yeah, that worked
it is, type it onto discord
i wonder why :game_die: didnt 
wait uhh, isnt that the name:id stuff
From the docs,
In case you want to use emoji that come from a message, you already get their code points in the content without needing to do anything special. You cannot send ':thumbsup:' style shorthands.
yeah I don't think it likes multi line like that
well, thanks for the help! 
What do you mean?
i have a new problem 
let's hear it
no thats not unicode
im trying to make a dice rolling command, which is what y'all just helped me with
@slash.slash(name='roll',description='Roll a dice, click on the button when you want to finalize your roll.',guild_ids=[917640265475440681])
async def _003(ctx,range : int):
message = await ctx.send(f'Your roll is: {random.randrange(range)}')
await message.add_reaction("🎲")
def check(reaction, user):
return user == ctx.author and str(reaction.emoji) in ["🎲"]
# This makes sure nobody except the command sender can interact with the "menu"
while True:
message = await message.edit(f'Your roll is: {random.randrange(range)}')
try:
reaction, user = await bot.wait_for("reaction_add", timeout=60, check=check)
```the goal is to have it so that the user clicks on the emote to stop the message from rolling, but im getting this error: `TypeError: SlashMessage.edit() takes 1 positional argument but 2 were given`
you don't need to check +/-
int() will automatically make it a positive or negative integer
just add that since a positive + a positive is normal addition, positive + negative is subtraction so it works out perfectly for us
i see
isn't it content= for edits?
huh
can we see the code?
did that fix it?
i didnt get an error 
i suppose that's better than nothing
i think i just need to have it wait a bit before it changes the number
that first if statement won't work
"+" or "-" will always be true
if args.startswith("-") or args.startswith("+")
!e
print("+" or "-")
@sick birch :white_check_mark: Your eval job has completed with return code 0.
+
it'll always be plus so it will never subtract
nah i understand where you're coming from though
since it's close to english, if args startswith plus or minus
unfortunately it's if args startswith plus or args startswith minus
also you can reduce
if not channel:
achannel = ctx.channel
else:
achannel = channel
to one line:
channel = channel or ctx.channel
and instead of
@bot.command(aliases=['sm'])
async def slowmode(ctx, args: str, channel: disnake.TextChannel=None):
change = int(args)
you can do
@bot.command(aliases=['sm'])
async def slowmode(ctx, args: int, channel: disnake.TextChannel=None):

oh that's unfortunate
actually ignore what i said here
won't work for our purposes
i dont think i'll be able to change the message fast enough for it to be a real roll
if it starts with +/- then int(args)
plus the wait_for check wasnt working 
@bot.command(aliases=['sm'])
async def slowmode(ctx, args: str, channel: disnake.TextChannel=None):
channel = channel or ctx.channel
if args.startswith("-") or args.startswith("-"):
change = int(args)
# do stuff
else:
change = int(args)
# do stuff
``` @slate swan
You should also be handling when the slowmode is already 0
Otherwise you'd be setting negatives
did you run the command without specifying the user?
or if it was say 4 seconds and they wanted -5
figure out what the change would be and if it's less than 0 set it to 0
how can i restart my bot by doing something like !restart
@client.has_permissions(manage_channels=True)
AttributeError: 'Bot' object has no attribute 'has_permissions'
how do i fix this
@commands.has_permissions(manage_channels=True)
OH
sorry im tired
f what datatype is a channel if i want to take it as an option in slash commands
how can i restart my bot by doing something like !restart
That worked but i dont want it to be like that
Can i dm you?
What do you want it to be then
from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'str' object has no attribute 'channel'
fixed it
im stupid
I want it to where itll create a profile like this one give me one minute ill show u a screenshot
nvm broke it again
like this @supple thorn
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'str' object has no attribute 'channel'
how do i fix this
from discord.ext import commands
Damn you're 6'5"?
Nah am way shorter but thats not the case rn
u live in new zealand?
Yes
?
How do u know?
same
You're a female named thomas?
hey guys i needed help again. So i want to make a command which can only be used every 15 minutes how do i do that?
thinking i am female
wdym
import commands because your running ur command
Sounds like you are looking for a cooldown
already have it?
yup so how do i set a cooldown?
Fuck i forgot the tag
@jade tartan
?
I already have it
Did you mention the channel?
I didn't think i had to, but i did just now and it still doesnt work
So how do i make it like that?
wdym
!d discord.ext.commands.cooldown
@discord.ext.commands.cooldown(rate, per, type=discord.ext.commands.BucketType.default)```
A decorator that adds a cooldown to a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command")
A cooldown allows a command to only be used a specific amount of times in a specific time frame. These cooldowns can be based either on a per-guild, per-channel, per-user, per-role or global basis. Denoted by the third argument of `type` which must be of enum type [`BucketType`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.BucketType "discord.ext.commands.BucketType").
If a cooldown is triggered, then [`CommandOnCooldown`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandOnCooldown "discord.ext.commands.CommandOnCooldown") is triggered in [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") and the local error handler.
A command can only have a single cooldown.
Could you help me with one?
oh alright thanks!
so i can continue it
He wants the bot to use wait_for for the answers to questions in dms
Yes like once i answer the question it will move to the other/next
?
ah
yeah i dont know how to do that rn
still learning
@supple thorn
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'str' object has no attribute 'channel'```
i get this error when i try run my lock command
Did you mention the channel?
Whats your code
How do i make a soccer command in discord.py
@client.command()
@commands.has_permissions(manage_channels=True)
async def lock(self, ctx, *, reason='none'):
channel = ctx.channel
overwrite = channel.overwrites_for(ctx.guild.default_role)
overwrite.send_messages = False
await channel.set_permissions(ctx.guild.default_role, overwrite=overwrite)
embed=discord.Embed(title=f'locked', description=f'reason: {reason}')
await channel.send(embed=embed)```
!codeblock
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
# lock channel command
@client.command()
@commands.has_permissions(manage_channels=True)
async def lock(self, ctx, *, reason='none'):
channel = ctx.channel
overwrite = channel.overwrites_for(ctx.guild.default_role)
overwrite.send_messages = False
await channel.set_permissions(ctx.guild.default_role, overwrite=overwrite)
embed=discord.Embed(title=f'locked', description=f'reason: {reason}')
await channel.send(embed=embed)
oh cool, always wondered how to do that
HOW DO I MAKE A SOCCER COMMAND IN DISCORD.PY
@supple thorn
Wait why does your command has self
Looking at the client.command() decorator its not in a cog
A what
Do you mean like the soccer game in dank memer's work command?
Okay
the soccer game in dank memer
# lock channel command
@client.command()
@commands.has_permissions(manage_channels=True)
async def lock(ctx, *, reason='none'):
channel = ctx.channel
overwrite = channel.overwrites_for(ctx.guild.default_role)
overwrite.send_messages = False
await channel.set_permissions(ctx.guild.default_role, overwrite=overwrite)
embed=discord.Embed(title=f'locked', description=f'reason: {reason}')
await channel.send(embed=embed)
can somebody simplify this for me please
help me bitches
Warn
bruh
Wdym simplify?
make it shorter if possible
help me :(
im still learning dpy
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
fuck off
bruh what
dude why can't you elaborate
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
all these mfs lead to errors
all the elaboration you'll need
the fuck man
watch your language kiddo
to bad sounds like a you problem
Hey. How do I make the bot send specific messages (e.g. NSFW materials) on NSFW channels only? I tried reading the Documentation but I can't figure out anything.
we like to keel it civil here
check the channel type
!d discord.ext.commands.is_nsfw
@discord.ext.commands.is_nsfw()```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that checks if the channel is a NSFW channel.
This check raises a special exception, [`NSFWChannelRequired`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NSFWChannelRequired "discord.ext.commands.NSFWChannelRequired") that is derived from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
Changed in version 1.1: Raise [`NSFWChannelRequired`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NSFWChannelRequired "discord.ext.commands.NSFWChannelRequired") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure"). DM channels will also now pass this check.
no one here is forced to help you yk
Yeah cant think of a way on how to simplify more than that
😢
alright thanks
oh you can and allot
Okay
lol
@umbral night she has what you need
can u help me
no
LMAO
why
how
useless variable better type hints return types no need for embed class instances etc if youre going by memory optimization
you can only index it with an int
can u simplify it the best u can for me please lol
# lock channel command
@client.command()
@commands.has_permissions(manage_channels=True)
async def lock(ctx, *, reason='none'):
channel = ctx.channel
overwrite = channel.overwrites_for(ctx.guild.default_role)
overwrite.send_messages = False
await channel.set_permissions(ctx.guild.default_role, overwrite=overwrite)
embed=discord.Embed(title=f'locked', description=f'reason: {reason}')
await channel.send(embed=embed)
I barely know python idk what a int is
a solid number is an int a decimal is a float
How do I fix it
!e
print("lol"[1])
@slate swan :white_check_mark: Your eval job has completed with return code 0.
o
python counts from 0
how do i convert js code to py
doubt you can
thats like changing a person to another person
you cant theyre both unique
I tried using it like this but it doesn't send any in both SFW and NSFW channels. What did I do wrong?
@bot.command()
async def nsfw(ctx):
if discord.ext.commands.is_nsfw() == True:
ctx.send("NSFW material URL")
else:
return
Sorry, I'm still a beginner.
typo
Oh wait.
if discord.ext.commands.is_nsfw
- you arent checking the channel
- use
is - .send is a coro
- useless else
My code didn't have any typo. But it still didn't worked.,
reason 1 lol
You would use it as a decorator
@slate swan
Oh I get it now. Thanks. I thought it's a function.
decos are functions.
I mean, those things that you put "@" in front?
yes
those are decorators which are functions
def deco():
def method():
...
is how theyre done
Oh ok ok. Thanks.
You’d have to return method to make it actually work
how do you specify a role
yeah
Specify? Elaborate
like uh
get it? or
Decorators are basically just syntactic sugar for deco(args)(wrapped)
Nice explanation
(ctx.guild.default_role) instead of this, how could I specify a role ive created
kinda yeah
just to change how a method works or behaves
!d discord.Guild.get_role
Or just store it in a variable if you are creating it in your code in the same function
No documentation found for the requested symbol.
Lmao
f
!d discord.Guild.get_role
get_role(role_id, /)```
Returns a role with the given ID.
inside the methods params
before it
ah ok
In the get_role method, first argument
/ makes all arguments before it positional
what
just like * which makes all arguments after keyword
yes
its an example
and it will always return none if you add a string aka you do "1234567890"
is a string something you put in quotes?
or would that raise an error as a bad arg im not sure
that is so
ohhhhhh
so no string
just the plain id
role = discord.Guild.get_role(role_id)
'''Role id should be an integer (aka without quotes)'''
yep
ty both sm
shouldve add the bot instance
so he wouldnt get confused
Its your wish smh
🏃♂️ why bot instance tho?
gosh im an idiot no you dont need it
where would i put that in this code
overwrite = channel.overwrites_for(ctx.guild.default_role)
it accepts a guild obj jeez ashley correct me😖
wait sorry
What?
@client.command()
@commands.has_permissions(manage_channels=True)
async def lock(ctx, *, reason='none'):
channel = ctx.channel
overwrite = channel.overwrites_for(ctx.guild.default_role)
overwrite.send_messages = True
await channel.set_permissions(ctx.guild.default_role, overwrite=overwrite)
embed=discord.Embed(title=f'locked', description=f'reason: {reason}')
await channel.send(embed=embed)
xD, Bth are alright
instead of the default role
where would i put this
OH
basic oop
🥂 really recommended to learn some OOP before trying bots
and async programming :(
so like this?
(ctx.guild.get_role(role_id))
without the extra parenthesis
if its just raw
yes that would work, role_id must be an integer
Yeah
yep
@slate swan long timeeeee
Brackets
no ()
oh
on a short break :p
i have my preboards from 2nd march
the outermost brackets
Oh lmao, idk, what those are but good luck, face it and ace it
I'll say no more since ot ;-;
its a method not a property
(ctx.guild.get_role(role_id))
role = ctx.guild.get_role(1773839338383738)
useless var
so this?
overwrite = channel.overwrites_for ctx.guild.get_role(role_id)
would that make sense
or do i need to keep the 'outermost' brackets
for that situation you do need them
role = discord.utils.get(ctx.message.guild.roles, id = int("1233445333")``` 😳
Hi does any one know to make the bot ask questions and then after all question is answered it will post the results in dms, in an embed
😫
!d discord.ext.commands.Bot.wait_for utilise this with message as the event
wait_for(event, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.
The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.
In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
This has to be a joke
I dont think u get my point
know to make the bot ask questions and then after all question is answered
what are you planning to do to get those answers?
Well how to make embeds for it and type in the questions u want it to be asked
you mean modals?
Can’t tell if your being serious or not 😔
use the discord.Embed object and construct the embed?
🏃♂️ was kidding
🤠
GatewayBot.cache.get_role(id) 🤲 hail hikari
Naw Rin, rin.Role.cache.get(id)
so basically, just enter the snowflake and get the object 😎 smart move
wait how does that work? <a role object>.cache.get(id)?
oh get it, its multiclassed with Cacheable
so ill assume most of the models have a cache property>
How do you make it have this?
Yea, classes that inherit Cacheable have the cache property
Caching is due for a refactor soon, I’ll be cleaning it up prob
ok how do i make it mention the user who runs the profile command?
async def embed(ctx):
embed=discord.Embed(title="Profile", description="", color=0xFF5733)
await ctx.send(embed=embed)
ctx.author.mention
async def start(ctx):
embed=discord.Embed(title="Profile",
description="{ctx.author.mention}", color=0xFF5733, inline="true")
await ctx.send(embed=embed)```
Like that?
f"{ctx.author.mention}"
ok
async def start(ctx):
embed=discord.Embed(title="Profile",
description=f"{ctx.author.mention} /n/n ✅Verified 18+✅", color=0xFF5733, inline="true")
await ctx.send(embed=embed)```
to make this
is inline even a valid parameter in the embed constructor? huh?
!d discord.Embed
class discord.Embed(*, colour=Embed.Empty, color=Embed.Empty, title=Embed.Empty, type='rich', url=Embed.Empty, description=Embed.Empty, timestamp=None)```
Represents a Discord embed.
len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.
bool(b) Returns whether the embed has any data set.
New in version 2.0.
Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty").
For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") for you.
it isnt
ohh lol
ok well i thought that would make it start a new line
- not a kwarg
- it's not a string
- its
=
smh, thats a field
!d discord.Embed.add_field
add_field(*, name, value, inline=True)```
Adds a field to the embed object.
This function returns the class instance to allow for fluent-style chaining.
infernum saves the day
no u
smh
ohh sorry this shows u that i know alot of python when i dont even know what i am trying to accomplish out of the embed
lol if that make sense
its totally normal rofl
ok that worked now how do i move verified 18+ text to the centre?
I think you need to space it
try it though
ew spaces
inline=True btw
no, stopppppp
its a boolean not a string
first see the docs before helping wtf
ITS NOT VALID ANYWAYS
i use inline = True in my bot -_-
no.
thats a field
fixed that before u even said it
oh in a field
!d discord.Embed
😳 wtf
class discord.Embed(*, colour=Embed.Empty, color=Embed.Empty, title=Embed.Empty, type='rich', url=Embed.Empty, description=Embed.Empty, timestamp=None)```
Represents a Discord embed.
len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.
bool(b) Returns whether the embed has any data set.
New in version 2.0.
Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty").
For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") for you.
ITS VALID ALWAYS it worked for me all the time
yea thats valid in a field
thats a FIELD
she is talking about add_field
Wtf guys
what the hell is a boolean never heard that before
YEah? It isn't in the starting header I know that?
True False thing
Um that's a primitive python type
ohh the inline
bruh
DUde what are you thinking your confusing me
add_field --> inline=True
!e
a = True
print(type(a))```
@vale wing :white_check_mark: Your eval job has completed with return code 0.
<class 'bool'>
header --> inline="true" this is what I know
thats invalid
its a boolean
oh god
bro if you dont know even that go refresh on some python
Any way lets get back to the topic
and btw its only valid for add_field
^^
k
ok you guys either need to stop flexing how much python you know or just leave tbh
flexing?
we aint flexing. You know wrong information so we correcting
I did not even see its not in a field I saw inline="ture" and I said it
here's ashley cring about it
very unprofessionally
what....
I ain't your pal or shit show some respect
"ture"
just to clear the confusion
was typing fast 
Understandable
for that you need to be a respectable person
just do what you are doing I'll leave
alr
bye
you'll have to space it manually no other way
spacing aint working too-
idk but this invisible spacing works -
<>
the space between these triangle stuff whatever
copy paste that
async def start(ctx, User):
embed=discord.Embed(title='Profile',
description= User=f"{ctx.author.mention} /n/n :white_check_mark:Verified 18+:white_check_mark:", color=0xFF5733, inline="true")
await ctx.send(embed=embed)
I want it to start User: and then {ctx.author.mention} is this right?
description = User = ?
'str' object does not support item assignment
def update_farm(user, i, waht):
user = str(user)
gni = check_farm_decoded_all(user)
gni[i] = waht
cur.execute("UPDATE farm set DECODED = ? where NAME = ?", (gni,user))
conn.commit()```
i friggin tired
that's not how embed work at all
!d discord.Embed
class discord.Embed(*, colour=Embed.Empty, color=Embed.Empty, title=Embed.Empty, type='rich', url=Embed.Empty, description=Embed.Empty, timestamp=None)```
Represents a Discord embed.
len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.
bool(b) Returns whether the embed has any data set.
New in version 2.0.
Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty").
For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") for you.
- inline isnt a kwarg in Embed(), it is in Embed.add_field()
- inline takes a bool not str
User: @jade tartan
that's not how python works
"User: " + ctx.author.mention
i always forgor
f"User: {author.mention}"
show full traceback
arent u can use dat format smth thing
"user: {}".format(ctx.author.mention)
if wrog yes, i not really remember
Traceback (most recent call last):
File "C:\Python310\lib\site-packages\discord\ext\commands\core.py", line 167, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\User\Downloads\PycharmProjects\main.py\main.py", line 742, in farm
database.update_farm(name, idk, str(e))
File "C:\Users\User\Downloads\PycharmProjects\main.py\database.py", line 809, in update_farm
gni[i] = waht
TypeError: 'str' object does not support item assignment
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Python310\lib\site-packages\discord\client.py", line 351, in _run_event
await coro(*args, **kwargs)
File "C:\Users\User\Downloads\PycharmProjects\main.py\main.py", line 178, in on_command_error
raise error
File "C:\Python310\lib\site-packages\discord\ext\commands\bot.py", line 994, in invoke
await ctx.command.invoke(ctx)
File "C:\Python310\lib\site-packages\discord\ext\commands\core.py", line 894, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Python310\lib\site-packages\discord\ext\commands\core.py", line 176, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'str' object does not support item assignment
``` dis
why? that's unnecessaary, f string does it all
what is gni
idk
@heavy folio
async def start(ctx):
embed=discord.Embed(title='Profile',
description= "User: + "{ctx.author.mention} /n/n ✅Verified 18+✅", color=0xFF5733, inline="true")
await ctx.send(embed=embed)
oh
try it and see
now what is check_farm_decoded_all
what object type does it return
That definitely will not work
and it's \n not /n
def check_farm_decoded_all(user):
user = str(user)
cur.execute("SELECT DECODED from farm where NAME = ?", (user,))
check = cur.fetchone()
s = check[0]
return s```
red???
basic python
Yeah told you
how ur eyes not hurt
Theres also no f string in the description so ctx.author.mention also will not work
For now
Probably thats why
ok now idk what type of object DECODED is, str?
red vs code (for me) is worse than light mode
description= f"User: + "{ctx.author.mention} \n\n ✅Verified 18+✅", color=0xFF5733, inline= true)
if in DB, dat's txt
for the last time im saying inline isnt a kwarg in Embed()
text yeah
r u kidding
now the error explains it all
WHY COMBINE F STRING AND "+" BRUH
hold up
ok, now how to fix
You didnt fix the earlier error
From there?

And you dont need a + if you are already using a f string
bruh, i dont even use f string
Just remove the second quote
and da plus sign ||ig||
wait, space list name is OK???
and, no
me 2
you basically cant do "string"["something"] = something
i think i fixed it by my self
my own
there dawg
now how to fix
Nice job
Bad. F strings >> .format, string concatenation(+)
firstly do you understand your error now
??
i just needed a hint but i seemed to have got it already
"basically cant do "string"["something"] = something"
what are you trying to do over here gni[i] = waht
str + str >>>> f strings
replace the "i" item of "gni" with "waht"
helo ashley
Hi sal
a w a i t
what
ur last problem with me xd
oh rofl
dont really understand but in a nutshell you wanna replace something in the db am i right
y e s
uncannier
alr so that's not how you do it
you gotta execute a query and commit it, this isnt like json or something
i hate nitro users except when they gimme one
......
what
ok good
🗿 👍
haters will hate
mmm, floors here made out of floors
string concatenation cringe 
cute-
execute something like this just with an update query
wait, so in my problem how i supposed to do it
Maybe in the next one you will say f-strings >> + 
and also uh i advise you use aiosqlite/asqlite/postgre because dpy is an async lib
https://pypi.org/project/aiosqlite/
https://github.com/Rapptz/asqlite
https://magicstack.github.io/asyncpg/current/
i use SQLite
How do i make a text in the embed in the centre?
i hate replit db
How did you make each field background fully black
because it isnt even a db
sqlite isn't async, aiosqlite is
eh shit i meant asqlite by danny
You wont see me here from the next month "maybe", save the pain
....
in my prob, how
do you know basic sql
"maybe"
What's even happening here 👀
kinda? idk
h e l l o
U do know that #databases exists, right?
Smh
#discord-bots exists too xD
lets move there but anyways their problem went from this to executing stuff
But this is for help and discussions regarding the Discord API, not databases
How do i make a text in the embed in the center?
I mean, do you ever see this channel on-topic?
there's no point in telling people to go to the appropriate channels
they won't

use invisible spaces
codeblock
U can't
Sadge
well that may look good on pc or something but discord's embed padding is horrible so it will look horrible on mobile
Hmm, sadly
wait, just " " wont help?
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.

nope
no
no because i think discord removes spaces unless in codeblock
Nope
noooo ok
e
Different platforms format differently
--
copy paste the space between the hyphens
im confused on how to make my code solve direct porportion
e
help
r a c i s t ||jk||
\u200b 
that question is really vague
doesn't work on mobile
Yeah it isnt the same type of dark as a codeblock
rip
thats way too easy, tell something harder
do u know what direct porportion is
Work smarter not harder
work hard and smart
dont work
lol
learn malbolge language
I'd rather gibberish, thanks for the suggestion
now !ot
Ot channels are fake made by aliens
wao
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
agreed

no
my job here is done
Helped all the planet
description= f"User: {ctx.author.mention}, value="**➤ Name:** `✅Verified 18+✅`\n **➤, color=0xFF5733, inline="True") How does that look?
Remove " " from True
done doesnt help
that hurt my brain
show the full embed structure
embed doesn't have a value, or online kwarg
async def start(ctx):
embed=discord.Embed(title='Profile',
description= f"User: {ctx.author.mention}, value="**➤ Name:** `✅Verified 18+✅`\n **➤, color=0xFF5733, inline=True)
await ctx.send(embed=embed)
???
whats the problem
Is it even worth trying to code a discord bot in python since from what I heard python is no longer supported with discord?
Well am trying to make this like center on the embed
Where did you hear that
Do you mean that discord.py is no longer maintained or
Yeah
no, one library stopped development, and 10 new libraries popped up
just use disnake, its literally discord but better
Or hikari
^^
but im not sure if this works inside embed descriptions
hey i need sum help w discord im working on a bot and sometimes it sends alot of text anyway to count that text and if its above disc's limit to send it into a txt file?
So it’s still worth making it in python?
of course
lots of libraries have continued on the work of discord.py
Ok thanks didn’t wanna put a lot of time in it and have to switch it over lol
except:
await ctx.send(now_plus_30m = now + datetime.timedelta(minutes = 30))```
I created this cmd But the embed is sent not with the timestamp or whtever this code line does
Any help?
Do you even know what that does? 
I just told that in the msg
Ok lemme be straight I just want a timestamp for 30 minutes
Like this:
Every time i run the cmd it should start from current time
You forgot to await something
Show code and the full error
did you await that?
await it then..
send the message with the embed together
send(content=..., embed=...)
!d asyncio.run you can use this
asyncio.run(coro, *, debug=False)```
Execute the [coroutine](https://docs.python.org/3/glossary.html#term-coroutine) *coro* and return the result.
This function runs the passed coroutine, taking care of managing the asyncio event loop, *finalizing asynchronous generators*, and closing the threadpool.
This function cannot be called when another asyncio event loop is running in the same thread.
If *debug* is `True`, the event loop will be run in debug mode.
This function always creates a new event loop and closes it at the end. It should be used as a main entry point for asyncio programs, and should ideally only be called once.
Example...
Run the async function using asyncio.run
Hello
hello
Ok what am trying to do i am trying to have an embed and have my bot ask questions. but then at the end it should send the results? if that make sense?
How do I make it so that my delete channel command only works in a certain category
@bot.command()
async def close(ctx):
await ctx.channel.delete()
await ctx.send("Successfully deleted the channel!")```
mhm, why are you doing ctx.channel.delete()?
So it deletes the channel your on
ok so you don't want to delete the channel by id
Can I have link for short time timestamp creator?
I have one
Send
Short time
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
:-:
Creating a short time timestamp
O mb
@slate swan you can use a list
yes it will but with list you can have more than 1 categories whitelisted
I only want 1
I want the cmd to say in 30 minutes
Either inside the embed or in. Normal message
@honest shoal if channel.id (id): await ctx.delete() else: await ctx.send(“channel cannot be deleted”)
Would that work?
Na In (id) I’ll put the id
Any one know how to do that?
yes
not directly, I meant something like that
no first you need to get the category
I have the id?
.
!d discord.Guild.categories
property categories: List[discord.channel.CategoryChannel]```
A list of categories that belongs to this guild.
This is sorted by the position and are in UI order from top to bottom.
do tasks.loop
Like this?
yes
no
there's an error in it
remove the now_plus_30m
Ok
Including the =
How do I set so a user can only use !open channel command once
So they can’t have multiple channels at once
you're missing a paranthesis
Oh kk
Now the embed is sent
yes
With?
U r missing a bracket in that line after hEmbed)
i'm making a bot that reads apis and sends the parsed output but sometimes the response can be a lil long anyway i can read if its at disc's limit and if it is send as a txt file?
await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.
To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.
To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
yes but how do i read
Pass in an instance of discord.File
it and how do i turn resposne content into a txt file?
from io import BytesIO
content = "the_text_to_send_as_a_file"
buffer = BytesIO(content.encode('utf-8'))
file = discord.File(buffer, filename='text.txt')
await ctx.send(file=file)
ty
Indeed that. Thanks invalid-user!
from dpy server
and how do i read the content of the resposne and calculate how long it is and see if its above the
limit
u can use len()
check if len(content) > 2000: write in txt
love u
no thanks
stuf
Lmao
Still does not work
After I put parenthesis before (now and between the last two )’) it says the code line when I run the cmd
@bot.command()
async def close(ctx):
if CategoryChannel.id :
await ctx.delete()
else:
await ctx.send("failed")
How do you define category id
Anybody having short time timestamp for 30 minutes from now?
Just use time.time() and do something like
min_after = time.time() + 30*60
Inside an embed
Will it work?
@maiden fable
Um
Any help?
It says f-string expected ‘}’
In the console
when setting as command, how can I restrict it to X servers? 
code?
@bot.command()
async def close(ctx):
if CategoryChannel.id :
await ctx.delete()
else:
await ctx.send("failed")```
How do you define category id
kk wait
async def heist(ctx, arg, arg1, arg2):
channel = ctx.channel
await ctx.send('<@&939441511433658389> \n :dot::money: **Dank Industries Heist Starting!** :money::dot:')
try:
hEmbed = discord.Embed(title=f"⏣ {arg}", description=f"Sponsor: {arg1} \n f"min_after = time.time() + 30*60" \n Requirements: \n \n:dot:Grab **Heist Ping** role to get ponged! \n:dot:Withdraw coins: `pls withdraw 2000` \n:dot:Use a life saver.")
hEmbed.set_footer(text=f"Thank the grinders too")
await ctx.send(embed = hEmbed)```
@bot.command()
async def close(ctx):
if CategoryChannel.id :
await ctx.delete()
else:
await ctx.send("failed")```
How do you define category id
why is there another string inside the string
get an instance of it
Can u edit the code and sent the correct one is possible?
that is spoonfeeding
k
Can you explain in greater detail
This comes when the cmd is ran
do you know what ctx is?
Yes
what is it?
!f-strings
Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.
>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."
Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.
you're not using it correctly
I use ctx for my commands
@client.event()
async def on_member_update(ctx, before, after):
with open('log.json', 'r', encoding='utf-8') as f:
guilds_dict = json.load(f)
if before.display_name != after.display_name:
embed = discord.Embed(title="Nickname change",
colour=after.colour,
timestamp=datetime.utcnow())
fields = [("Before", before.display_name, False),
("After", after.display_name, False)]
for name, value, inline in fields:
embed.add_field(name=name, value=value, inline=inline)
channel_id = guilds_dict[str(ctx.guild.id)]
await client.get_channel(int(channel_id)).send(embed=embed)
elif before.roles != after.roles:
embed = discord.Embed(title="Role updates",
colour=after.colour,
timestamp=datetime.utcnow())
fields = [("Before", ", ".join([r.mention for r in before.roles]), False),
("After", ", ".join([r.mention for r in after.roles]), False)]
for name, value, inline in fields:
embed.add_field(name=name, value=value, inline=inline)
channel_id = guilds_dict[str(ctx.guild.id)]
await client.get_channel(int(channel_id)).send(embed=embed)
Error:
@client.event()
TypeError: Client.event() missing 1 required positional argument: 'coro'
what the
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
if i remove the event not work
remove the ctx arg
hover over the red line
timestamp=ctx.message.created_at
nope
my timestamp work
the channel id with ctx
also u should try looking into format_dr
ok
!d discord.utils.format_dt
discord.utils.format_dt(dt, /, style=None)```
A helper function to format a [`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "(in Python v3.9)") for presentation within Discord.
This allows for a locale-independent way of presenting data using Discord specific Markdown...
just use member.guild.get_channel or bot.get_channel
how?channel_id = guilds_dict[str(ctx.guild.id)]
member not definied
Whats not working?
i need some help
How to add reaction to a embed the bot sent
can you help me
i need some question
i have an error
K bye, good luck answering them all
Ignoring exception in command None:
discord.ext.commands.errors.CommandNotFound: Command "java"
the code
question not questions
Lmao
What is wrong with this code its doesnt work
u forgot () in the command deco
indent
First get the message then user the add_reaction method on the Message object
!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
let me see
nothing tab in the code
Code?
It isnt working though
pm me
Me?
Ignoring exception in command None:
discord.ext.commands.errors.CommandNotFound: Command "java"
After the embed.set_footer(text=“....”)
?
here @bot.command()
async def java(ctx):
embed=discord.Embed(title="java", url="https://www.java.com/en/", description="java is an programming language created by James Gosling in 1995 in Indonesia,java is an a high-level, class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible", color=discord.Color.red())
embed.set_author(name="the reaper", icon_url="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTRLn8pIOVf-ZA6DUrwCp9AQMrl1EXS7-dtLOI21WcvsKvA9-g6d-4y6_pT7t-c_H-FP0c&usqp=CAU")
embed.set_thumbnail(url="https://upload.wikimedia.org/wikipedia/el/thumb/d/d0/Java.svg/1200px-Java.svg.png")
embed.timestamp = datetime.datetime.now()
embed.add_field(name="Fun fact", value="java took its name from an oak tree that stood outside Gosling's office. Later the project went by the name Green and was finally renamed Java, from Java coffee, a type of coffee from Indonesia.", inline=False)
embed.add_field(name="programs java has contrubite", value="Minecraft,Amazon,Uber,Linkedln,Spotify,Netflix,Google", inline=False)
embed.add_field("java beginners courses", value="12 hours beginner course", inline=True)
embed.set_footer(text="Information requested by: {}".format(ctx.author.display_name))
embed.set_image(url="https://miro.medium.com/max/1400/1*5h3Fv82Gsilyhh2URcIVZA.png")
await ctx.send(embed=embed)
Java tutorial for beginners full course
#Java #tutorial #beginners
⭐️Time Stamps⭐️
#1 (00:00:00) Java tutorial for beginners ☕
#2 (00:20:26) variables ❌
#3 (00:32:58) swap two variables 💱
#4 (00:36:42) user input ⌨️
#5 (00:44:40) expressions 🧮
#6 (00:49:13) GUI intro 🚩
#7 (00:55:01) Math class 📐
#8 (01:01:08) ra...
yeah
weird
!paste please paste the code here
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.
what do you mean
un-indent it
Still can’t find where you put the add_reaction
I am trying to use sub command but it sends the main command as well as the sub command
bro wrong ping
how do i prevent that?
Atleast then tell me :-:
set invoke_without_command=True in the parent function's decorator
sure
its absolutely massive including the sub commands tho
cuz there are like 14 or so
wait lemme send
send the group only then I guess
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
oof
i put it under wrong decorator ☠️
sorry 🙏
thx xcrino for helping its now working like a charm

Help it shows expected a intended block though the code looks like good to go
tab in 9 line
bro your token just make it env
learn python basics first
Using tablet
make your token secure
Ok but I censored it
yea but your repl is public
No one will find it
yea true but i am just telling you its better to be secured
Ok but can you help
yea
I am in tablet
ok send the error message
Fix your indent
!indents
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
Can I get a screenshot of what it should look like aswell?
you need to make indent on 9 line i said
No.

Probably you should learn python before doing bots
If you don't know at least the basics don't expect you go too far with your code, indents are some basic knowledge in python

I am in tablet bruh
Then stop coding on tablet, that's just an excuse
Also in english and in all of the programming languages
you can just place spaces
Ok thx
Is there any way to make a cmd like:
-da 1,000,000 @slate swan
The bot responds with
Successfully added 1,000,000 amount donation fro @slate swan
And if I use the cmd again with different amount
It should add the amount to the previous amount the user donated
what's the problem?
No problem :-:
I asked if it is possible to make like that
ofc possible
Hi, how to keep calling a function every 5 secs and also keep calling another function every 10secs ???
@commands.command()
async def da(ctx, amount, member: discord.Member):
#load data from your db
data[member.id] += int(amount.replace(",", ""))
#pu data to ur db
await ctx.send(f"Successfully added {amount} amount donation from {member.mention}")
yes
Ummm
:O
ANYWAYS
WHERE THE CODE?
@slate swan also did u know, replit has a discord.py template
Sad replit
async def da(ctx, amount, member: discord.Member):
#load the data from your db
data[member.id] += int(amount.replace(",", ""))
#pu data to ur db
await ctx.send(f"Successfully added {amount} amount donation")```
Did you just
Copy it without having a database
embed.add_field(
name = "Language",
value = f"`{language}`"
)
``` how can i get the first letter of language to be capitalized ? :)
you can use language.title() to get it in title case
oke thank
np
@desert badger
hi
Are u a snake or python
Couldnt think of your username at the top of my head so using alec now
idk honestly i just googled snek emoji 
:meme:


Betterdiscord
I actually just have them copied at all times
Since i made them
Wha-
Wanna see the originals
can someone help me with something | if yes dm me | it's an easy error Im sure that Im having problems with
Ok
Sending an image doesn't mean they are using another discord client
what the-
?
I self advertised
wow
that was some high level advertising 👍


