#discord-bots

1 messages · Page 48 of 1

golden tapir
#

would that work

#

thx ur lots of help

#

can u friend me

#

@potent spear

potent spear
#

just keep questions regarding discord bot development in this server...

golden tapir
#

ok i sent friend request

limber bison
#

i want my bot take capital commands too

#

how can i do that ?

hazy oxide
limber bison
hazy oxide
#

In your commands.Bot, add case_insensitive = True

potent spear
hazy oxide
#

Ya

#

If you want capital only, I think the only way is to add aliases

potent spear
#

I just read it wrong, he wants both I see

hazy oxide
#

Ah

tired notch
#

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

slate swan
#

What code did you do?

#

!d discord.Embed.add_field

unkempt canyonBOT
#

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.
potent spear
#

=> inline should be set to False on third field

tired notch
#

looks like this

robust fulcrum
#

Guys i have a timeout command
I want that if bot dont have timeout permission, so it sends a message
How to do that?

potent spear
potent spear
# tired notch

you haven't set the last field's inline to False, right?

tired notch
#

yeah

robust fulcrum
tired notch
#

there should be an error that you can catch if the bot doesnt have enough perms

potent spear
#

ah, the bot will most likely have an error, you could handle that

potent spear
robust fulcrum
tired notch
#

this makes no sense

potent spear
robust fulcrum
tired notch
#

what

#

i set 4 inline so it should be inline with 3

potent spear
#

by using \u200b as name and value

slate swift
#

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?

golden tapir
#

idk

robust fulcrum
#
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?

golden tapir
#

i am not that smart

potent spear
torn sail
robust fulcrum
pulsar bay
#

hello

potent spear
pulsar bay
#

whats a couple good dbs for py bots

robust fulcrum
# potent spear depends on what your get_prefix method looks like
    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 '>'
slate swift
potent spear
robust fulcrum
potent spear
#

=> a list

torn sail
robust fulcrum
slate swift
potent spear
# robust fulcrum Oh k

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

torn sail
robust fulcrum
potent spear
#

sure

default_prefix = ">"
return [prefix, default_prefix] if prefix else default_prefix```
potent spear
robust fulcrum
# potent spear 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
potent spear
#

yup, you definitely DON'T want to use list as a variable name

robust fulcrum
vocal snow
#

fetchone returns a tuple ?

robust fulcrum
potent spear
#

well, you should just prefix[0] in that case

robust fulcrum
#

Ok

potent spear
# robust fulcrum Ok
default_prefix = ">"
return [prefix[0], default_prefix] if prefix else default_prefix```
tired notch
#

in dpy 2 how do you make slash command arguments have descpriotisn

slate swan
#

Is there a way to have the writing inside and embed description like organised say?

potent spear
slate swan
tired notch
#

oh i meant for the arguments you pass in if the command needs any

slate swan
slate swan
#

thanks!

robust fulcrum
#

Guys i have a timeout command
I want that if bot dont have timeout permission, so it sends a message
How to do that?

slate swan
#

Error handler probably

#

Or just some conditionals

potent spear
tired notch
slate swan
#

That’s an option

robust fulcrum
potent spear
#

right, when passing options in the app_command, you can add extra info

slate swan
tired notch
#

ok thanks

robust fulcrum
slate swan
#

Just do a conditional then

robust fulcrum
potent spear
#

can't you handle that error in the on_error event? not sure

slate swan
#

Give us some more information @robust fulcrum

robust fulcrum
slate swan
potent spear
#

use case most likely:

  1. users uses /timeout <member> command
  2. bot fails to timeout member since it doesn't have timeout perms
  3. bot tries to handle timeout error internally instead of printing its traceback to the console
potent spear
#

can't you handle them in the on_command_error event?

robust fulcrum
potent spear
#

if isinstance(error, <error class which raises>): await ctx.send("woops, I don't have perms to do so")
else: raise error

robust fulcrum
potent spear
#

well, then you should know what to fill in

robust fulcrum
#

Idk i never did that

#

Oh ik

