#discord-bots
1 messages · Page 48 of 1
just keep questions regarding discord bot development in this server...
ok i sent friend request
Use case insensitive
sentex ?
In your commands.Bot, add case_insensitive = True
that would not make it capital only tho
I just read it wrong, he wants both I see
Ah
in discord py embeds how can i make 2 fields go inline with eacher and then 2 other fields inline with each other
when i try i get like 3 fields inline and 1 field not
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. Can only be up to 25 fields.
=> inline should be set to False on third field
Guys i have a timeout command
I want that if bot dont have timeout permission, so it sends a message
How to do that?
you're looking for the has_permission decorator
you haven't set the last field's inline to False, right?
yeah
That's for user not for bot
there should be an error that you can catch if the bot doesnt have enough perms
ah, the bot will most likely have an error, you could handle that
try an embed visualizer
If user don't have perm then the has perm will work . If bot dont have then it would raise error
this makes no sense
It makes sense
you can just add a third "invisible field"
by using \u200b as name and value
em2 = discord.Embed(colour=discord.Color.orange(), description=f":warn: {member.mention} You have been muted from {guild.name}, for: ``{reason}``") How can I make the Bot dm the member when they get muted?
idk
class botclass(commands.Bot):
def __init__(self):
super().__init__(command_prefix=self.get_prefix,help_command=None,intents=discord.Intents.all())
Guys i have this prefix system. How can I add 2 prefixes to it?
maybe set a bool when someone gets muted and if the bool is true send the dm?
i am not that smart
await member.send(…)
depends on what your get_prefix method looks like
Return a list of prefixes in get_prefix
My get prefix returns a prefix from sqlite datbase
hello
probably some on_voice_state_update event
act upon that
whats a couple good dbs for py bots
async def get_prefix(self,message):
id = message.guild.id
self.cursor = await self.connection.cursor()
await self.cursor.execute('SELECT prefix FROM prefixtable WHERE guild_id=?',(id,))
prefix = await self.cursor.fetchone()
await self.connection.commit()
return prefix or '>'
where do i put that before the embed?
well, you want to have > as default AND the prefix the admin of the guild set up?
I want that users can use both prefixes
then you'll want to return [prefix, ">"]
=> a list
Do you want to send the embed to the user?
Oh k
yes
the main problem here though could be that the prefix is None, not sure how the bot acts upon that
Like if you'd pass [None, ">"] as prefix, no idea what would happen
Then it’s just await member.send(embed=em2)
I can do that if prefix None it returns [">"]
sure
default_prefix = ">"
return [prefix, default_prefix] if prefix else default_prefix```
I got this error
show me get_prefix
async def get_prefix(self,message):
id = message.guild.id
self.cursor = await self.connection.cursor()
await self.cursor.execute('SELECT prefix FROM prefixtable WHERE guild_id=?',(id,))
prefix = await self.cursor.fetchone()
await self.connection.commit()
if prefix is None:
list = [">"]
else:
list = [prefix,">"]
return list
yup, you definitely DON'T want to use list as a variable name
No prob but get_prefix returns tuple
fetchone returns a tuple ?
just...
Yep
well, you should just prefix[0] in that case
Still prefix is a tuple ;-;
Ok
default_prefix = ">"
return [prefix[0], default_prefix] if prefix else default_prefix```
in dpy 2 how do you make slash command arguments have descpriotisn
Is there a way to have the writing inside and embed description like organised say?
you're probably looking for embed fields
Thank you
So when you define the slash command through app_command, you can pass a description kwarg
oh i meant for the arguments you pass in if the command needs any
is this included in from discord import Embed or do i import fields too?
thanks!
Guys i have a timeout command
I want that if bot dont have timeout permission, so it sends a message
How to do that?
where have you seen that?
That’s an option
Error handler is for users not for bot
Idk what you meant in your original question
ok thanks
I mean that for ex bot role name is bots so if bots role don't have timeout permission it sends a message
Just do a conditional then
How?
can't you handle that error in the on_error event? not sure
Give us some more information @robust fulcrum
What type of information?
I need help in here about disocrd bot #help-croissant
use case most likely:
- users uses
/timeout <member>command - bot fails to timeout member since it doesn't have timeout perms
- bot tries to handle timeout error internally instead of printing its traceback to the console
How to do that?
can't you handle them in the on_command_error event?
I mean what statement do i out in if else?
if isinstance(error, <error class which raises>): await ctx.send("woops, I don't have perms to do so")
else: raise error
The error is forbidden 404 missing permissions
well, then you should know what to fill in

