#discord-bots
1 messages ยท Page 694 of 1
๐คฆโโ๏ธ
and that video is literally shit, he doesn't even explain what the code does
hmm
Basically showing syntax only?
My bad for the ping shouldve turned it off
yes
Dang does tutorials suck
whats the good tutorial for making a discord music bot then? Now that rythm is also ded?
Not really much since yt's tos
i just learned by trying to make projects and learning my issues with non cheating questions that just helped me know how to solve my solution
id rather stick to web dev and html, css and all cuz that sh** easier
Solve a solution? Congrats tho
ong
nice
ty
but python is interesting tho
Proud of you keep it up
ofc
I mean you can say that
there's a similar program to python called small basic. Its a programming app for kids and easier than programming languages
small basic?
yes
tf
!ot
Off-topic channel: #ot2-never-nesterโs-nightmare
Please read our off-topic etiquette before participating in conversations.
So your saying python is for kids?
no
stop going off topic
but small basic is
bruh
My bad discord moderator
indeed
ok lester
who's lester?
BRUH
Watch beluga
LMFAO
He cute tho ngl
๐
๐คฃ
No but really lets stay on topic
!ot
Off-topic channel: #ot2-never-nesterโs-nightmare
Please read our off-topic etiquette before participating in conversations.
.
...
Yeah lets stay on topic
k
the main problem im facing while making music discord bots is the indentation. Otherwise, when I made the messaging discord bot, it was fine
maybe cuz i did the indentation right who knows?
Indentation?
uh huh
Of all things indentation?
yes
Your kidding?
Indentation is the basics of any programming language though?
and ofc the .env file
Ikr
Read pep 8 lol
never found difficulty in indentation in any other languages
Its 4 spaces.
except python
You gotta be joking indentations in python is so easy lol
nah
!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
why did the code have to be dependent on indentation
every problem i had in making the bot was syntax errors and indentations
I mean it isnt even that hard
def func():
...
class Cog:
def __init___(self):
self.arg = ...
async def do_stuff(self):
...
the errors you got were basic python mistakes though
You forgot the colon in the func lol
f?
added to the fact that i've never gone past print('Hello world!') in python...
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
^^
!pep8
PEP 8 is the official style guide for Python. It includes comprehensive guidelines for code formatting, variable naming, and making your code easy to read. Professional Python developers are usually required to follow the guidelines, and will often use code-linters like flake8 to verify that the code they're writing complies with the style guide.
More information:
โข PEP 8 document
โข Our PEP 8 song! :notes:
ยฏ_(ใ)_/ยฏ
This will be useful to
Just use Flakes8 or Black. It will make u follow PEP8
Does pylance make you follow pep8?
There should be 2 spaces after a hashtag before a comment, yes. But PyLance is a type checker and not a linter
Nah i ment indentation level
An in a comment i always use 1 lol
I forgot again.. what is Flake8?
!ot
Off-topic channel: #ot2-never-nesterโs-nightmare
Please read our off-topic etiquette before participating in conversations.
Hes just helping me smh
ty
This discussion doesn't suit this channel tho
Ik but atleast its not trolling tbh
Like my bad for getting a bit off topic
Why pypi command uselessly
I just wanted something really sorry
I just wanted the embed pic ๐
Haha cool
!ot
Off-topic channel: #ot2-never-nesterโs-nightmare
Please read our off-topic etiquette before participating in conversations.
.....
#bot-commands exist though
I am really sorry
No need
its ok just asking
Why even use repl
i dunno, the tutorial guy was using replit
Oh lord no please don't use replit
And do not watch tutorials
Docs bro
Or this
https://tutorial.vcokltfre.dev/
A tutorial on how to use discord.py to create your own Discord bot in Python, written to fix the flaws of many other popular tutorials.
Do not watch those rubbish youtube tutorials
Specially not that guy who uses replit
eh replit good but its database is shit, took me 30 seconds to fetch 30~ keys ๐
can we make the bot in pycharm?
replit is not good at all
Slow bandwidth
Rubbish database
Rubbish packaging system
Not made for deployement
OFC u can your IDE doesn't decide your code
oh ok
@sullen shoal 
Freecodecamp?
Just install discord.py(or any other wrapper) and you're good to go
- Whats bandwith
- Agreed
- How?
- Idm
Bandwidth is a range of frequencies within a given band, in particular that used for transmitting a signal.
- Slow rubbish packaging
1st answered ^
It isnt slow, your just impatient
ยฏ\_(ใ)_/ยฏ
Why even use something so rubbish there are many limits
out of curiousity, is anyone a hacker here? White hat one?
I am learning shit bout cyber security
i mean i dont think it has many limits
But off topic
Use selenium on repl then come back to me and say that
No idea what selenium is
Didn't expect any worse
?
!pypi selenium
!ot BTW
Off-topic channel: #ot2-never-nesterโs-nightmare
Please read our off-topic etiquette before participating in conversations.
Whats wrong with using that on replit then
its all good till its python right?
You can't-
Nope it's all good as long it's related to #discord-bots
k
why did you tell me to use it then??
lol
To show the limits of replit
u realize that replit is an online ide smartass
it isnt a local ide
And you just said replit is good for hosting
this some big brain conversation
Not at all
i mean i get good uptime
damn these guys