potent spear
robust fulcrum
potent spear
#

if that's the error which the traceback shows...

robust fulcrum
#

Let me show again

potent spear
#

well, as you can read, it's commands.errors.MissingPermissions

robust fulcrum
#

Ok

potent spear
#

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

robust fulcrum
#

Guys how to kick or ban a user in dpy?

vocal snow
#

!d discord.Member.kick

unkempt canyonBOT
#

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").
sick birch
unkempt canyonBOT
#

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").
slate swan
#

I need help with reply embed

slate swift
#
@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
limber bison
#

when i use @vale junco if want i some condiction happen its dont apply ,

limber bison
# slate swift 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

slate swan
#

holy

limber bison
#

i want when the rob fail the cooldown dont apply

#

@vale junco(1, 600, BucketType.user)

#

this

slate swan
#

Isn't it @commands.cooldown ?

slate swift
unkempt canyonBOT
#

%pastebin```
Upload code to dpaste.com, returning the URL.
slate swift
#

oops

limber bison
slate swan
slate swift
#

Honestly I would help I wouldn't know how to help with that

limber bison
#

from discord.ext.commands import cooldown

#

😳

slate swan
#

Yeah

#

Is BucketType.user a thing?

#

and would it not be commands.BucketType.user

#

from discord.ext.commands import cooldown, BucketType

twin hazel
#

discordjs better

vocal snow
#

true

primal token
primal token
unkempt canyonBOT
slate swan
primal token
#

go? more like go home

left idol
#
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

paper sluice
#

you have this twice, why?

if setting == "Enabled":
dull terrace
limber bison
#

which permission remove/ignore channel cooldown ?

slate swan
#

!d help

unkempt canyonBOT
#

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.
slate swan
#

channels

rugged shadow
#

sarth new pfp 😔

slate swan
rugged shadow
potent spear
#

the wrong one for sure

slate swan
#

why doesn't anyone create good video tutorials fr 😔

#

help pls

vocal snow
#

Which lib are you using

#

For discord api

slate swan
#

seems like pycord but discord

#

only pycord has discord.Bot

vocal snow
#

🥴

slate swan
#

yes

#

slash commands aren't created like that in dpy

#

see their examples

#

what should i type instead

vocal snow
#

See their examples

slate swan
#

check pins 🐢 there's a gist for that

#

@uncut zenith.command

vocal snow
#

Sarth new pfp is nice

#

What is it

slate swan
#

its my Spotify aura lol

#

is it @uncut zenith.command

#

i see on yt and thats how it goes

vocal snow
#

Ooh nice

slate swan
#

ohh nvm

#

ty guys

slate swan
#

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

vocal snow
#

Comprehensive documentation is unreadable when you don't know python !

slate swan
#

you need to learn python?

vocal snow
#

👐

slate swan
#

than how i can change the slash comands in a prefix?

vocal snow
#

What

slate swan
# vocal snow 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

vocal snow
#

.lancebot

#

When they gonna fix that

slate swan
cerulean shale
#

Any idea on how i can get thumbnail and links?

rugged shadow
#

la da la da da da da la da da la da la da da la la da da

rugged shadow
cerulean shale
# rugged shadow 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)
rugged shadow
#

yea aiohttp parses it for you ig

cerulean shale
#

this is my code

#

it isnt doing it

cerulean shale
rugged shadow
cerulean shale
#

this is how it is, under thumbnail i have to get the link from genius

slate swan
#

dict[key][key]
is valid too

#

since json is automatically converted to dict by aiohttp

cerulean shale
#

ight

pulsar bridge
#

New to Python (Since this morning MeguDed) 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?

cerulean shale
pulsar bridge
#

I've tried the guild's ID, didn't work

vale wing
#

Guild is accessible via ctx.guild

pulsar bridge
#

What if it's under an on_message event?

vale wing
pulsar bridge
#

New to Python -- I've programmed in other languages

vale wing
#

!d discord.Message

unkempt canyonBOT
#

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.
pulsar bridge
#

Hmm.. I must've mistyped or had a logic error cause that didn't work

#

But I'll try again Jas_thumbsup

vale wing
pulsar bridge
#

I have the intent enabled

vale wing
#

Both in code and in dev portal right?

pulsar bridge
#

mhm~

#

OH

#

I FOUND THE ERROR
One of my elif's was indented a bit too much

#

Not used to python's strict indenting MeguExploded

vale wing
#

Happens

pulsar bridge
#

Thanks anyway though!

lone lichen
#

Not in python

rapid knoll
#

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

unkempt canyonBOT
#

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").
silk fulcrum
#

set minutes to 20 and feel nice

slate swan
#

,

rapid knoll
#

thanks I spent like an hour trying to do this haha

silk fulcrum
#

siht pahhens

silk fulcrum
shrewd apex
#

👀

silk fulcrum
#

rapid knoll
#

oh and how would I pair this with

@bot.command()
    async def ...():

silk fulcrum
#

wdym pair with command?

#

do you want cooldown?

shrewd apex
#

maybe they want to run the command every 20 min

silk fulcrum
#

@shrewd apex how does code jam category look like

shrewd apex
#

wdym code jam category?

silk fulcrum
#

isnt there some category named CODE JAM?

shrewd apex
#

it's just two channels one channel for your team

silk fulcrum
#

youre a participant

shrewd apex
silk fulcrum
shrewd apex
#

for talking with others

silk fulcrum
shrewd apex
rapid knoll
silk fulcrum
#

burh

#

then why do you need a command for thath

slow fog
silk fulcrum
#

morning

rapid knoll
slow fog
silk fulcrum
#

mr

slow fog
silk fulcrum
slow fog
slate swan
silk fulcrum
#

he wants to call it every 20 mins

slow fog
#

oh

rapid knoll
#

I only know how to use commands I have never used anything else

cerulean shale
#

any idea on what is embed type?

slow fog
#

@tasks.loop(minutes=20)
async def something():
....
rugged shadow
slow fog
#

and to start it it should be under the on_ready section something.start()

slow fog
silk fulcrum
#

start in on_ready :blobpain:

slow fog
cerulean shale
slow fog
#

i dont know what he wants exactly

cerulean shale
#

EmbedType = 'rich

slate swan
silk fulcrum
slate swan
#

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

slate swan
slow fog
#

lmao

cerulean shale
silk fulcrum
slate swan
silk fulcrum
cerulean shale
silk fulcrum
#

!d discord.Embed.type

unkempt canyonBOT
#

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

silk fulcrum
#

Possible strings for embed types can be found on discord’s api docs

cerulean shale
#

got it

slate swan
silk fulcrum
#

ok..

cerulean shale
#

thx

pulsar solstice
#

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```
slow fog
#