will it be commands.MissingPermissions?
if that's the error which the traceback shows...
Let me show again
well, as you can read, it's commands.errors.MissingPermissions
Ok
you can just
await ctx.send(error) which will basically send the member what perms the bot is missing exactly, which might be more useful
Guys how to kick or ban a user in dpy?
!d discord.Member.kick
await kick(*, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Kicks this member. Equivalent to [`Guild.kick()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.kick "discord.Guild.kick").
!d discord.Member.ban
await ban(*, delete_message_days=1, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Bans this member. Equivalent to [`Guild.ban()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.ban "discord.Guild.ban").
@commands.has_permissions(manage_channels = True)
async def lock(ctx):
await ctx.channel.set_permissions(ctx.guild.default_role, send_messages=False)
embed = discord.Embed(colour=discord.Color.green(), description=f":approve: {ctx.author.mention}: {ctx.channel.mention} has been **locked**")
await ctx.send(embed=embed)``` Can someone help me make a auto-reply check a channel is already locked/unlocked
when i use @vale junco if want i some condiction happen its dont apply ,
Send code
@commands.command()
@commands.guild_only()
@commands.check(check_channel)
@cooldown(1, 600, BucketType.user)
async def rob(self, ctx, user: discord.Member):
ecoembed = discord.Embed(color= random.choice(colors))
ecoembed.set_author(name = ctx.author , icon_url= ctx.author.display_avatar.url)
if user.id == ctx.author.id:
await ctx.send('Trying to rob yourself?')
elif user is client.user:
await ctx.send('Trying to rob ME?')
else:
user_bal = await economy.find_one({"id": user.id})
member_bal = await economy.find_one({"id": ctx.author.id})
if user_bal is None:
await self.open_account(user.id)
user_bal = await ecomoney.find_one({"id": user.id})
if member_bal is None:
await self.open_account(ctx.author.id)
member_bal = await economy.find_one({"id": ctx.author.id})
mem_total = member_bal["bank"] + member_bal["cash"]
user_cash = user_bal["cash"]
if mem_total < 1000:
if user_cash < 1000:
await economy.update_one({"id": ctx.author.id}, {"$inc": { "cash": -(int(mem_total * 0.8))}})
ecoembed.description = f"❎ | You've been fined :paodcoin2222: {int(mem_total * 0.8) : ,} for trying to rob a poor person."
await ctx.send (embed = ecoembed)
else :
await economy.update_one({"id": ctx.author.id}, {"$inc": { "cash": +(int(user_cash * 0.8))}})
await economy.update_one({"id": user.id}, {"$inc": { "cash": -(int(user_cash * 0.8))}})
its half
discord limits
holy
i want when the rob fail the cooldown dont apply
@vale junco(1, 600, BucketType.user)
this
Isn't it @commands.cooldown ?
!d pastebin
oops
i import cooldown directly
How
Honestly I would help I wouldn't know how to help with that
Yeah
Is BucketType.user a thing?
and would it not be commands.BucketType.user
from discord.ext.commands import cooldown, BucketType
discordjs better
true
Depends what we're comparing
!d discord.ext.commands.BucketType.user
The user bucket operates on a per-user basis.
discordgo better
go? more like go home
button.disabled = True
button.label = f"You must wait {self.combat.turn_skill - self.combat.turn} turns."
await interaction.response.edit_message(view = self)
button.disabled = False
button.label = f"Skill"
await interaction.response.edit_message(view = self)
can i do something like this without the double interaction
you have this twice, why?
if setting == "Enabled":
You can only respond once to each interaction, you could do response.edit_message then a normal edit
which permission remove/ignore channel cooldown ?
!d help
help([object])```
Invoke the built-in help system. (This function is intended for interactive use.) If no argument is given, the interactive help system starts on the interpreter console. If the argument is a string, then the string is looked up as the name of a module, function, class, method, keyword, or documentation topic, and a help page is printed on the console. If the argument is any other kind of object, a help page on the object is generated.
Note that if a slash(/) appears in the parameter list of a function when invoking [`help()`](https://docs.python.org/3/library/functions.html#help "help"), it means that the parameters prior to the slash are positional-only. For more info, see [the FAQ entry on positional-only parameters](https://docs.python.org/3/faq/programming.html#faq-positional-only-arguments).
This function is added to the built-in namespace by the [`site`](https://docs.python.org/3/library/site.html#module-site "site: Module responsible for site-specific configuration.") module.
manage_channel iirc
channels
sarth new pfp 😔
help
what tutorial did you follow 😂
the wrong one for sure
seems like pycord but discord
only pycord has discord.Bot
🥴
is there any chance to fix
yes
slash commands aren't created like that in dpy
see their examples
what should i type instead
See their examples
its my Spotify aura lol
is it @uncut zenith.command
i see on yt and thats how it goes
Ooh nice
there's no proper tutorial for discord.py app commands yet
so docs are the only good resource for learning about them
why do people even prefer videos tbh
when reading could actually save a lot more time
skill issue
Comprehensive documentation is unreadable when you don't know python !
you need to learn python?
👐
than how i can change the slash comands in a prefix?
What
like instead of slash command how can i put a command with prefix like
instead of /ok
jeez, see the examples
.ok
lmao nice error handling
Use commands.Bot
.lancebot
When they gonna fix that
Any idea on how i can get thumbnail and links?
la da la da da da da la da da la da la da da la la da da
parse it using json.loads
@commands.command(aliases = ['ly'])
async def lyrics(self, ctx, *, search=None):
if not search:
await ctx.reply("Give me a song for lyrics bruh -_-")
song = search.replace(' ', '%20')
async with aiohttp.ClientSession() as cs:
async with cs.get(f'https://some-random-api.ml/lyrics?title={song}') as r:
res = await r.json()
em = discord.Embed(url = f"{res['links']}",
title = f"{res['title']}",
description = f"{res['lyrics']}",
color = h()
)
em.set_author(name = f"By - {res['author']}")
em.set_thumbnail(url = f"{res['thumbnail']}")
em.set_footer(text=f'Requested by {ctx.author.name}', icon_url=ctx.author.avatar.url)
yea aiohttp parses it for you ig
see this properly
what do you mean by this?
"thumbnail":{"genius":"https://images.genius.com/1729378bb29676184cc8d92de72aff2f.300x300x1.png"}, "links":{"genius":"https://genius.com/Nicky-youre-and-dazy-sunroof-lyrics"}
this is how it is, under thumbnail i have to get the link from genius
ight
New to Python (Since this morning
) How would I make the thingies like guild.banner and guild.created_at return the appropriate data (guild banner) for the guild the event was run in?
or what would I set guild as?
thx it works now
Guild is accessible via ctx.guild
What if it's under an on_message event?
New to python or to programming generally
New to Python -- I've programmed in other languages
message.guild, check the docs for required classes
!d discord.Message
class discord.Message```
Represents a message from Discord.
x == y Checks if two messages are equal.
x != y Checks if two messages are not equal.
hash(x) Returns the message’s hash.
Hmm.. I must've mistyped or had a logic error cause that didn't work
But I'll try again 
That might have not worked because you haven't enabled members intent
I have the intent enabled
Both in code and in dev portal right?
mhm~
OH
I FOUND THE ERROR
One of my elif's was indented a bit too much
Not used to python's strict indenting 
Happens
Thanks anyway though!
Not in python
how would I make an event that's on a timer, so it only happens idk maybe once every 20 mins ? and event as in a message
!d discord.ext.tasks.loop
discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/latest/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
make a task loop
nvm
set minutes to 20 and feel nice
,
thanks I spent like an hour trying to do this haha
siht pahhens
,
👀
❔
oh and how would I pair this with
@bot.command()
async def ...():
maybe they want to run the command every 20 min
yes
@shrewd apex how does code jam category look like
wdym code jam category?
isnt there some category named CODE JAM?
it's just two channels one channel for your team
youre a participant
and another #code-jammers
oh ok
for talking with others
then you will need a context to run a command
what's in the command
as of right now its just an embed message saying "Event"
good morning
morning
I want their to be an event message for the thing I am making and I want it to be completely automatic as in it happens every so often
morning mr master32
mr
🤼♂️
didnt understand how that explains why do you need command for that
so you only want the command to be callable once for each 20 minutes?
morning websi 
no
he wants to call it every 20 mins
oh
I only know how to use commands I have never used anything else
any idea on what is embed type?
@tasks.loop(minutes=20)
async def something():
....
where did you hear that?
and to start it it should be under the on_ready section something.start()
you must import tasks
start in on_ready :blobpain:
if he do want it to start on with the bot
i dont know what he wants exactly
EmbedType = 'rich
embed type will Always be rich for embeds send by bots
idk why is it EmbedType if it's string, but here: https://discord.com/developers/docs/resources/channel#embed-object-embed-types
there's also a video type which is used by embedded videos etc
I just accidently pasted over my whole code I was just writing, is there an undo button LOL
oh got it
ctrl+z
ctrl z
omfg thank you
lmao
how many types are there?
me ignored:(
6, you can use only one , i.e. rich
why?
sorry sorry
!d discord.Embed.type
The type of embed. Usually “rich”. This can be set during initialisation. Possible strings for embed types can be found on discord’s api docs
Possible strings for embed types can be found on discord’s api docs
got it
yes, and
Embed types are "loosely defined" and, for the most part, are not used by our clients for rendering. Embed attributes power what is rendered. Embed types should be considered deprecated and might be removed in a future API version.
ok..
thx
Idk what error is this
code:
import discord
import random
from discord.ext import tasks
bot=discord.Client(intents=discord.Intents.all())
@bot.event
async def on_ready():
print("Online")
@tasks.loop(seconds = 10)
async def loop():
await bot.send("hello")
loop.start()
bot.run("<token>")```
error:
File "c:\Users\8ster\OneDrive\Desktop\projects\Discord Bots\Novic\main.py", line 16, in <module>
myLoop.start()
File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\tasks\__init__.py", line 398, in start
self._task = asyncio.create_task(self._loop(*args, **kwargs))
File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\asyncio\tasks.py", line 336, in create_task
loop = events.get_running_loop()
RuntimeError: no running event loop
sys:1: RuntimeWarning: coroutine 'Loop._loop' was never awaited```
you must start the task
await loop.start()
okay
ok ig
also, bot.send is not a thing
yaeh
new error:
2022-08-21 01:47:06 ERROR discord.ext.tasks Unhandled exception in internal background task 'loop'.
Traceback (most recent call last):
File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\tasks\__init__.py", line 239, in _loop
await self.coro(*args, **kwargs)
File "c:\Users\8ster\OneDrive\Desktop\projects\Discord Bots\Novic\main.py", line 15, in loop
await bot.send("hello")
AttributeError: 'Client' object has no attribute 'send'
2022-08-21 01:47:06 ERROR discord.client Ignoring exception in on_ready
Traceback (most recent call last):
File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 466, in _run_event
await coro(*args, **kwargs)
File "c:\Users\8ster\OneDrive\Desktop\projects\Discord Bots\Novic\main.py", line 10, in on_ready
await loop.start()
File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\tasks\__init__.py", line 264, in _loop
raise exc
File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\tasks\__init__.py", line 239, in _loop
await self.coro(*args, **kwargs)
File "c:\Users\8ster\OneDrive\Desktop\projects\Discord Bots\Novic\main.py", line 15, in loop
await bot.send("hello")
AttributeError: 'Client' object has no attribute 'send'```
sarth is so lovely, he won't mind
so how should I await it?
lol
😔 atleast someone pings me
client.send_message
the problem is not with awaiting it, Client.send does not exist at all
what is that
you await coroutines using the await keyword
that's not a thing anymore
oh bruh
you need to get_ a channel first, then use send on it
we talking in async branch? 😳
gimme the code
what u mean?
!d discord.Client.get_channel
get_channel(id, /)```
Returns a channel or thread with the given ID.
Changed in version 2.0: `id` parameter is now positional-only.
await bot.get_channel(channel id).send("uwu")
``` pretty straightforward
usually it supposed to be like this
channel = await client.fetch_channel(channel id)
await channel.send("")
if get_channel did not work for you because that usually happen
🗿```py
bot.http.send_message(channel id, "stuff")
until they did some weird stuff in 2.0
channel = client.get_channel(id) or await client.fetch_channel(id)
await channel.send("Never gonna give you up")
🚶♂️ I've added a ChannelState class in my library, you can ```py
bot.channels.get(id)
await bot.channels.fetch(id)
await bot.channels.getch(id)
same for guilds and roles
your bot can't send message in that channel
i wonder what can Missing Permissions mean
probably that it's time to wash the dishes
"was the dished" 
lol lags
!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.
I've a problem with persistent view in disnake in cogs
https://paste.pythondiscord.com/uruyowisiy
I'm getting this error
RuntimeError: There is no current event loop in thread 'MainThread'.
@glad cradle show where do you add the views
it's at the end of the code
in class RoleGiver
function create_dropdown_role_giver
it's a problem related with the class PersistentDropdownView() I'm trying to use this class as a bot object but there's some errors
I'm not sure how to do this inside a cog
In disnake they need to be added in overriden start method of Bot
Disnake doesn't have setup_hook afaik
do you have any example?
utils/bot.py lines 58 to 63
async def start(self, token: str, *, reconnect: bool = True):
self.log.info("Starting...")
self.setup_persistent_views()
await self.db.connect()
await super().start(token, reconnect=reconnect)```
There's also I method which involves asyncio but I prefer not to smoke that grass
why not just ```py
async def main():
await bot.setup_persistent_views()
bot.run()
asyncio.run(main())
Overriding is faster and more elegant imo
++
launch.py :good:
Anyway do whatever you want
so basically you're also overriding commands.Bot right?
Subclassing*
I only overwrite start method to pass the token there
so when in my cog I will use bot will it refer to my subclass?
Yes
🚶♂️i wonder why discord.py asks for the token in start method
could have just used the Client obj
🗿
well it probably wont work cus of some app info but
Good, thx for the example, I'll work on it later, if I'll have some problems can I write to you in DMs?
Sure but I am slow to respond these days
what exactly do you not understand how to do?
no problem I'll wait for the response (maybe in the meantime I could resolve the problem myself)
to make a help command, this: <#discord-bots message>
like buttons under the embed
!d discord.ui.View
class discord.ui.View(*, timeout=180.0)```
Represents a UI view.
This object must be inherited to create a UI within Discord.
New in version 2.0.
Ya were supposed to link the examples not the docs
Hey guys, as of today i have begun my journey within python discord bot development. Upon initially creating my bot i have encountered 1 problem, if anyone can please help me i would be so grateful. (code attached below)
My code:
client = discord.Client()
key = "KeyIshere"
@client.event
async def on_ready():
print('Logged in as {0.user}'.format(client))
client.run(key)```
Error I am Getting:
```PS D:\Discord Development\Gigachad V1> py main.py
Traceback (most recent call last):
File "D:\Discord Development\Gigachad V1\main.py", line 3, in <module>
client = discord.Client()
TypeError: Client.__init__() missing 1 required keyword-only argument: 'intents'
PS D:\Discord Development\Gigachad V1> ```
The views are hard to understand just from docs
why can't I link both?
Master86 would have done better
waht
bot.start is blocking as well
Isn't it async
can use create_task for the first bot to run
is this a yt tutorial? since dpy 2.0 intents are required (run !intents for more info on how to enable them)
it is, but it starts the Websocket listener which runs forever
thats how the bot keeps running
Why not just asyncio.gather everything
yep i found this one form youtube, thankyou for the heads up 🙂
can't he include them in a function async def main():
and then run the function with asyncio.run(main())?
!intents
Using intents in discord.py
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default discord.py has all intents enabled except for Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, and to get members' statuses.
To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.
Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.
yt tutorials are all outdated
possible as well, but there can be cases where one of the bot is running and other is not
@slate swan
nope even that won't work
The best solution would be to just run several instances of script then
ah
@slate swan you can use this as a tutorial https://gist.github.com/Ash-02014/426ec7974f705303a2363c739dd82309
or this to make slash commands https://gist.github.com/Ash-02014/b6f57065f394b54f43666037ade38d32
lmao wth is wrong with me today
import asyncio
loop = asyncio.get_event_loop()
loop.create_task(bot1.start())
loop.run_until_complete(bot2.start())
``` should work maybe
not in 3.10
yes in 3.10+ you need to create a new loop yourself
though its just a warning for now
Nice
@commands.command()
@commands.guild_only()
@commands.check(check_channel)
async def pvc(self , ctx , duration : DurationConverter):
multiplier = { 'm' : 60 , 'h' : 3600}
amount , unit = duration
guild = ctx.guild
user = ctx.author
overwrites = {
guild.me : discord.PermissionOverwrite(manage_permissions=True , manage_channels =True),
guild.default_role: discord.PermissionOverwrite(connect=False) ,
discord.Object(ctx.author.id): discord.PermissionOverwrite(connect=True)
}
bal = await economy.find_one({'id' : ctx.author.id})
info = await pvcdata.find_one({"id" : ctx.author.id})
rate = 1 #rate/sec
if info != None:
await ctx.send("you already have a pvc !!")
return
if bal['PAODs'] >= int((amount*multiplier[unit])* rate):
def check( m):
return (m.content =='yes' or m.content =='Yes' or m.content =='T' or m.content =='t' or m.content =='Y' or m.content =='y') and m.channel == ctx.channel and m.author.id == ctx.author.id ```
await ctx.send(f'This will charge you **{int((amount*multiplier[unit])* rate)}** PAODs ! \nif you want to cont. type `yes`')
try:
await client.wait_for('message', check=check , timeout = 10)
#create vc
PVC = await guild.create_voice_channel(f"{ctx.author.name}'s vc" , category = discord.Object(995100986488147989) , overwrites=overwrites)
await economy.update_one({"id" : ctx.author.id } , {"$inc": {"PAODs" : -(int((amount*multiplier[unit])* rate))}})
await pvcdata.insert_one({"id" : ctx.author.id , "time" : amount*multiplier[unit] , "vcid" : PVC.id})
await ctx.reply(f"{ctx.author} your vc created named {PVC.mention} for `{amount}{unit}` , enjoy!")
await asyncio.sleep(int(amount*multiplier[unit]))
#delete vc
await PVC.delete()
await pvcdata.delete_one({"id" : ctx.author.id })
await ctx.send(f'{ctx.author.mention} time ended vc deleted')
except asyncio.TimeoutError:
await ctx.reply("transetion cenceled")
else:
await ctx.send(f"not enough PAODs you need {int((amount*multiplier[unit])* rate)} PAODs") ```
bot have manage channel prms still missing permission error
pvc reminds me of pipes 🗿
btw you dont have to put that many ors to check the upper case you can do if message.content.lower() == 'yes'
🐒
oh k
!pip durations-nlp use this for time convertor
so much more convenient
@bot.group(invoke_without_command=True)
async def yardım(ctx):
embed = discord.Embed(title="HeKaSTORE", url="https://www.youtube.com/c/Her%C5%9FeyKanal%C4%B1",
description="Yardım menüsü", color=0x00fb3f)
embed.set_author(name="Yardım",
icon_url="https://images-ext-2.discordapp.net/external/ddonIzMurmYNG1HDatzlQPdLmzN5eN0ZDDhkU9OFSNQ/https/cdn.discordapp.com/icons/789415065589776405/7efb9efddfa8353aa5f6e647c2a5ef98.webp")
embed.set_thumbnail(
url="https://images-ext-2.discordapp.net/external/ddonIzMurmYNG1HDatzlQPdLmzN5eN0ZDDhkU9OFSNQ/https/cdn.discordapp.com/icons/789415065589776405/7efb9efddfa8353aa5f6e647c2a5ef98.webp")
embed.add_field(name="Ana Sayfa", value=":book:Sayfalar:", inline=False)
embed.add_field(name="", value="» :flag_white: • Genel Kategorisi ", inline=False)
embed.add_field(name="", value="» :robot: • Bot ile ilgili komutlar ", inline=False)
embed.add_field(name="", value="» :joystick: • Eğlence komutları", inline=False)
embed.add_field(name="", value="» :dollar: • Ekonomi komutları", inline=True)
embed.add_field(name="", value="» :medal: • Yetkili komutları", inline=True)
embed.set_footer(
text="» :video_game: • Oyun komutları » :dollar: • Ekonomi komutları » :medal: • Yetkili komutları » :new: • Interaction komutları")
await ctx.send(embed=embed)
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
@bot.group(invoke_without_command=True)
async def yardım(ctx):
embed = discord.Embed(title="HeKaSTORE", url="https://www.youtube.com/c/Her%C5%9FeyKanal%C4%B1",
description="Yardım menüsü", color=0x00fb3f)
embed.set_author(name="Yardım",
icon_url="https://images-ext-2.discordapp.net/external/ddonIzMurmYNG1HDatzlQPdLmzN5eN0ZDDhkU9OFSNQ/https/cdn.discordapp.com/icons/789415065589776405/7efb9efddfa8353aa5f6e647c2a5ef98.webp")
embed.set_thumbnail(
url="https://images-ext-2.discordapp.net/external/ddonIzMurmYNG1HDatzlQPdLmzN5eN0ZDDhkU9OFSNQ/https/cdn.discordapp.com/icons/789415065589776405/7efb9efddfa8353aa5f6e647c2a5ef98.webp")
embed.add_field(name="Ana Sayfa", value="📖Sayfalar:", inline=False)
embed.add_field(name="", value="» 🏳️ • Genel Kategorisi ", inline=False)
embed.add_field(name="", value="» 🤖 • Bot ile ilgili komutlar ", inline=False)
embed.add_field(name="", value="» 🕹️ • Eğlence komutları", inline=False)
embed.add_field(name="", value="» 💵 • Ekonomi komutları", inline=True)
embed.add_field(name="", value="» 🏅 • Yetkili komutları", inline=True)
embed.set_footer(
text="» 🎮 • Oyun komutları » 💵 • Ekonomi komutları » 🏅 • Yetkili komutları » 🆕 • Interaction komutları")
await ctx.send(embed=embed)
huh fix the indents
the last line indent
there u go fixed the indent
huh is that much easy
also how is someone supposed to type this command that i is weird it's not there in my keyboard 
\u0131 : LATIN SMALL LETTER DOTLESS I - ı
bruh
How to fix this?
fields names cant be empty
make sure there are no symbols from other langs, like the a or a dot idk
There location?
you did a lot of embed.add_field()
and didnt pass name kwarg
they should have bot name an value
like this embed.add_field(name="uwu", value="[Click me!](https://never-gonna-give-you-up.com/)")
Wait giving you multiplier link @silk fulcrum come dm
replit moments, sometimes replit corrupt packages files, try to delete asyncio, then delete the cache doing cntrl + shift + r, and finally reinstall asyncio, if this does not work delete your repl and create a new one (in my cases these things worked)
yes
I am with phone
delete the phone
🤔
pip uninstall -y phone
Are you unable to use "<@{}>" inside embed.set_footer description?
mention doesn't works on footer text
ahh ok thanks
you can only use the display name of the user
on footer
footer(@silk fulcrum)
not even emojis
how would I go to get the user name put in the footerwho clicked a emoji reaction?
use buttons now
footer(@silk fulcrum is dumbass 😳)
in that case you must deal with the on_reaction event i think
😳
eh u much smorter than me i was dumb af at ur age
ahh yes, thank you!
lmao
users = message.reactions[0].users().flatten()
does af mean as fu... ?
why emojis are still used as buttons 😭
something like this or was iirc
yes see u so smort
bruh
some people using it as it has a classic look
😭
like this
it's a shitty look
it's called dropdown menu
actually for me reactions are too small and buttons are too big none of them are able to portray the emoji perfectly
+++
do you have the new version of discord mobile? (android only)
@shrewd apex take a look at this old announcement in Reaction Roles bot discord
They be like: Showing len(role.members) takes hella lot of resources so they can't show it on free version 💀
ignorance is bliss
I agree
"But sadly with discord limitations it would just be a brick" If u want to lie, blame it on discord. Nice
b-but len iterates through each elements and does count+=1 👉 👈
so if they use pil to generate images they are gonna charge even more 
No other choice to show the len, and the bot does nothing except give roles on reacting
i think in 2.0 for getting len they optimised the code or something i remember something similar in updates channel
Nice
B-but they use djs
@shrewd apex can u share the link where they said that tho?
yeah lemme search
This is just a general thing 😄
Not like it will take 10 years to compile a program to show length of a list :D
yeah, it will take longer
Yes. Discord gonna die till they compile the program that saves len(role.members), so understandable
they made it proxy type to save time
Thanks!
But in djs, everything is still better optimized
except js
It can't take like 1 GB of RAM to just show len lol
that was sarcasm but yea
ik just saying 🥲
I am tring to build a currency bot in discord.py. Currency name is Cokkie
Here is my code:
import discord
from discord.ext import commands
import json
bot = commands.Bot(command_prefix='>', intents=discord.Intents.all())
@bot.event
async def on_ready():
print("Bot is Now Online")
@bot.event
async def on_message(message):
user_id = str(message.author.id)
with open("jar.json", "r") as file:
jar = json.load(file)
if not user_id in jar:
jar[user_id] = {}
jar[user_id]["cookies"] += 5
jar[user_id]["cookies"] += 5
with open("jar.json", "w") as file:
json.dump(jar, file)
await bot.process_commands(message)
@bot.command()
async def jar(ctx):
user=ctx.author
with open("jar.json") as f:
data = json.load(f)
cookies_amt=data[str(user.id)]["cookies"]
await user.send(f"You currently have **{cookies_amt}** cookies in you jar.")
bot.run("<token>")```
error:
2022-08-21 03:07:26 INFO discord.gateway Shard ID None has sent the IDENTIFY payload.
2022-08-21 03:07:26 INFO discord.gateway Shard ID None has connected to Gateway (Session ID: 0063bcb2be749e0da6370fbc8c041865).
Bot is Now Online
2022-08-21 03:07:29 ERROR discord.client Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 466, in _run_event
await coro(*args, **kwargs)
File "c:\Users\8ster\OneDrive\Desktop\projects\Discord Bots\Novicookies\main.py", line 21, in on_message
jar[user_id]["cookies"] += 5
KeyError: 'cookies'```
idk what it means and I am struggling on it for so long
Also, u should take a look at r+ open mode
ok?
That means first read, then write
still getting the same error
So you don't have to open the file repeatedly
Asher told the problem
^^^
how should i fix it?
Just add a check if the user exists and if it doesn't then send The user doesn't exists?
[2022-08-21 13:14:02] [ERROR ] discord.ext.commands.bot: Ignoring exception in command yardım
Traceback (most recent call last):
File "C:\Users\tekno\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\discord\ext\commands\core.py", line 190
, in wrapped
ret = await coro(*args, **kwargs)
File "main.py", line 21, in yardım
select = Select(options=[
NameError: name 'Select' is not defined
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\tekno\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\discord\ext\commands\bot.py", line 1347
, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\tekno\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\discord\ext\commands\core.py", line 161
0, in invoke
await super().invoke(ctx)
File "C:\Users\tekno\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\discord\ext\commands\core.py", line 986
, in invoke
await injected(*ctx.args, **ctx.kwargs) # type: ignore
File "C:\Users\tekno\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\discord\ext\commands\core.py", line 199
, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'Select' is not defined
this is my error
@bot.group(invoke_without_command=True)
async def yardım(ctx):
select = Select(options=[
discord.SelectOption(label="Genel Kategorisi", emoji=":flag_white:", description="Genel kategorideki komutlar"),
discord.SelectOption(label="Bot Komut", emoji=":robot:", description="Bot ile ilgili komutlar"),
])
view = View()
view.add_item(select)
embed = discord.Embed(title="HeKaSTORE", url="https://www.youtube.com/c/Her%C5%9FeyKanal%C4%B1",
description="Yardım menüsü", color=0x00fb3f)
embed.set_author(name="Yardım",
icon_url="https://images-ext-2.discordapp.net/external/ddonIzMurmYNG1HDatzlQPdLmzN5eN0ZDDhkU9OFSNQ/https/cdn.discordapp.com/icons/789415065589776405/7efb9efddfa8353aa5f6e647c2a5ef98.webp")
embed.set_thumbnail(
url="https://images-ext-2.discordapp.net/external/ddonIzMurmYNG1HDatzlQPdLmzN5eN0ZDDhkU9OFSNQ/https/cdn.discordapp.com/icons/789415065589776405/7efb9efddfa8353aa5f6e647c2a5ef98.webp")
embed.add_field(name="Ana Sayfa", value=":book:Sayfalar:", inline=False)
embed.add_field(name="", value="» :flag_white: • Genel Kategorisi ", inline=False)
embed.add_field(name="", value="» :robot: • Bot ile ilgili komutlar ", inline=False)
embed.add_field(name="", value="» :joystick: • Eğlence komutları", inline=False)
embed.add_field(name="", value="» :dollar: • Ekonomi komutları", inline=True)
embed.add_field(name="", value="» :medal: • Yetkili komutları", inline=False)
embed.set_footer(
text="» :video_game: • Oyun komutları » :dollar: • Ekonomi komutları » :medal: • Yetkili komutları » :new: • Interaction komutları")
await ctx.send(embed=embed)
await ctx.send("Bir kategori seç", view=view)```
no timeout 👀
from discord.ui import Select
view = View()
is there anyone to return session_id from discord websocket?
I'm totally not eagerly waiting for Danny to add a cooldown system to ui components lol
Why would u need that?
still the same error : (
Asher can help you better
I've go in a few min
from discord.ui import View
Lol ok?
to run the websocket again using the same session id
incase
Discord.py does that for u automatically
yea im making a wrapper
Ah
U should consult the discord dev docs at https://discord.dev then!
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
Ok
And you can get a better answer in #965291516031549500 since here people will assume u r using hikari/discord.py/disnake or some other wrapper
instead of += 5 do = 5
just do py jar[user_id] = {"cookies": 5}
Can someone help me makin an simple / command
I want an command like /give (Amount)
Then the bot reply's and give the (amount) from an file
so what's the problem?
Idk how i can make like get lines of an file & send the amount thats give up of lines to the person
@silk fulcrum
a
Can u help or make it for me
!rule 8 100% cannot make it for you
8. Do not help with ongoing exams. When helping with homework, help people learn how to do the assignment without doing it for them.
it's not homework nor an exam
bruh it's a phrase
spoonfeeding is bad, yes, but not strictly prohibited
it's only homework or exams that have a rule to it
i don't think txt files will be good for economy
at least json
its for them to learn fileio...
ohkay
I am building a currency bot now I am struggling to make a steal command it it which will deduct a certain amount and add the same amount in your balance.
code:
import discord
from discord.ext import commands
import json
import random
bot = commands.Bot(command_prefix='>', intents=discord.Intents.all())
@bot.event
async def on_ready():
print("Bot is Now Online")
@bot.event
async def on_message(message):
user_id = str(message.author.id)
with open("jar.json", "r+") as file:
jar = json.load(file)
if not user_id in jar:
jar[user_id] = {}
jar[user_id]["cookies"] = 5
jar[user_id]["cookies"] += 5
with open("jar.json", "w") as file:
json.dump(jar, file)
await bot.process_commands(message)
@bot.command()
async def jar(ctx):
user_id = ctx.author.id
user=ctx.author
with open("jar.json") as f:
data = json.load(f)
cookies_amt=data[str(user_id)]["cookies"]
await user.send(f"You currently have **{cookies_amt}** cookies in you jar.")
@bot.command()
async def steal(ctx, member = discord.Member):
random_steal = random.randrange(0, member_cookies_amt + 1)
user_id = str(ctx.author.id)
member_id = str(member.id)
with open("jar.json", "r+") as file:
jar = json.load(file)
if not user_id in jar:
jar[user_id] = {}
jar[user_id]["cookies"] = 5
if not member_id in jar:
jar[member_id] = {}
jar[member_id]["cookies"] = 5
member_cookies_amt=jar[str(member_id)]["cookies"]
random_steal = random.randrange(0, member_cookies_amt + 1)
jar[user_id]["cookies"] += random_steal
jar[member_id]["cookies"] -= random_steal
member_cookies_amt=jar[str(member_id)]["cookies"]
random_steal = random.randrange(0, member_cookies_amt + 1)
jar[user_id]["cookies"] += random_steal
jar[member_id]["cookies"] -= random_steal
with open("jar.json", "w") as file:
json.dump(jar, file)
bot.run("<token>")```
error:
2022-08-21 03:53:29 ERROR discord.ext.commands.bot Ignoring exception in command steal
Traceback (most recent call last):
File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 195, in wrapped
ret = await coro(*args, **kwargs)
File "c:\Users\8ster\OneDrive\Desktop\projects\Discord Bots\Novicookies\main.py", line 44, in steal
random_steal = random.randrange(0, member_cookies_amt + 1)
UnboundLocalError: local variable 'member_cookies_amt' referenced before assignment
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 1330, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 991, in invoke
await injected(*ctx.args, **ctx.kwargs) # type: ignore
File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 204, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: UnboundLocalError: local variable 'member_cookies_amt' referenced before assignment
member = discord.Member i think this is meant to be a type hint
randint is better than randrange if randrange even works
embed.set_footer(text="Total Value{lim1}+{lim2}") how do i make it add lim1 and lim2 together?
oksy?? lemme me try
{lim1 + lim2}
why is randint better and why wont randrange work?
ok thanks
idk, never used randrange, why would it be better?
same error : (
where do you think you are getting member_cookies_amt from? what should it be? because you do not define it anywhere
that didn’t work, it just replied with "Total Value: 419 512
your statment doesn't make sense, and btw randint uses randrange internally https://github.com/python/cpython/blob/main/Lib/random.py#L328L332
Lib/random.py line 328
def randint(self, a, b):```
rip
I defined it before the randint line
check
they're str most likely, do {int(lim1) + int(lim2)}
okay
you did not
idk if that works but you can try await guild.me.edit(nick="uwu") @placid talon
await edit(*, nick=..., mute=..., deafen=..., suppress=..., roles=..., voice_channel=..., timed_out_until=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the member’s data.
Depending on the parameter passed, this requires different permissions listed below...
ywah its nick
Ok so I fixed 7 errors now I am getting a new non-sense error
2022-08-21 04:01:59 ERROR discord.ext.commands.bot Ignoring exception in command steal
Traceback (most recent call last):
File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 195, in wrapped
ret = await coro(*args, **kwargs)
File "c:\Users\8ster\OneDrive\Desktop\projects\Discord Bots\Novicookies\main.py", line 46, in steal
member_id = member.id
AttributeError: type object 'str' has no attribute 'id'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 1330, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 991, in invoke
await injected(*ctx.args, **ctx.kwargs) # type: ignore
File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 204, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: type object 'str' has no attribute 'id'```
like what?
show code
ohh sorry wait
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
= should be :
typekidding
= is used to assign a value
: is used for typehinting
import discord
from discord.ext import commands
import json
import random
bot = commands.Bot(command_prefix='>', intents=discord.Intents.all())
@bot.event
async def on_ready():
print("Bot is Now Online")
@bot.event
async def on_message(message):
user_id = str(message.author.id)
with open("jar.json", "r+") as file:
jar = json.load(file)
if not user_id in jar:
jar[user_id] = {}
jar[user_id]["cookies"] = 5
jar[user_id]["cookies"] += 5
with open("jar.json", "w") as file:
json.dump(jar, file)
await bot.process_commands(message)
@bot.command()
async def jar(ctx):
user_id = ctx.author.id
user=ctx.author
with open("jar.json") as f:
data = json.load(f)
cookies_amt=data[str(user_id)]["cookies"]
await user.send(f"You currently have **{cookies_amt}** cookies in you jar.")
@bot.command()
async def steal(ctx, member = discord.Member):
with open("jar.json", "r+") as file:
jar = json.load(file)
member_id = member.id
member_cookies_amt=jar[str(member_id)]["cookies"]
random_steal = random.randint(0, member_cookies_amt + 1)
user_id = str(ctx.author.id)
if not user_id in jar:
jar[user_id] = {}
jar[user_id]["cookies"] = 5
if not member_id in jar:
jar[member_id] = {}
jar[member_id]["cookies"] = 5
member_cookies_amt=jar[str(member_id)]["cookies"]
random_steal = random.randint(0, member_cookies_amt + 1)
jar[user_id]["cookies"] += random_steal
jar[member_id]["cookies"] -= random_steal
member_cookies_amt=jar[str(member_id)]["cookies"]
random_steal = random.randrange(0, member_cookies_amt + 1)
jar[user_id]["cookies"] += random_steal
jar[member_id]["cookies"] -= random_steal
with open("jar.json", "w") as file:
json.dump(jar, file)
bot.run("<token>")```
combine both and you have a cooler assignment operator
walrus lol
where do u mean that?
that works only in if
your member argument? from where the error cmes
no?
(x:=1,)
print(x)
nope you can use it pretty much anywhere
!e ```py
import random
print(random.choice([a:=1, 2]))
print(a)
@slate swan :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | 1
002 | 1
well... who ever uses it in something else?
me
ok..
its useful for when you have to write a 200liner in one line
Its also useful in regular code !
bruh
yea, but thats boring
do I need to use it before assignment?
because my new error;
bruh
2022-08-21 04:13:37 ERROR discord.ext.commands.bot Ignoring exception in command steal
Traceback (most recent call last):
File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 195, in wrapped
ret = await coro(*args, **kwargs)
File "c:\Users\8ster\OneDrive\Desktop\projects\Discord Bots\Novicookies\main.py", line 47, in steal
member_cookies_amt=jar[str(member_id)]["cookies"]
UnboundLocalError: local variable 'member_id' referenced before assignment
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 1330, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 991, in invoke
await injected(*ctx.args, **ctx.kwargs) # type: ignore
File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 204, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: UnboundLocalError: local variable 'member_id' referenced before assignment```
HuH...
show your updated code
oh
Member is not a discord.Member
You’ve tried to typehint but you’ve assigned it
In the command arguments you’ve done member = not member:
import discord
from discord.ext import commands
import json
import random
bot = commands.Bot(command_prefix='>', intents=discord.Intents.all())
@bot.event
async def on_ready():
print("Bot is Now Online")
@bot.event
async def on_message(message):
user_id = str(message.author.id)
with open("jar.json", "r+") as file:
jar = json.load(file)
if not user_id in jar:
jar[user_id] = {}
jar[user_id]["cookies"] = 5
jar[user_id]["cookies"] += 5
with open("jar.json", "w") as file:
json.dump(jar, file)
await bot.process_commands(message)
@bot.command()
async def jar(ctx):
user_id = ctx.author.id
user=ctx.author
with open("jar.json") as f:
data = json.load(f)
cookies_amt=data[str(user_id)]["cookies"]
await user.send(f"You currently have **{cookies_amt}** cookies in you jar.")
@bot.command()
async def steal(ctx, member = discord.Member):
with open("jar.json", "r+") as file:
jar = json.load(file)
member_id : member.id
member_cookies_amt=jar[str(member_id)]["cookies"]
random_steal = random.randint(0, member_cookies_amt + 1)
user_id = str(ctx.author.id)
if not user_id in jar:
jar[user_id] = {}
jar[user_id]["cookies"] = 5
if not member_id in jar:
jar[member_id] = {}
jar[member_id]["cookies"] = 5
member_cookies_amt=jar[str(member_id)]["cookies"]
random_steal = random.randint(0, member_cookies_amt + 1)
jar[user_id]["cookies"] += random_steal
jar[member_id]["cookies"] -= random_steal
member_cookies_amt=jar[str(member_id)]["cookies"]
random_steal = random.randrange(0, member_cookies_amt + 1)
jar[user_id]["cookies"] += random_steal
jar[member_id]["cookies"] -= random_steal
with open("jar.json", "w") as file:
json.dump(jar, file)
bot.run("<token>")```
@slate swan
you still didn't made any changes i asked you to
I’ve given you the solution
it is ig
^
Both of us have given you the solution
u mean all of em?
It would help if you used them?
Is there any way to break a line in f string? In embeds i mean
in the function signature of steal
ok did
Bruh f string can't contain backslash
only the interpolation part of an f-string cant
a string inside f string can't
Wdym?
!e f"\n"
the f string can
@rugged shadow :warning: Your 3.11 eval job has completed with return code 0.
[No output]
f"this \nis \nlegit"
f"this {'is\nnot'}"
This is what I am doing rn and it ain't working so is there any other way?
but the error is this
Should I just add fields?
2022-08-21 04:13:37 ERROR discord.ext.commands.bot Ignoring exception in command steal
Traceback (most recent call last):
File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 195, in wrapped
ret = await coro(*args, **kwargs)
File "c:\Users\8ster\OneDrive\Desktop\projects\Discord Bots\Novicookies\main.py", line 47, in steal
member_cookies_amt=jar[str(member_id)]["cookies"]
UnboundLocalError: local variable 'member_id' referenced before assignment
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 1330, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 991, in invoke
await injected(*ctx.args, **ctx.kwargs) # type: ignore
File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 204, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: UnboundLocalError: local variable 'member_id' referenced before assignment```
how do i reply to the message a button is attached to?
what are you trying to do actually? there may be easier ways around
the idea of f-strings is that you can have inline code in a string, I don't see why in an embed you would need the \n to be in the code part, not the string part, could you show what you're trying to do
!d discord.Interaction.message
The message that sent this interaction.
lmao
you have member_id : member.id which is incorrect, its supposed to assign not type hint
@vocal plover
lol
You need to use separate {} sections for each of the embedded variables
@leaden cosmos do it in #bot-commands please
oh sorry
As in fields?
you didn't close the bracket after res['participants']
so could this work? await interaction.original_message.reply()
you need to await original_message too iirc
oh
F, i continued in it and didn't realise, thx
nothing
No, you need to use separate interpolation sections, i.e. {code} for each thing you want to put in. They can be in the same string, but you cant put everything in one section, so
f"{something}\n{other_something}"
it's removed since the PyPI release
!d discord.MessageInteraction.original_message
No documentation found for the requested symbol.
wait did they rename it?
Got it got it
!d discord.Interaction.original_response
await original_response()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Fetches the original interaction response message associated with the interaction.
If the interaction response was a newly created message (i.e. through [`InteractionResponse.send_message()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.InteractionResponse.send_message "discord.InteractionResponse.send_message") or [`InteractionResponse.defer()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.InteractionResponse.defer "discord.InteractionResponse.defer"), where `thinking` is `True`) then this returns the message that was sent using that response. Otherwise, this returns the message that triggered the interaction (i.e. through a component).
Repeated calls to this will return a cached value.
@vocal plover this is the issue
cursed
hehe
@slate swan
i had that problem when swithcing to pypi version
2022-08-21 04:17:38 ERROR discord.ext.commands.bot Ignoring exception in command steal
Traceback (most recent call last):
File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 195, in wrapped
ret = await coro(*args, **kwargs)
File "c:\Users\8ster\OneDrive\Desktop\projects\Discord Bots\Novicookies\main.py", line 48, in steal
random_steal = random.randint(0, member_cookies_amt + 1)
File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\random.py", line 370, in randint
return self.randrange(a, b+1)
File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\random.py", line 353, in randrange
raise ValueError("empty range for randrange() (%d, %d, %d)" % (istart, istop, width))
ValueError: empty range for randrange() (0, -1218505542399643901, -1218505542399643901)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 1330, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 991, in invoke
await injected(*ctx.args, **ctx.kwargs) # type: ignore
File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 204, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ValueError: empty range for randrange() (0, -1218505542399643901, -1218505542399643901)```
what does this mean?
I'd make sure to wrap the interaction class to a custom one while using discord.py
await interaction.response.edit_message(view=self) if this is in my code i cant respond again?
oh... here you probably use randrange
yep, an interaction can be responded only once
im not sure, never used it
ahh okay
ok so randrange is trash and useless
followup:)
everyone should use randint
... what
should use randrange*
you're supposed to use randrange
ohh...
I will surly not say "Ofc"
followups are just webhooks lol
!d discord.Interaction.followup
Returns the follow up webhook for follow up interactions.
@bot.slash_command(guild_ids=[settings["guildID"]], name="givetoken", description="Give Tokens to an buyer") async def number(ctx: discord.ApplicationContext, number: discord.Option(discord.Number, "Amount of Tokens", required=True)): for line in open("tokens.txt"): number += 1
well, anyways you can send ephemeral message again:)
discord.Number
from tokens.txt
Thats right or not?
if you're using pycord it might be 🤣
yes, this looks exactly same as the boost bot I saw
Haha
But i need to send the amount he gives up
did you buy that or what?
How can i do that
or sell...
No i'm making it
Master... Master I am getting same error again!!!
what should I do!!
🌚
But can someone help?
code+error please, i can't really help without them
(not whole code, code of command is enough)
okkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
sorry for that btw
Bro?
this is helpful btw https://pythondiscord.com/pages/asking-good-questions/
@bot.command()
async def steal(ctx, member : discord.Member):
with open("jar.json", "r+") as file:
jar = json.load(file)
member_id = member.id
member_cookies_amt=int(jar[str(member_id)]["cookies"])
random_steal = random.randrange(0, member_cookies_amt)
user_id = str(ctx.author.id)```
2022-08-21 04:25:33 ERROR discord.ext.commands.bot Ignoring exception in command steal
Traceback (most recent call last):
File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 195, in wrapped
ret = await coro(*args, **kwargs)
File "c:\Users\8ster\OneDrive\Desktop\projects\Discord Bots\Novicookies\main.py", line 48, in steal
random_steal = random.randrange(0, member_cookies_amt)
File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\random.py", line 353, in randrange
raise ValueError("empty range for randrange() (%d, %d, %d)" % (istart, istop, width))
ValueError: empty range for randrange() (0, -1218505542399643903, -1218505542399643903)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 1330, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 991, in invoke
await injected(*ctx.args, **ctx.kwargs) # type: ignore
File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 204, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ValueError: empty range for randrange() (0, -1218505542399643903, -1218505542399643903)
Can u help or what are u doing?
@silk fulcrum
when did I say I'll help you?
Lol
!rule
The rules and guidelines that apply to this community can be found on our rules page. We expect all members of the community to have read and understood these.
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
accident
lemme check docs for randrange lmao
no idea how should that work
yooo!!!
How can i read an file and send the amount thats giving up
btw you are getting negative numbers if im not mistaking
same idk why
someone respond on #965291516031549500
Can someone help?
How can i read an file and send the amount of lines thats giving up by the / command option
!d open
open(file, mode='r', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None)```
Open *file* and return a corresponding [file object](https://docs.python.org/3/glossary.html#term-file-object). If the file cannot be opened, an [`OSError`](https://docs.python.org/3/library/exceptions.html#OSError "OSError") is raised. See [Reading and Writing Files](https://docs.python.org/3/tutorial/inputoutput.html#tut-files) for more examples of how to use this function.
*file* is a [path-like object](https://docs.python.org/3/glossary.html#term-path-like-object) giving the pathname (absolute or relative to the current working directory) of the file to be opened or an integer file descriptor of the file to be wrapped. (If a file descriptor is given, it is closed when the returned I/O object is closed unless *closefd* is set to `False`.)
b-but rule 5?
hm?
hes making boost bot
!rule 5
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
tf is that lol
what's a boost bot
ik about that, but whats a boost bot
his boost bot uses same strategy as the one I saw.
It has tokens of users, who can give boosts to the server. using these tokens bot makes users join server to boost it
@pulsar solstice imagine what happens in logs
Lmao
sounds phishy
@silk fulcrum btw did u checked out what's randrange
btw proved: captcha doesnt do anything, because this system skips it
!d random.randint
random.randint(a, b)```
Return a random integer *N* such that `a <= N <= b`. Alias for `randrange(a, b+1)`.
yeah, was about to say that you have a step that goes all the way from 0 to that number
b should always be smoler than a
or equal
oh
sounds silly but ok?
U mean I should start with 1?
i thought it can go backwards
@slate swan
no
Can u help me?
0 is set by default
!e ```py
print(import("random").randint(1,2))
@slate swan :x: Your 3.11 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | File "/usr/local/lib/python3.11/random.py", line 362, in randint
004 | return self.randrange(a, b+1)
005 | ^^^^^^^^^^^^^^^^^^^^^^
006 | File "/usr/local/lib/python3.11/random.py", line 345, in randrange
007 | raise ValueError("empty range for randrange() (%d, %d, %d)" % (istart, istop, width))
008 | ValueError: empty range for randrange() (1, 0, -1)
See, same.error as yours
How can i read an file and send the amount of lines thats giving up by the / command option
your b is smaller than a
And then remove the lines he send
-1 step
!e ```py
print(import("random").randint(1,2))
@slate swan :white_check_mark: Your 3.11 eval job has completed with return code 0.
1
@pulsar solstice add , -1 to your randrange
it works
why?!?!/
Wdym
i dont want it to give the time in decimals, what to do?
msg = '**Still on cooldown**, pls try again in {:.2f}s'.format(error.retry_after)
!e py print(__import__("random").randrange(0, -4468, -1))
@silk fulcrum :white_check_mark: Your 3.11 eval job has completed with return code 0.
-3957
intents = discord.Intents.default()
intents.members = True
intents.message_content = True
client = commands.Bot(command_prefix=commands.when_mentioned_or(config["prefix"]) , strip_after_prefix =True, case_insensitive=True, intents=intents )
is this perfect ?
new way of import 😳
-1 step means it will choose from negative numbers, cus by default step is 1 and it cannot go up when your b is negative (0+1 is even bigger than 0 to -48623871569234)
new for me
int(error.retry_after)
thats the way, import statment uses it
can i do like
if
error.retry_after = 0
else
normal
???
where you have :.2f currently you can change it to :.0f
the .nf formatting directive will format to n decimal places, so giving 0 means it'll format it as an integer
ight got it
stop ? ing. just ask the part you don't understand
error.retry_after returns a float value 1.234...
int(error.retry_after) will convert it into an integer 1
this saves you from using .2f as well
command.cooldown.reset() ig
k
await commad.cooldown.reset()
don't think its an awaitable
why
return ?
return isnt used like that-
it "reproducing" new error
but it's app_commands.Coooldown
2022-08-21 04:46:37 ERROR discord.ext.commands.bot Ignoring exception in command steal
Traceback (most recent call last):
File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 195, in wrapped
ret = await coro(*args, **kwargs)
File "c:\Users\8ster\OneDrive\Desktop\projects\Discord Bots\Novicookies\main.py", line 48, in steal
random_steal = random.randrange(-1, member_cookies_amt)
File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\random.py", line 353, in randrange
raise ValueError("empty range for randrange() (%d, %d, %d)" % (istart, istop, width))
ValueError: empty range for randrange() (-1, -1020941608420596387, -1020941608420596386)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 1330, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 991, in invoke
await injected(*ctx.args, **ctx.kwargs) # type: ignore
File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 204, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ValueError: empty range for randrange() (-1, -1020941608420596387, -1020941608420596386)```
weird weird weird, why is commands.Command.cooldown an app_commands.Cooldown object
bruh, not replace 0 with -1, you should add it at the end
like randrange(0, -12904812, -1)
no idea
like i want if i use a command and in command a if condition i dont want if that run command go on cooldown
@Rapptz why?
or just do the latter, randrange(-12904812, 0)
well, possible
actually, lemme ask in discord.py server lol
lmao im with you
it's a empty range T-T
2022-08-21 04:49:09 ERROR discord.ext.commands.bot Ignoring exception in command steal
Traceback (most recent call last):
File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 195, in wrapped
ret = await coro(*args, **kwargs)
File "c:\Users\8ster\OneDrive\Desktop\projects\Discord Bots\Novicookies\main.py", line 48, in steal
random_steal = random.randrange(0, member_cookies_amt, -1)
File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\random.py", line 363, in randrange
raise ValueError("empty range for randrange()")
ValueError: empty range for randrange()
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 1330, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 991, in invoke
await injected(*ctx.args, **ctx.kwargs) # type: ignore
File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 204, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ValueError: empty range for randrange()```
Do u have any alt?
yes
!!what!!??
there is also @tough wagon
wut happened?
why is commands.Command.cooldown an app_commands.Cooldown object, and was it not commands.Cooldown in earlier versions?
the changelog doesnt mention about it either
wdym?
what?
wdym that Command.cooldown is an app_commands.Cooldown object
they are totally different
that's what sarth said in dpy server
btw click on that Cooldown in the docs
it's app_commands.Cooldown
no?
and there is no ext.commands.Cooldown
yes?
discord/ext/commands/cooldowns.py line 37
from discord.app_commands import Cooldown as Cooldown```
so I guess they simply shifted it to be in app_commands
how cooldown property of a normal prefix command being an app_commands.Cooldown object make sense?
!d discord.ext.commands.cooldowns.Cooldown
No documentation found for the requested symbol.
undocumented behaviour
when did I say it does lmao
could have just wrapped app_commands.Cooldown as a sublass of commands.Cooldown but yeah, discord.py moment
sarth make pr and fix
!!
I don't even have my laptop with me these days :p
: {
my only contribution in discord.py is changing a value from 0 to 25
imagine studying so much
excessively dying for no reason 😔
Can I add persistence to buttons if I'm making buttons like this?
class Button(discord.ui.Button):
def __init__(self, label):
super().__init__(
label=label,
style=discord.ButtonStyle.grey,
custom_id=label
)
async def callback(self, interaction: discord.Interaction):
...
yes
def not studying, just travelling
How 🙏
Oh
views are persistent, not the buttons themselves so
The view has to be persistive right
Yeah
study tour
no noooooo don't make me imagine that

Wait @slate swan does adding timeout=None to my view make it persistent?
How do I get trigger deleted right after the command is done?
guys I am running an .edit(embed=embed), so once a user reacts to the reaction, it will send a new edited embed. Still can't figure out once the new embed has been posted upon "clicking reaction" to get the user who clicked the reaction, mentioned in the new embed description.
embed = Embed(color=discord.Color.dark_green(), title="", description="<@{}> Has accepted".format(ctx.author.id))
ctx.message.delete
How do u detect when the reaction is triggered?
return user == ctx.message.author and str(reaction.emoji) == '✅'
await bot.wait_for('reaction_add', check=check)```
@ctx.message.delete
?
bot.wait_for returns something
Check the docs on what it returns
is it possbile to see if message replied like that?
No, It’ s a method
huh? so how do I do it
!d discord.Message.reference
The message that this message references. This is only applicable to messages of type MessageType.pins_add, crossposted messages created by a followed channel integration, or message replies.
New in version 1.5.
!d discord.Message.rference
No documentation found for the requested symbol.
call the method
!d discord.Message.reference
The message that this message references. This is only applicable to messages of type MessageType.pins_add, crossposted messages created by a followed channel integration, or message replies.
New in version 1.5.
!d discord.Message.delete
await delete(*, delay=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Deletes the message.
Your own messages could be deleted without any proper permissions. However to delete other people’s messages, you need the [`manage_messages`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission.
Changed in version 1.1: Added the new `delay` keyword-only parameter.
If I'm not wrong
reaction, user = await bot.wait_for('reaction_add', check=check)
if role in ctx.author.roles:
await ctx.message.delete()```
can delete via role too
Like that?
await ctx.message.delete()
ya but not sure how to get the user who reacted mentioned in an embed description
no-
ya i realized 🤣
f'<@!{user.id}>' will ping them
Member.mention also exists if you got an object
or User.mention
and it's only valid in the description of the embed and in the values of fields