My bot hasn't been down since last 2 days with local host
good for you
also you can use selenium on replit but its slow asf and you cant run a webserver with it so its kinda useless most of the time
You don't get chrome binaries on replit
you get it when you select bash
Dont get it with py atleast
then you gotta do some shit to run python that i forgot
i have done it myself some months ago
Why instead of using these rubbish hacks just switch to a lot better platform
and some python modules (webbrowser) arent even usable on replit because its an ONLINE
IDE and that isnt even a con about using replit, its just because its an online IDE and not a local one
And how can we forget these
Not talking bout the IDE, talking bout hosting issues
It has went a bit too off-topic now
mainly that yes but they also have included all this shit,
Replit is a simple yet powerful online IDE, Editor, Compiler, Interpreter, and REPL. Code, compile, run, and host in 50+ programming languages.
so we kinda can say that its more than just an online ide according to them but thats outta this channel's topic to talk bout
lmao
Heh
So I've been away from the discord bot development scene for a bit, and with the cease of maintenance of the discord.py, I have a couple of questions I hope some of you guys could answer:
-
What is the urgent drawback of this lack of maintenance? I've heard some information regarding an April 2022 deadline where bots in >75 servers need to an apply for a message intent and your bot needs to make a gateway request which discord.py hasn't handled, but I wanted to verify this information and maybe get some more if there is.
-
What are some good alternatives to discord.py? I've heard that disnake and pycord are pretty good and have similar syntax to discord.py. Which do you guys prefer of the two? Are there better alternatives that you guys prefer more than these?
P.S I understand I am answering these questions at the risk of causing repetition. If there is somebody who has already answered these questions, could you please link me the message where they answered? It would be greatly appreciated. Also it would be awesome if you could ping when responding.
- No Comments on that. Choose the one you like. (I personally use and prefer disnake)
Yeah in regards to (2) I was asking based on preference, its hard to identify the objectively better alternative. Thanks for your response!
yea 2 i like disnake too
I just feel disnake is easy to use and more stable than others
Ah
Yup and it's more stable than those cords lol
Thanks!
Yeah
indents
hmm I'll check it out
Can you even do that
so that command wont register for will the onready work
big help, appreciate it
Hope you find the one you like
is cmd always = "5" ?
I don't think you can create commands inside an if statement
^^
then ofc it wont work
you need to unindent the command nuke and the onready outside the if statement
Reaction flex lol
no
Huh?
Also, for disnake users: Does disnake have cogs like discord.py?
it should work idk about same
Is this a nuke bot?
OFC cuz it is a fork after all
disnake = dpy v2 with slash commands
disnake is forked from discord.py so yes
oh nice thanks
and context commands
But be command name is nuke
aah its a fork ok then that makes sense
๐
any module that i can use to upload image and then send in the webhook using image url ?
!d discord.Webhook.send
await send(content=..., *, username=..., avatar_url=..., tts=False, ephemeral=False, file=..., files=..., embed=..., embeds=..., allowed_mentions=..., view=..., thread=..., wait=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message using the webhook.
The content must be a type that can convert to a string through `str(content)`.
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.
If the `embed` parameter is provided, it must be of type [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") and it must be a rich embed type. You cannot mix the `embed` parameter with the `embeds` parameter, which must be 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 to send.
Didn't understand
use file
i wanna send image from webhook
So just use discord.Embed IG
why does this have a ephemeral kwarg
!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.
no...not using discord api...but requests
send it then?
Everything you do on discord uses discord api
requests? the lib?
yes lib
And making raw requests is hard
that is blocking
then get the url content and then paste the image
i mean
@oak warren bruh
You prolly meant use async functions
yeah first i need convert my image into a url
Yk you can send files
Essentially if your bot is operating in less than 100 servers, the change in April won't affect the bot?
yes
It won't
ok cool
or else you can apply for message content intent
yeah
but I don't think discord.py can make the gateway request anyway
so the change in april will still affect the bot even if you apply for the message intent
so send the url discord automatically embeds it
thats the reason people are shifting over to disnake and pycord right?
yeah first i need convert my image into a url
Immage into url
idk honestly
i am talking about taking a screenshot on my pc and then using requests to send webhook to a channel .
they wanna send a file bruh
dpy now has slash commands too someone made it its called slash_util
People are shifting cuz discord.py doesn't support application commands so after the new intents if the bot gets limited they won't be able to use it anymore
dont use that, its better to use a fork and that lib prolly has limited slash features
ofc i use disnake
Yeah........
i forked it and edited disnake to discord
WTF why lol
too lazy to write import disnake as discord in everyfile
Sorry, what are application commands?
So changed disnake ~> discord in every file lmfao
slash commands
User, Message, Slash commands
aah thanks
Slash Commands including User and Message Interaction Commands
ehh i meant for the future
its mostly slash commands
User and Message Interaction Commands too
I do
smh ok
Not at all
no
slash commands are called slash for a reason lmao
oh its app commands
yes
wow discord being discord
I've gotta do some more research xd
I've been out of the discord bot loop for too long
I hope you get back soon ๐
lol I want to
at Timeout.onTimeout (/home/runner/akinator/node_modules/discord.js/src/sharding/Shard.js:163:16)
at listOnTimeout (internal/timers.js:554:17)
at processTimers (internal/timers.js:497:7) {
[Symbol(code)]: 'SHARDING_READY_TIMEOUT'
}```
wrong server
if there is anyone here using the nextcord library, did they bring support for slash commands?
what does this means
The UnboundLocalError is raised when you try to assign a value to a local variable before it has been declared. You can solve this error by ensuring that a local variable is declared before you assign it a value. (or you could use the global keyword)
>>> number = 0
>>> def increase():
>>> number += 1
>>> increase()
UnboundLocalError: local variable 'number' referenced before assignment
When adding functions or classes to a program, it can be tempting to reference inaccessible variables by declaring them as global. Doing this can result in code that is harder to read, debug and test. Instead of using globals, pass variables or objects as parameters and receive return values.
Instead of writing
def update_score():
global score, roll
score = score + roll
update_score()
do this instead
def update_score(score, roll):
return score + roll
score = update_score(score, roll)
For in-depth explanations on why global variables are bad news in a variety of situations, see this Stack Overflow answer.
> >>> def increase():
> >>> number = 0
> >>> number += 1
> >>> increase()
> ```
wut
like this?
oo global blah blah
or return blah blah
but how do i make ctx.author.id global
it will tell ctx not defined
๐ What's happening
What you wanna do actually?
i wanna defined ctx.author.id once
wap
You mean owner ID?
define that in a function and global it
yes
ok
aaaaaaaaaaAAAAAAAAAAAAAAAA
Can some1 explain??
@client.command()
async def this_command_is_so_so_secretive_that_no_one_will_ever_use_it_in_fact_never_try_to_type_it_out(ctx):
global userid
userid = str(ctx.author.id)
@loud junco
!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
ur spacing
I dont quite undertstand
indentation ;-; thats basic python wdym
its the tab spacing
I'm new
like this
and this
and this
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
learn python first
ya
Oh, fixed
thanks <3

:D
[pyflakes] unindent does not match any outer indentation level
Still doesn't work (wait)
My previous codes are fine
ss
and please
try to code on a text/code editor
replit is meh
Probably would (but can't)
Since I coded this w/ my friends
use github
100x better
LOL
what
github good
ikr
ok 
:/
pls answer me 
u cant run in github but
Replit kinda sucks
but??
ok i feel like a dumb fuck but when doing embeds
value = "Shrek
Donkey"
I need them to be on 2 separate lines but they appear in the same line.
this is a logger code ```py
@client.event
async def on_message_delete(message):
embed = nextcord.Embed(title=f"{message.author.name} has deleted a message | {message.author.id}", description=f"{message.content}")
channel = client.get_channel()
await channel.send(embed=embed)
@client.event
async def on_message_edit(message_before, message_after):
embed = nextcord.Embed(title=f"{message_before.author.name} has edited a massege | {message_before.author.name}")
embed.add_field(name="before Massage", value=f"{message_before.content}", inline=False)
embed.add_field(name="After Massage", value=f"{message_after.content}", inline=False)
channel = client.get_channel()
await channel.send(embed=embed) ```
how can i make it so it can be in more then 1 server and log and admins have perms that they can chance what chat it going to log in?
/n
what
I donโt understand
\n
oof
is it / or \
\
i want to make it so it can logge more then 1 server
k
you post the message in diff servers then
store the channel ids in a db and and use them to fetch channels
how to make verify??
for different servers or single?
just wait for button click and do the blah blah things
with button
?
how to make a button and verifications
;-; atleast answer me
idk pyton or python3
I asked discord.py version smh
sorry bro
@graceful verge how did you install discord.py?
......
pip show discord.py to see version
Store the channel idโs where you want to log in a database for each guild
Sorry I literally just saw u said the same @upbeat otter
@graceful verge
i use vps
even vps shows the version smh
Vps doesnโt just come with d py
help
with?
@upbeat otter
use a third party library for buttons
what?
!pypi discord_components
help me
dm
:/
I sent the picture on dm
How to insert dictionary python using asyncpg?
@loud junco Why can u just define the variables normally outside a function
Have you used the command?
and see if that works
def __init__(self, bot):
self.bot = bot
self.bot.loop.run_until_complete(self.create_db_pool())
@commands.Cog.listener()
async def on_ready(self):
await self.db.execute(
"""CREATE TABLE IF NOT EXISTS coba (author_id BIGINT, data TEXT[])"""
)
async def create_db_pool(self):
self.db = await asyncpg.create_pool(
database="kamus", user="postgres", password="083806637610"
)
async def add_kamus(self, author_id, key, value):
if akun := await self.dapat_kamus(author_id):
hasil = akun[1]
a_kamus = {key: value}
hasil.append(a_kamus)
update = await self.db.execute('UPDATE coba SET data = $1 WHERE author_id = $2', hasil, author_id)
return update
else:
hasil = {key: value}
coba = await self.db.execute('INSERT INTO coba (author_id, data) VALUES ($1, $2)', author_id, [hasil])
return coba
async def dapat_kamus(self, id):
akun = await self.db.fetchrow('SELECT * FROM coba WHERE author_id = $1', id)
return akun
@commands.command()
async def tambahkamus(self, ctx, key, value):
await self.add_kamus(ctx.author.id, key, value)โ
error
I donโt see the point of defining global variables in a function
Yup
Traceback (most recent call last):
File "asyncpg\protocol\prepared_stmt.pyx", line 168, in asyncpg.protocol.protocol.PreparedStatementState._encode_bind_msg
File "asyncpg\protocol\codecs/base.pyx", line 206, in asyncpg.protocol.protocol.Codec.encode
File "asyncpg\protocol\codecs/base.pyx", line 111, in asyncpg.protocol.protocol.Codec.encode_scalar
File "asyncpg\protocol\codecs/array.pyx", line 853, in asyncpg.protocol.protocol.arraytext_encode
File "asyncpg\protocol\codecs/array.pyx", line 134, in asyncpg.protocol.protocol.array_encode
ValueError: invalid array element at index 0: expected str, got dictโ
coughs
bruh
What the-
thats why my dms are always closed ;-;
@graceful verge Iโd suggest you learn python first, and get familiar with what libraries are.
๐ฆ
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
-bash: !resources: event not found
WHAT
How can I set the button size?
what is this related to?
It depends on the size of text
Like?
Otherwise you can't
Whitespaces in both sides
just give me the source code
WDYM?
We don't spoonfeed
why? Your about me says you are a developer so make it yourself
class discord.ui.Button(*, style=<ButtonStyle.secondary: 2>, label=None, disabled=False, custom_id=None, url=None, emoji=None, row=None)```
Represents a UI button.
New in version 2.0.
discord-components breaks dpy
I'm just learning python
Oh understood
empty spaces
Understood
โ ๏ธ
oof, buttons dont work in 1.7.3
That's why I never said I am a developer or they gonna ask me to make the whole API wrapper myself
Then tell them to update

lol
u mean the area command?
oo wait
here
then install 2.0 ez
;-;
help 
Yes?
youโre defining global variables inside a function, iโm saying just do it outside of the function
it's simple and it's just that 1 line of code
not code i mean pip install statement
mhm
I get "cant set attribute" when im trying to set a dict to bot.cogs. Why?
read this ๐คฆ
this
if message.content == 'c':
await message.add_reaction("\U0001F60E")
```why this is not working
why not just define user in function
Whats the error
that makes no sense, you canโt have a global variable of an author
I mean u could but why
not showing any error but not working to
Is the message actually c?
ya
@commands.command()
@commands.cooldown(1,5,commands.BucketType.user)
async def gamble(self,ctx,amount):
try:
amount = int(amount)
except ValueError:
self.bot.get_command("gamble").reset_cooldown(ctx)
return await ctx.send("You have to give an integer small brain")
if amount < 100:
self.bot.get_command("gamble").reset_cooldown(ctx)
return await ctx.send("At least gamble 100 coins")```
how to code it so if the amount is "all" it becomes an int
the channel variable isnt working. I'm trying to get it to create a channel.
this is my guild variable
guild = self.bot.get_guild(self.guild_id)
self.guild_id has the guild ID
if amount == โallโ:
โฆ?
@commands.command()
@commands.cooldown(1,5,commands.BucketType.user)
async def gamble(self,ctx,amount):
try:
amount = int(amount) or "all"
if amount == "all":
amount = await current_balance(ctx.author)
else:
amount = amount
except ValueError:
self.bot.get_command("gamble").reset_cooldown(ctx)
return await ctx.send("You have to give an integer small brain")
if amount < 100:
self.bot.get_command("gamble").reset_cooldown(ctx)
return await ctx.send("At least gamble 100 coins")```
tried this but didnt work
help ๐ฃ
yeah
need more context
How do I make a discord bot command that takes a text argument?
the indents are wrong
and what exactly u are typing for the command
a command that would be "/message {{any string text}} {{channel}}
if i type $gamble all it should take the author's current balance and execute
right
if not then the amount should be an int
Any errors?
client = commands.Bot(command_prefix= "!")
@client.event
async def on_ready():
await client.change_presence(status=discord.Status.idle, activity= discord.Activity(type = discord.ActivityType.listening, name = 'EggyinIt'))
print('logged in {0.user}'.format(client))
@client.event
async def on_message(message):
await client.process_commands(message)
if message.author == client.user:
return
if message.content == 'what':
await message.add_reaction("\U0001F60E")
print("REACT")
wait
use elif 
u have 2 if statements
put arg: str in function parameters
and for the channel?
channel: int if it's supposed to be a number
it works fine if i input $gamble int
but it returns value error when i use gamble all
its supposed to be a # arg
show error
by default all received arguments would be string
then string(?)
ok
channel: discord.TextChannel
still not working also not even print that REACT ๐ฃ
its except value error
this one
and how would i collect this data and make the bot message the string in the appropriate channel?
channel.send(arg)
arg being the received string argument and channel being a discord.TextChannel object
I know but show the output of the error
@commands.command()
@commands.cooldown(1,5,commands.BucketType.user)
async def gamble(self,ctx,amount):
try:
if amount == "all":
amount = await current_balance(ctx.author)
else:
amount = int(amount)
except ValueError:
self.bot.get_command("gamble").reset_cooldown(ctx)
return await ctx.send("You have to give an integer small brain")
if amount < 100:
self.bot.get_command("gamble").reset_cooldown(ctx)
return await ctx.send("At least gamble 100 coins")โ
don't handle the error and show the output
alright, any modules i need for all this?
the discord.py library
okay
discord
alright, thank you so much
guys is there anyway to load script from raw website?
you could get the website contents and exec() it, not saying that's the best approach though
ok lemme try
alright would this code work? ```py
@client.command()
async def messahe(ctx):
arg: str
channel: discord.TextChannel
await ctx.channel.send(arg)
why is arg: str outside the parameters
is it?

put it after ctx, e.g.
async def message(ctx, arg: str, channel: discord.TextChannel):
?
File "C:\Users\sony\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 173, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\sony\Desktop\Bot2\cogs\economy.py", line 105, in gamble
if amount < 100:
TypeError: '<' not supported between instances of 'str' and 'int'
Yeah so u canโt compare strings and integer values
convert amount to int
i did
showcode
@commands.command()
@commands.cooldown(1,5,commands.BucketType.user)
async def gamble(self,ctx,amount):
if amount == "all":
amount = await current_balance(ctx.author)
if amount < 100:
self.bot.get_command("gamble").reset_cooldown(ctx)
return await ctx.send("At least gamble 100 coins")```
@client.command()
async def message(ctx, arg: str, channel: discord.TextChannel):
client.run(TOKEN)
so that?
you did not convert it to int? Default type of parameter is str
if amount == "all"
convert amount to str here
something in the overwrites is None
how???
with await channel.send(arg) inside the function yes
hmm
str(amount)
ok
Doesn't work
does current_balance return an integer or string @slate nymph
integer
class Nitro(disnake.ui.View):
def __init__(self):
super().__init__()
@disnake.ui.button(style=disnake.ButtonStyle.blurple, label="\u200b\u200b\u200b\u200b\u200b\u200b\u200b\u200b\u200b\u200b\u200b\u200bACCEPT\u200b\u200b\u200b\u200b\u200b\u200b\u200b\u200b\u200b\u200b\u200b\u200b", row=0)
async def rickroll(self, button: disnake.ui.Button, interaction: disnake.Interaction):
await interaction.response.send_message("https://c.tenor.com/Z6gmDPeM6dgAAAAC/dance-moves.gif", ephemeral=True)```
you expect amount to be int but you still compare it to string in first if statement line, that does not make any sense?
but there will be tons of userid = str(ctx.author.id)
@commands.command()
@commands.cooldown(1,5,commands.BucketType.user)
async def gamble(self,ctx,amount):
try:
amount = int(amount) or "all"
if amount == "all":
amount = await current_balance(ctx.author)
else:
except ValueError:
self.bot.get_command("gamble").reset_cooldown(ctx)
return await ctx.send("You have to give an integer small brain")```
and userid will be undefined :/
ic
why indent :/
Thats zero width space
except ValueError:
self.bot.get_command("gamble").reset_cooldown(ctx)
return await ctx.send("You have to give an integer small brain")
``` if you allow a string as well, this is misleading message
!resources
me when terrible code logic
Yes
@slate nymph Well firstly, donโt redefine amount, use a difference variable
!resources
๐คฃ
since amount is a argument
!resources
ok
stop
#bot-commands
okay
meaning one of the roles that i put in doesnt exist?
Yes
show what's overwrites
Not working
!global
When adding functions or classes to a program, it can be tempting to reference inaccessible variables by declaring them as global. Doing this can result in code that is harder to read, debug and test. Instead of using globals, pass variables or objects as parameters and receive return values.
Instead of writing
def update_score():
global score, roll
score = score + roll
update_score()
do this instead
def update_score(score, roll):
return score + roll
score = update_score(score, roll)
For in-depth explanations on why global variables are bad news in a variety of situations, see this Stack Overflow answer.
Oh wait, I see now
i literally pressed on the accept ๐คฃ
class Nitro(disnake.ui.View):
def __init__(self):
super().__init__()
@disnake.ui.button(style=disnake.ButtonStyle.blurple, label=" ACCEPT ", row=0)
async def rickroll(self, button: disnake.ui.Button, interaction: disnake.Interaction):
await interaction.response.send_message("https://c.tenor.com/Z6gmDPeM6dgAAAAC/dance-moves.gif", ephemeral=True)```
lmfao
rickroll :/
Trying to make the button big
discord will auto remove too long spaces ig
So how to make it bigger?
u/200b
works perfectly now tysm!
hello
try adding a bunch of ** **
how do I make my bot log invite creation
just ** **
Cool
spaces
Lemme try
life if someone creates an invite, bot will send msg exampls: user created invite
any help?
Code
I just did accept
The full code please
Just copy this code block
Why is that not working for me
...

Literally fck
why cant i edit bot.cogs to another value
Wdym?
I did bot.cogs = a_dict and it said "cant set attribute"
Lemme try
Try doing discord.ext.commands.Bot.cogs = a_dict
I usually change the methods like that
ok brb
hmm interesting
\t
Very much interesting on how they made the button that big
Now try \u200b accept \u200b
where?
example
thanks it worked
.
DON'T touch the in built attrs
Why tho
Viva JavaScript
Isn't that what Kayle wants to do
It's possible that the library can break just cz u overwrote a variable u weren't supposed to 

but like i wanna make my cogs lowercase too and idk any other method to do this
Doesn't work
Doesn't work
@slate swan ignore the ping
๓
Copy this emoji
wHICH emoji?
It's a space emoji :D
Unicode
That's just unicode
๓ U+E0020 This is the unicode for the emoji tho
And it doesn't paste it in VSC
Rip
Lol
_ _
Doesn't work in the button
Ah those boxes are just VSC indicators telling u that the unicode isn't used much in source codes and will show u some alternatives/suggestions
Oooo
lemme try
Not working
noice
Emoji buttons should work maybe?
wdym
@tiny ibex which unicodes have u tried?
idk, ask hunter, igtg
\200b and the once you both gave
\u2800
lemme see
@tiny ibex what are you tryna do
Make the button big

tysm

use botvar instead of global ones
botvar userid, pogchop, cooked_pogchop, beef, steak, hp, level, highestArea, atk, defend
```like this?
or what
!botvar
Python allows you to set custom attributes to most objects, like your bot! By storing things as attributes of the bot object, you can access them anywhere you access your bot. In the discord.py library, these custom attributes are commonly known as "bot variables" and can be a lifesaver if your bot is divided into many different files. An example on how to use custom attributes on your bot is shown below:
bot = commands.Bot(command_prefix="!")
# Set an attribute on our bot
bot.test = "I am accessible everywhere!"
@bot.command()
async def get(ctx: commands.Context):
"""A command to get the current value of `test`."""
# Send what the test attribute is currently set to
await ctx.send(ctx.bot.test)
@bot.command()
async def setval(ctx: commands.Context, *, new_text: str):
"""A command to set a new value of `test`."""
# Here we change the attribute to what was specified in new_text
bot.test = new_text
This all applies to cogs as well! You can set attributes to self as you wish.
Be sure not to overwrite attributes discord.py uses, like cogs or users. Name your attributes carefully!
bot.whatever = "hello"
#usage eg
await ctx.send(bot.var) #in theory it should work
you store them to bot variables and can use them like bot.<variable_or_whatever_you_named_this> and do what ever you want
they will be usable all over that file (or if you would use cogs it would be usable in those cogs)
why not?
just do the global thing
ยฏ_(ใ)_/ยฏ
literally everyone does that though
theres no way you could make a variable containing ctx.author.id since ctx is gonna be undefined
ya
thats the problem
but all my variable is like this
pogchop = db[userid + 'pogchop']
cooked_pogchop = db[userid + 'cooked_pogchop']
beef = db[userid + 'beef']
steak = db[userid + 'steak']
hp = db[userid + 'hp']
level = db[userid + 'level']
highestArea = db[userid + 'highestArea']
atk = db[userid + 'atk']
defend = db[userid + 'defend']
so userid is going to be undefined as well
I don't think global is the way to go
use f strings? idk
uh
could you explain again what you want to do @loud junco
i have tons of variable
and some of the commands share the common variable
i dont wanna repeat to call the variable
so i wanna make them global variable
!global
When adding functions or classes to a program, it can be tempting to reference inaccessible variables by declaring them as global. Doing this can result in code that is harder to read, debug and test. Instead of using globals, pass variables or objects as parameters and receive return values.
Instead of writing
def update_score():
global score, roll
score = score + roll
update_score()
do this instead
def update_score(score, roll):
return score + roll
score = update_score(score, roll)
For in-depth explanations on why global variables are bad news in a variety of situations, see this Stack Overflow answer.
???
so you just have global foo, bar, foobar and add the values you want?
I don't ever use global so I can't really help
maybe the global stuff might fit in #โ๏ฝhow-to-get-help / #python-discussion
Put global above the def
so
global wasd
wasd=4
global variables above function
Why not just tell it to return x?
wdym
this isnt really a discord specific problem, you'd have better luck opening a help channel
In the first function, just add return x...
ok
In 2nd do x = myfunc()
Don't see how...
from discord.ext.commands import bot
from discord.ext.commands.bot import Bot
from discord_slash import SlashCommand
from discord.ext import commands, tasks
import discord
from discord import message
from discord import channel
client = commands.Bot(command_prefix='!')
slash = SlashCommand(client, sync_commands=True)
TOKEN = 'Secret Token'
@client.command()
async def message(ctx, arg: str, channel: discord.TextChannel):
await channel.send(arg)
client.run(TOKEN)
anyone know why its not working?
it doesnt even show up in the command menu as a command
it takes upto 1 hour or more than 1 hour to register slash commands
so it needs to run that long?
wait its not a slash command?!
@slash.slash(name="Message", description="Send a message in a channe;")
async def message(ctx, arg: str, channel: discord.TextChannel):
await channel.send(arg)
would that work?
don't know tbh , never used the discord_slash library
does anyone else know
could you help?
never used discord_slash
Try it and see if it will work?
it doesnt
I set the banner color to be the same as the bar below and the color changes to a different one. Who knows what color you need to set
from discord.ext.commands import bot
from discord.ext.commands.bot import Bot
from discord_slash import SlashCommand
from discord.ext import commands, tasks
import discord
from discord import message
from discord import channel
client = commands.Bot(command_prefix='!')
slash = SlashCommand(client, sync_commands=True)
TOKEN = 'secret'
@client.command()
async def message(ctx, arg: str, channel: discord.TextChannel):
await channel.send(arg)
client.run(TOKEN)
nothing until i try use the command
@client.command()
async def test(ctx):
msg = await ctx.send("The game has ended, thanks for playing!")
await msg.add_reaction('โ
')
await ctx.message.delete()
How can i add when someone press the button it give a role to the member that pres the button?
discord.Client.wait_for()
nothing the error is
too long to send here
it wont let me
just send the last part
RuntimeError: Event loop is closed
is it possible make command flexible like
?power ,?po, ?pow all work the same
aliases i think
you must be doing something very wrong
Thx! โค๏ธโ๐ฅ
yes
do you have intents on @unkempt magnet
!message hello #โ-rules
is how the command is sent
and are you sure you aren't trying to execute code after the client.run()
try enabling intents
yes 100%
how would i do that?
help me use aliases
Whole traceback?
too long to send
!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.
go to the dev portal, your application, bot, enable all intents you can find, later make a variable intents = discord.Intents.all() and pass it to the client constructor
the runtimeerror can be caused by lack of intents
where do i pass intents?
ok
intents = discord.Intents.all()
client = commands.Bot(command_prefix='!', intents=intents)```
did you enable intents on the dev portal?
yes,
give full traceback
message intents, member intents
!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.
alright but unfortunately the traceback included sensitive info
remove the sensitive info
either dm me the traceback or make a text editor replace all the sensitive info with something else
never used vsc before but this might help https://docs.microsoft.com/en-us/visualstudio/ide/finding-and-replacing-text?view=vs-2022
You passed wrong token
improper token
# TEST
@client.command()
async def end(ctx):
guild = ctx.guild
msg = await ctx.send("The game has ended, thanks for playing!")
await msg.add_reaction('โ
')
await ctx.message.delete()
discord.Client.wait_for(msg.add_reaction)
role = guild.get_role(880511595464249374)
await ctx.add_roles(role)
it is not giving the role?
error?
no error
also it's user.add_roles() iirc
but user = not ctx.author how can i define that then?
also you should pass a timeout and check kwarg to wait_for
it's instance.wait_for(), so you'd do client.wait_for() instead of discord.Client.wait_for()
get the user that's playing the game
Nobody plays the game, the intention is that everyone should press the emoji and that the bot ensures after 2 minutes, for example, that everyone has received the role
So i don't know how i can define user because anyone can press the button
then the approach you're using for this is very wrong
wait_for takes a string argument iirc
what is this error
can't compare int and str
I need to use await client.wait_for("reaction_add", check=check)
how to fix it
check being a function returning True or False, yes
make them the same type
ok
oof
i added ' ' in highestArea
idk why did i does it
aw man
here we go again
define it
in another function
how
learn about scopes
ok
also, you're calling variable() without await
and you aren't saving the returned values in anything
Ive run into another issue with my message command
if I want to send a sentence it doesnt recognize it
for some reason it looks for the second word in the message and tries to use that as the channel
causing an error
put the sentence in quotes
thank you again๐
no problem
you tried to use the variable before you defined it
Hey @loud junco!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
โข If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
โข If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
which line throws the error
also instead of building an elif chain you could just use a formula to calculate everything
its not a formula
its not adding evenly
why are there two return statements
which line throws the error
thats not the error
Can someone give me an example of the timeout kwarg in buttons?
what lib
discord.py or disnake
you prob failed to pass an arg that the elif chain detects, hence the error
modef might have failed to be defined, and does not have a default value.
Does mobdef have a default value?
Which library are you using?
discord.py or disnake
nope
disnake
i have an idea
Then set a default value.
Can anyone please give it for discord.py 2.0
alright it isnt working
import asyncio
try:
inter = await bot.wait_for("button_click", timeout=60.0) # This will set a timeout for 60 seconds
except asyncio.TimeoutError:
return
That's not even related to buttons-
That's how you set a timeout for a wait_for.
I want the button to never timeout
Then don't pass a kwarg.
This Interaction Failed.
But the buttons times out
If you don't pass anything