you must start the task

silk fulcrum
#

await loop.start()

pulsar solstice
silk fulcrum
#

and start in on_ready at least...

#

@pulsar solstice

pulsar solstice
slate swan
#

also, bot.send is not a thing

silk fulcrum
#

yaeh

pulsar solstice
#

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'```
silk fulcrum
#

oops ping

slate swan
#

sarth is so lovely, he won't mind

pulsar solstice
silk fulcrum
#

lol

slate swan
#

😔 atleast someone pings me

slow fog
slate swan
silk fulcrum
slate swan
slate swan
slow fog
#

oh bruh

slate swan
#

you need to get_ a channel first, then use send on it

slate swan
pulsar solstice
#

what u mean?

slate swan
#

!d discord.Client.get_channel

unkempt canyonBOT
#

get_channel(id, /)```
Returns a channel or thread with the given ID.

Changed in version 2.0: `id` parameter is now positional-only.
slate swan
#
await bot.get_channel(channel id).send("uwu")
``` pretty straightforward
slow fog
#

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

slate swan
#

🗿```py
bot.http.send_message(channel id, "stuff")

#

until they did some weird stuff in 2.0

silk fulcrum
slate swan
#

🚶‍♂️ 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
silk fulcrum
#

your bot can't send message in that channel

slate swan
#

i wonder what can Missing Permissions mean

silk fulcrum
paper sluice
#

"was the dished" pithink

silk fulcrum
#

lol lags

glad cradle
#

!paste

unkempt canyonBOT
#

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.

glad cradle
vale wing
#

@glad cradle show where do you add the views

glad cradle
#

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

vale wing
#

Disnake doesn't have setup_hook afaik

glad cradle
#

no disnake doesn't have setup_hook

#

so should I overwrite the start method?

vale wing
#

Yes

#

I always do that

#

For all the setup stuff

glad cradle
#

do you have any example?

vale wing
#

Yeah one sec

unkempt canyonBOT
#

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)```
vale wing
#

There's also I method which involves asyncio but I prefer not to smoke that grass

slate swan
#

why not just ```py
async def main():
await bot.setup_persistent_views()
bot.run()

asyncio.run(main())

vale wing
#

Overriding is faster and more elegant imo

vale wing
#

Anyway do whatever you want

glad cradle
vale wing
#

Subclassing*

silk fulcrum
#

I only overwrite start method to pass the token there

glad cradle
vale wing
#

Yes

slate swan
#

🚶‍♂️i wonder why discord.py asks for the token in start method

#

could have just used the Client obj

silk fulcrum
#

bot.start(one_token)
bot.start(second_token)

#

have 2 bots :lmao:

vale wing
#

🗿

silk fulcrum
#

well it probably wont work cus of some app info but

glad cradle
# vale wing Yes

Good, thx for the example, I'll work on it later, if I'll have some problems can I write to you in DMs?

glass sapphire
#

how can i made a help menu like this

#

in python

vale wing
silk fulcrum
glad cradle
silk fulcrum
glass sapphire
silk fulcrum
unkempt canyonBOT
#

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.
vale wing
#

Ya were supposed to link the examples not the docs

slate swan
#

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> ```
vale wing
#

The views are hard to understand just from docs

silk fulcrum
glad cradle
silk fulcrum
slate swan
vale wing
#

Isn't it async

slate swan
#

can use create_task for the first bot to run

silk fulcrum
slate swan
#

thats how the bot keeps running

vale wing
#

Why not just asyncio.gather everything

slate swan
glad cradle
#

can't he include them in a function async def main():
and then run the function with asyncio.run(main())?

slate swan
#

!intents

unkempt canyonBOT
#

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.

silk fulcrum
slate swan
vale wing
#

The best solution would be to just run several instances of script then

glad cradle
silk fulcrum
#

lmao wth is wrong with me today

slate swan
#
import asyncio

loop = asyncio.get_event_loop()
loop.create_task(bot1.start())
loop.run_until_complete(bot2.start())
``` should work maybe
slate swan
#

yes in 3.10+ you need to create a new loop yourself

#

though its just a warning for now

polar granite
maiden fable
#

Nice

limber bison
#
    @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
silk fulcrum
#

on what does it apperar?

#

when*

#

when you delete a vc channel?

limber bison
#

no on create

#
  • adding new members too
shrewd apex
#

pvc reminds me of pipes 🗿

silk fulcrum
#

btw you dont have to put that many ors to check the upper case you can do if message.content.lower() == 'yes'

limber bison
shrewd apex
unkempt canyonBOT
shrewd apex
#

so much more convenient

glass sapphire
#
@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)
unkempt canyonBOT
#

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.

glass sapphire
#

this is my code

#

im taking this errors

shrewd apex
#
@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

glass sapphire
#

huh is that much easy

shrewd apex
#

also how is someone supposed to type this command that i is weird it's not there in my keyboard pithink

silk fulcrum
#

?yardım

#

!charinfo ı

unkempt canyonBOT
silk fulcrum
#

bruh

glass sapphire
#

this time i am taking this error

polar granite
#

How to fix this?

silk fulcrum
#

fields names cant be empty

silk fulcrum
silk fulcrum
#

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/)")

polar granite
#

Wait giving you multiplier link @silk fulcrum come dm

glad cradle
# polar granite How to fix this?

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)

polar granite
#

I am with phone

glad cradle
#

delete the phone

polar granite
silk fulcrum
slate swan
#

Are you unable to use "<@{}>" inside embed.set_footer description?

glad cradle
slate swan
slow fog
#

on footer

silk fulcrum
shrewd apex
#

not even emojis

slate swan
shrewd apex
#

use buttons nowpithink

silk fulcrum
slow fog
glass sapphire
#

how can i do the bottom clickable

#

writing hakkında

glad cradle
shrewd apex
slate swan
shrewd apex
silk fulcrum
#

does af mean as fu... ?

glad cradle
#

why emojis are still used as buttons 😭

shrewd apex
#

something like this or was iirc

shrewd apex
silk fulcrum
#

bruh

slow fog
glad cradle
#

😭

glass sapphire
#

like this

glad cradle
#

it's a shitty look

glad cradle
shrewd apex
#

actually for me reactions are too small and buttons are too big none of them are able to portray the emoji perfectly

glad cradle
maiden fable
#

@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 💀

shrewd apex
#

ignorance is bliss

maiden fable
#

I agree

#

"But sadly with discord limitations it would just be a brick" If u want to lie, blame it on discord. Nice

silk fulcrum
shrewd apex
maiden fable
shrewd apex
maiden fable
#

Nice

#

B-but they use djs

#

@shrewd apex can u share the link where they said that tho?

shrewd apex
#

yeah lemme search

maiden fable
#

This is just a general thing 😄

#

Not like it will take 10 years to compile a program to show length of a list :D

shrewd apex
#

here u go

maiden fable
#

Yes. Discord gonna die till they compile the program that saves len(role.members), so understandable

shrewd apex
#

they made it proxy type to save time

maiden fable
shrewd apex
#

except js

maiden fable
#

It can't take like 1 GB of RAM to just show len lol

shrewd apex
#

nah it won't even take half a mb

#

prolly even less

maiden fable
#

that was sarcasm but yea

shrewd apex
#

ik just saying 🥲

pulsar solstice
#

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

shrewd apex
#

btw use if user_id not in jar more pythonic

#

means it has no key cookies

maiden fable
#

Also, u should take a look at r+ open mode

pulsar solstice
#

ok?

maiden fable
#

That means first read, then write

pulsar solstice
#

still getting the same error

maiden fable
#

So you don't have to open the file repeatedly

maiden fable
maiden fable
pulsar solstice
maiden fable
#

Just add a check if the user exists and if it doesn't then send The user doesn't exists?

glass sapphire
#
[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

silk fulcrum
#

you didnt import select

#

from discord.ui

glass sapphire
#
@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)```
shrewd apex
#

no timeout 👀

maiden fable
#

from discord.ui import Select

glass sapphire
#

view = View()

slate swan
#

is there anyone to return session_id from discord websocket?

maiden fable
glass sapphire
maiden fable
maiden fable
maiden fable
pulsar solstice
slate swan
#

incase

maiden fable
slate swan
maiden fable
#

Ah

slate swan
#

Ok

maiden fable
#

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

silk fulcrum
slate swan
#

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

silk fulcrum
#

so what's the problem?

slate swan
#

Idk how i can make like get lines of an file & send the amount thats give up of lines to the person

#

@silk fulcrum

silk fulcrum
#

a

slate swan
#

Can u help or make it for me

silk fulcrum
unkempt canyonBOT
#

8. Do not help with ongoing exams. When helping with homework, help people learn how to do the assignment without doing it for them.

rugged shadow
pulsar solstice
rugged shadow
#

it's only homework or exams that have a rule to it

silk fulcrum
#

at least json

paper sluice
silk fulcrum
#

ohkay

pulsar solstice
#

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
paper sluice
#

member = discord.Member i think this is meant to be a type hint

silk fulcrum
#

randint is better than randrange if randrange even works

slate swan
#

embed.set_footer(text="Total Value{lim1}+{lim2}") how do i make it add lim1 and lim2 together?

pulsar solstice
paper sluice
slate swan
silk fulcrum
pulsar solstice
silk fulcrum
#

they cannot edit personal info, but you can do it manually

#

or can they?

silk fulcrum
slate swan
paper sluice
unkempt canyonBOT
#

Lib/random.py line 328

def randint(self, a, b):```
paper sluice
#

rip

pulsar solstice
#

check

silk fulcrum
slate swan
#

okay

silk fulcrum
#

idk if that works but you can try await guild.me.edit(nick="uwu") @placid talon

slate swan
#

it should

#

if nick doesn't, then it should be nickname

#

!d discord.Member.edit

unkempt canyonBOT
#

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...
slate swan
#

ywah its nick

pulsar solstice
#
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?

pulsar solstice
#

ohh sorry wait

silk fulcrum
#

!code

unkempt canyonBOT
#

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.

slate swan
#

= should be :

silk fulcrum
#

typekidding

slate swan
#

= is used to assign a value
: is used for typehinting

pulsar solstice
# silk fulcrum !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):
    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>")```
paper sluice
#

combine both and you have a cooler assignment operator

slate swan
#

walrus lol

pulsar solstice
silk fulcrum
slate swan
paper sluice
slate swan
paper sluice
#

forgot !e 💀

#

i have been ill for the past 2 weeeks, have lost my flow here

slate swan
#

!e ```py
import random

print(random.choice([a:=1, 2]))
print(a)

unkempt canyonBOT
#

@slate swan :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | 1
002 | 1
silk fulcrum
slate swan
#

me

silk fulcrum
#

ok..

paper sluice
vocal snow
#

Its also useful in regular code !

paper sluice
pulsar solstice
#

because my new error;

silk fulcrum
#

bruh

pulsar solstice
#
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```
pulsar solstice
slate swan
pulsar solstice
winged coral
#

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:

pulsar solstice
#
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

slate swan
#

you still didn't made any changes i asked you to

winged coral
#

I’ve given you the solution

pulsar solstice
slate swan
winged coral
#

Both of us have given you the solution

pulsar solstice
winged coral
#

It would help if you used them?

cerulean shale
#

Is there any way to break a line in f string? In embeds i mean

paper sluice
pulsar solstice
cerulean shale
vocal plover
#

only the interpolation part of an f-string cant

slate swan
cerulean shale
#

Wdym?

rugged shadow
#

!e f"\n"

slate swan
#

the f string can

unkempt canyonBOT
#

@rugged shadow :warning: Your 3.11 eval job has completed with return code 0.

[No output]
vocal plover
#

if you have f"abc\n{variable_name}" that's fine

#

but f"{variable_name + '\n'}" isnt

slate swan
#
f"this \nis \nlegit"
f"this {'is\nnot'}"
cerulean shale
pulsar solstice
cerulean shale
#

Should I just add fields?

pulsar solstice
#
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```
slate swan
#

how do i reply to the message a button is attached to?

slate swan
vocal plover
#

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

slate swan
unkempt canyonBOT
silk fulcrum
paper sluice
cerulean shale
pulsar solstice
vocal plover
# cerulean shale

You need to use separate {} sections for each of the embedded variables

paper sluice
#

@leaden cosmos do it in #bot-commands please

slate swan
slate swan
slate swan
#

oh

cerulean shale
silk fulcrum
#

nothing

vocal plover
# cerulean shale As in fields?

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}"
silk fulcrum
#

it's removed since the PyPI release

slate swan
unkempt canyonBOT
#
Noooooo!!

No documentation found for the requested symbol.

slate swan
#

wait did they rename it?

silk fulcrum
#

!d discord.Interaction.original_response

unkempt canyonBOT
#

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.
cerulean shale
slate swan
#

cursed

silk fulcrum
#

hehe

slate swan
silk fulcrum
#

i had that problem when swithcing to pypi version

pulsar solstice
# silk fulcrum 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?

slate swan
#

I'd make sure to wrap the interaction class to a custom one while using discord.py

slate swan
silk fulcrum
slate swan
#

yep, an interaction can be responded only once

silk fulcrum
#

im not sure, never used it

slate swan
pulsar solstice
silk fulcrum
pulsar solstice
#

everyone should use randint

vocal plover
#

... what

silk fulcrum
#

should use randrange*

vocal plover
#

you're supposed to use randrange

pulsar solstice
silk fulcrum
#

now i look like an idiot

#

well... always was

pulsar solstice
slate swan
#

!d discord.Interaction.followup

unkempt canyonBOT
slate swan
#

@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

silk fulcrum
#

well, anyways you can send ephemeral message again:)

slate swan
#

yea

#

I have this, but i want that he send the amount of tokens he gives up in Option

vocal snow
#

discord.Number

slate swan
#

from tokens.txt

slate swan
vocal snow
#

if you're using pycord it might be 🤣

silk fulcrum
#

yes, this looks exactly same as the boost bot I saw

slate swan
#

But i need to send the amount he gives up

silk fulcrum
#

did you buy that or what?

slate swan
#

How can i do that

silk fulcrum
#

or sell...

slate swan
#

No i'm making it

pulsar solstice
#

what should I do!!

#

🌚

slate swan
#

But can someone help?

silk fulcrum
#

(not whole code, code of command is enough)

pulsar solstice
#

sorry for that btw

slate swan
#

Bro?

silk fulcrum
pulsar solstice
#
@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)
slate swan
pulsar solstice
#

@silk fulcrum

silk fulcrum
slate swan
#

Lol

silk fulcrum
#

!rule

unkempt canyonBOT
#

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.

silk fulcrum
#

bruh

#

!rule 5

unkempt canyonBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.

slate swan
#

bRO

#

U have already help me before

silk fulcrum
#

accident

silk fulcrum
#

no idea how should that work

pulsar solstice
slate swan
#

How can i read an file and send the amount thats giving up

silk fulcrum
#

btw you are getting negative numbers if im not mistaking

pulsar solstice
slate swan
#

Can someone help?
How can i read an file and send the amount of lines thats giving up by the / command option

#

!d open

unkempt canyonBOT
#

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`.)
silk fulcrum
slate swan
#

hm?

silk fulcrum
#

hes making boost bot

pulsar solstice
#

!rule 5

unkempt canyonBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.

slate swan
#

tf is that lol

silk fulcrum
#

what that?

#

you didnt know about rule 5?

shrewd apex
#

what's a boost bot

slate swan
#

ik about that, but whats a boost bot

rugged shadow
#

bot that boost

#

💯

silk fulcrum
#

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

slate swan
#

sounds phishy

pulsar solstice
#

@silk fulcrum btw did u checked out what's randrange

silk fulcrum
#

btw proved: captcha doesnt do anything, because this system skips it

slate swan
#

!d random.randint

unkempt canyonBOT
#

random.randint(a, b)```
Return a random integer *N* such that `a <= N <= b`. Alias for `randrange(a, b+1)`.
silk fulcrum
slate swan
#

b should always be smoler than a

silk fulcrum
#

so you probably remove 0 from it

#

idk if that helps

slate swan
#

or equal

silk fulcrum
#

oh

pulsar solstice
pulsar solstice
silk fulcrum
#

i thought it can go backwards

slate swan
#

@slate swan

silk fulcrum
slate swan
#

Can u help me?

silk fulcrum
#

0 is set by default

pulsar solstice
#

BRAIN

slate swan
#

!e ```py
print(import("random").randint(1,2))

unkempt canyonBOT
#

@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)
slate swan
#

See, same.error as yours

slate swan
#

your b is smaller than a

silk fulcrum
#

sed

#

oh wait

slate swan
silk fulcrum
#

-1 step

slate swan
#

!e ```py
print(import("random").randint(1,2))

unkempt canyonBOT
#

@slate swan :white_check_mark: Your 3.11 eval job has completed with return code 0.

1
silk fulcrum
#

@pulsar solstice add , -1 to your randrange

slate swan
#

it works

pulsar solstice
slate swan
cerulean shale
#

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)
silk fulcrum
#

!e py print(__import__("random").randrange(0, -4468, -1))

unkempt canyonBOT
#

@silk fulcrum :white_check_mark: Your 3.11 eval job has completed with return code 0.

-3957
limber bison
#

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 ?

limber bison
silk fulcrum
# pulsar solstice why?!?!/

-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)

silk fulcrum
#

it always was there

limber bison
#

new for me

slate swan
#

thats the way, import statment uses it

limber bison
cerulean shale
vocal plover
vocal plover
#

the .nf formatting directive will format to n decimal places, so giving 0 means it'll format it as an integer

cerulean shale
#

ight got it

slate swan
# cerulean shale ???

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

silk fulcrum
limber bison
#

got it

limber bison
#

await commad.cooldown.reset()

slate swan
#

don't think its an awaitable

silk fulcrum
#

why

limber bison
#

return ?

slate swan
#

return isnt used like that-

silk fulcrum
#

AHAHHA it's app_commands.Cooldown now

#

u still can use commands.cooldown deco

pulsar solstice
silk fulcrum
#

but it's app_commands.Coooldown

pulsar solstice
#
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)```
slate swan
#

weird weird weird, why is commands.Command.cooldown an app_commands.Cooldown object

silk fulcrum
#

like randrange(0, -12904812, -1)

limber bison
#

like i want if i use a command and in command a if condition i dont want if that run command go on cooldown

silk fulcrum
#

@Rapptz why?

slate swan
#

or just do the latter, randrange(-12904812, 0)

silk fulcrum
#

well, possible

slate swan
silk fulcrum
#

lmao im with you

pulsar solstice
#
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?

kindred kernel
pulsar solstice
kindred kernel
pulsar solstice
#

wtf wtf

#

master 32

#

master 64

#

master 86

#

wtf?!?!?!

shrewd apex
kindred kernel
# shrewd apex 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

slate swan
#

they are totally different

kindred kernel
#

btw click on that Cooldown in the docs

#

it's app_commands.Cooldown

slate swan
#

no?

kindred kernel
#

and there is no ext.commands.Cooldown

kindred kernel
unkempt canyonBOT
#

discord/ext/commands/cooldowns.py line 37

from discord.app_commands import Cooldown as Cooldown```
slate swan
#

so I guess they simply shifted it to be in app_commands

slate swan
# slate swan wdym?

how cooldown property of a normal prefix command being an app_commands.Cooldown object make sense?

slate swan
unkempt canyonBOT
#
Out of the question.

No documentation found for the requested symbol.

slate swan
#

undocumented behaviour

slate swan
#

could have just wrapped app_commands.Cooldown as a sublass of commands.Cooldown but yeah, discord.py moment

vocal snow
#

sarth make pr and fix
!!

slate swan
#

I don't even have my laptop with me these days :p

vocal snow
#

: {

slate swan
#

my only contribution in discord.py is changing a value from 0 to 25

slate swan
#

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):
        ...

slate swan
#

def not studying, just travelling

#

How 🙏

#

Oh

#

views are persistent, not the buttons themselves so

#

The view has to be persistive right

#

Yeah

slate swan
#

no noooooo don't make me imagine that

#

Wait @slate swan does adding timeout=None to my view make it persistent?

modern fiber
#

How do I get trigger deleted right after the command is done?

slate swan
#

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))

lone lichen
lone lichen
slate swan
modern fiber
lone lichen
#

Check the docs on what it returns

gusty shard
#

is it possbile to see if message replied like that?

lone lichen
modern fiber
vocal snow
unkempt canyonBOT
#

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.

lone lichen
unkempt canyonBOT
#
Noooooo!!

No documentation found for the requested symbol.

vocal snow
lone lichen
#

!d discord.Message.reference

unkempt canyonBOT
#

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.

lone lichen
unkempt canyonBOT
#

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.
slate swan
slate swan
slate swan
#

await ctx.message.delete()

lone lichen
#

It’ s a functrion

#

U call it

slate swan
slate swan
slate swan
#

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