#discord-bots

1 messages · Page 1111 of 1

vale wing
#

What was invented first

dull terrace
#

unreal or unity

grim oar
vale wing
#

Tbh I know both java and c# and they are pretty similar but for some reason java is less readable

#

Probably because of different naming conventions

grim oar
#

Both are garbage too

vale wing
#

Well ur opinion

grim oar
#

No, fact

slate swan
#

Kannakillyourself get over everything and use rust

grim oar
#

And flex others that you use rust, also I use arch btw

maiden fable
#

and also take this to an ot

slate swan
#
    @discord.ui.button( emoji = f"{e_checkMark}", style=discord.ButtonStyle.green, row=1)
    async def iron_yes(self, interaction: discord.Interaction, button: discord.ui.Button):
        embed = discord.Embed(
            description= "Проверяем вас на судимость наличие должности в другой компании..", 
            color= 0x00b300
        )

        file = discord.File("./ImageO/Экономика/Эмодзи/Железо.png", filename="Железо.png")
        embed_dict = embed.to_dict()

        embed = discord.Embed.from_dict(embed_dict)
        embed.set_footer(
            text = "| Шахта SK",
            icon_url = "attachment://Железо.png"
        )


        await interaction.response.edit_message(attachments=[file], embed = embed)

Dear, please tell me why it does not see the file, although I checked the correct path in the folders

brave flint
#

how to send a interaction.response when a view is shown?

slate swan
grim oar
#

Yeah try

#

Full path

#

C:/bot py/ImageO/Экономика/Эмодзи/Железо.png

#

It shud work normally too :thonk:

slate swan
#

Hello World

grim oar
#

Goodbye worl 😩

brave flint
slate swan
#

classed a buttons.....what

slate swan
brave flint
#

classed a view

slate swan
#

subclassed*

brave flint
#

YES

slate swan
#

ok and what do you mean by "shown"

brave flint
#

hmm

vocal snow
brave flint
#

so i send the view like with embed

slate swan
#

when the button is clicked?

brave flint
slate swan
slate swan
brave flint
#

i wanna the first responded embed from the ctx stay, then send a new embed for be edited with the views

#

can or cant?

slate swan
#

you can, totally can

brave flint
#

um how ?

slate swan
#

you want to edit the original embed or keep it as it is?

brave flint
#

and edit a embed from the view

slate swan
#

easy as that

brave flint
#

so i can just edit the response because num 2 embed

#

ik" thx

slate swan
#

yep

#
    @discord.ui.button( emoji = f"{e_checkMark}", style=discord.ButtonStyle.green, row=1)
    async def iron_yes(self, interaction: discord.Interaction, button: discord.ui.Button):
        embed = discord.Embed(
            description= "Проверяем вас на судимость наличие должности в другой компании..", 
            color= 0x00b300
        )

        file = discord.File("C:/bot py/ImageO/Эмодзи/Ресурсы/Железо.png", filename="Железо.png")
        embed_dict = embed.to_dict()

        embed = discord.Embed.from_dict(embed_dict)
        embed.set_footer(
            text = " | Шахта SK",
            icon_url= 'attachment://Железо.png'
        )


        await interaction.response.edit_message(embed = embed)

Dear, it does not give errors, but it does not load the picture in the footer either. help me please

#

discord python question: how to make my discord bot update its status in real time (every 1min), show in status how many guilds it is in?

@client.event
async def on_ready():
   version = discord.Activity(type=discord.ActivityType.watching, name=f"{len(client.guilds)} servers!")
   await client.change_presence(status=discord.Status.online, activity=version)
   print(f'{client.user} has connected to Discord!')```
slate swan
#

you can filename="image.png" and "attachment://image.png" , that will work

slate swan
#
    @discord.ui.button( emoji = f"{e_checkMark}", style=discord.ButtonStyle.green, row=1)
    async def iron_yes(self, interaction: discord.Interaction, button: discord.ui.Button):
        embed = discord.Embed(
            description= "Проверяем вас на судимость наличие должности в другой компании..", 
            color= 0x00b300
        )

        file = discord.File("C:/bot py/ImageO/Эмодзи/Ресурсы/Железо.png", filename="iron.png")
        embed_dict = embed.to_dict()

        embed = discord.Embed.from_dict(embed_dict)
        embed.set_footer(
            text = " | Шахта SK",
            icon_url= 'attachment://iron.png'
        )


        await interaction.response.edit_message(embed = embed)

Oh, for some reason it also does not display a photo

slate swan
grim oar
#

I think it's cuz you making a new embed out of older's dict

#

Idk

slate swan
#

yeah the dict conversion may be the issue

#

and I don't see any usage of that either

slate swan
grim oar
#

yes

slate swan
#
    @discord.ui.button( emoji = f"{e_checkMark}", style=discord.ButtonStyle.green, row=1)
    async def iron_yes(self, interaction: discord.Interaction, button: discord.ui.Button):
        embed = discord.Embed(
            description= "Проверяем вас на судимость наличие должности в другой компании..", 
            color= 0x00b300
        )

        file = discord.File("C:/bot py/ImageO/Эмодзи/Ресурсы/Железо.png", filename="iron.png")
        embed.set_footer(
            text = " | Шахта SK",
            icon_url= 'attachment://iron.png'
        )


        await interaction.response.edit_message(embed = embed)

(((

grim oar
#

:loading:

#

Have you restarted it

slate swan
grim oar
#

I forgor

slate swan
#

bruh

grim oar
#

!d discord.ext.tasks.loop

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").
grim oar
#

so

#

You decorate it

#
@tasks.loop()
async def f():
   ...

f.start()
#

Idk

spring flax
#

yep

#

just pass the time to repeat each loop in the decorator

#

example ```py
@tasks.loop(seconds=10)

slate swan
#

no

#

discord python question: how to make my discord bot update its status in real time (every 1min), show in status how many guilds it is in?

@client.event
async def on_ready():
   version = discord.Activity(type=discord.ActivityType.watching, name=f"{len(client.guilds)} servers!")
   await client.change_presence(status=discord.Status.online, activity=version)
   print(f'{client.user} has connected to Discord!')```
grim oar
#

Don't do it in on_ready

slate swan
#

look i only want the activity part to repeat, but the last two lines i dont want it to

spring flax
grim oar
#

Change activity in tasks loop and set presence in bot constructor

slate swan
#

wait

spring flax
#

they will have to use a task loop for this

grim oar
#

yes

spring flax
#

just put the code you have in the oin_ready function except the print statement into the task loop

#

on*

slate swan
#

why does it have to be in task loop?

grim oar
#

cuz it can crash the bot

spring flax
#

doing API calls on the on_ready is not good

#

and also how would code which is put on on_ready repeat every one minute

slate swan
#

like this?

@tasks.loop(minutes=1)
async def bot_servers():
    version = discord.Activity(type=discord.ActivityType.watching, name=f"{len(client.guilds)} servers!")
    await client.change_presence(status=discord.Status.online, activity=version)

bot_servers.start()


#on_ready
@client.event
async def on_ready():
    print(f'{client.user} has connected to Discord!')```
grim oar
#

Yes

slate swan
#

Unhandled exception in internal background task 'bot_servers'.
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/ext/tasks/init.py", line 101, in _loop
await self.coro(*args, **kwargs)
File "/Users/bai/Documents/Personal Things/Do not delete/Only viewable by me/Aww Pika Discord Bot/aww pika discord bot.py", line 48, in bot_servers
await client.change_presence(status=discord.Status.online, activity=version)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/client.py", line 1062, in change_presence
await self.ws.change_presence(activity=activity, status=status, afk=afk)
AttributeError: 'NoneType' object has no attribute 'change_presence'

#

error @grim oar

eager bluff
#

r!whois and wdym how do you use it

grim oar
#

Aaa

spring flax
#

!d discord.ext.commands.Bot.wait_until_ready

unkempt canyonBOT
#

await wait_until_ready()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Waits until the client’s internal cache is all ready.

Warning

Calling this inside [`setup_hook()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.setup_hook "discord.ext.commands.Bot.setup_hook") can lead to a deadlock.
vale wing
grim oar
#

Yes

slate swan
vale wing
#

If you typehinted the argument correctly

grim oar
#

Put that right below function declaration

slate swan
grim oar
#

async def f():
await bot.wait_until_ready()
...

spring flax
#

i assume his bot instance is client so just change that when using that code

grim oar
#

Yes

slate swan
#

Unhandled exception in internal background task 'bot_servers'.
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/ext/tasks/init.py", line 101, in _loop
await self.coro(*args, **kwargs)
File "/Users/bai/Documents/Personal Things/Do not delete/Only viewable by me/Aww Pika Discord Bot/aww pika discord bot.py", line 47, in bot_servers
await wait_until_ready()
NameError: name 'wait_until_ready' is not defined

#

still error

grim oar
#

client.wait_until_ready

spring flax
#

it's a method of commands.Bot

slate swan
#

Warning (from warnings module):
File "/Users/bai/Documents/Personal Things/Do not delete/Only viewable by me/Aww Pika Discord Bot/aww pika discord bot.py", line 47
client.wait_until_ready()
RuntimeWarning: coroutine 'Client.wait_until_ready' was never awaited
Unhandled exception in internal background task 'bot_servers'.
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/ext/tasks/init.py", line 101, in _loop
await self.coro(*args, **kwargs)
File "/Users/bai/Documents/Personal Things/Do not delete/Only viewable by me/Aww Pika Discord Bot/aww pika discord bot.py", line 49, in bot_servers
await client.change_presence(status=discord.Status.online, activity=version)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/client.py", line 1062, in change_presence
await self.ws.change_presence(activity=activity, status=status, afk=afk)
AttributeError: 'NoneType' object has no attribute 'change_presence'

grim oar
#

second iirc

#

Wha

#

Show code

slate swan
#

i forgot to put await lol

#

thxs

grim oar
#

np

maiden fable
#

Does that even change anything? Putting await...

#

That error means the bot isn't even ready lol

grim oar
#

yes and awaiting wait_until_ready will make it wait until the bot is connected

eager bluff
brave flint
#

eh nvm i think my fault

#

wait

slate swan
#

Slash command important for bots?

slate swan
brave flint
#

nah i arl got it

#

sorry i forgot to deleteee

#

thanks btw

sick birch
slate swan
#

Big?

slate swan
# slate swan Slash command important for bots?

it's not important important
it's just recommended since slash commands are based on webhooks not messages
slash commands are into the light due to the discord api privileging message content.
so, all your normal commands such !ping/.ping/etcetera (ext.commands) are basically advanced on_message commands
and that's why they will stop working until and unless your bot gets approval for the message content intent from discord

#

Ok thanks

slate swan
dry kelp
slate swan
#

nice

dry kelp
#

Sorry i need an explanation
how does a thread join?

serene mantle
#

Anyone here have any experience with PyCord?

#

i made some slash commands for my Discord Bot, and for some reason they're only visible to admins

slate swan
slate swan
#

@slate swan

#

3rd last message

slate swan
dry kelp
#

no

slate swan
dry kelp
#

this is

slate swan
slate swan
maiden fable
slate swan
#

Ok sir

sick birch
#

That was before they were enforcing was it not?

maiden fable
maiden fable
#

Or was it Jan 2022? I remember my bot getting verified just a day before discord staff went on a holiday

sick birch
slate swan
#

2022

#

👀

maiden fable
#

Ah, I meant when discord announced that message content gonna be a privileged intent and forced suggested everyone to move to slash commands

#

There was this rumor that time that discord won't verify your bot if it doesn't have slash commands and apparently a few people still dk that it's false

slate swan
#

Applications for requesting the intent began on Monday, Oct 25, 2021

#

for Robin.

sick birch
#

Ah okay

#

Looks like I was misundestanding

maiden fable
#

Indeed

slate swan
eager bluff
#

i think my bot is accidentally calling from the wrong library, how do i fix this?

eager bluff
#
@has_permissions(manage_guild=True)  # Guild managers only.
async def setrank(ctx, username, rank: int):
    if 255 >= rank >= 1:  # Make sure rank is in allowed range
        group = await roblox.get_group(9258046)  # Group ID here
        member = await group.get_member_by_username(username)
        await member.setrole(rank)  # Sets the rank
        await ctx.send("Promoted user.")
    else:
        await ctx.send("Rank must be at least 1 and at most 255.")```
#

its supposed to call from roblox library

#

instead it calls from discord library

#

error:

Traceback (most recent call last):
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "c:\Users\thoma\OneDrive\Desktop\DiscordBot\main.py", line 53, in setrank
    await member.setrole(rank)  # Sets the rank
AttributeError: 'MemberRelationship' object has no attribute 'setrole'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'MemberRelationship' object has no attribute 'setrole'```
grim oar
#

The member of roblox api wrapper doesn't have setrole

eager bluff
#

because its discord.ext.commands.errors.CommandInvokeError

heady sluice
grim oar
#

CommandInvokeError wraps all the errors

eager bluff
#

alright so i need to find the substitute for setrole then right

grim oar
#

Yes

slate swan
#
    @discord.ui.button( emoji = f"{e_checkMark}", style=discord.ButtonStyle.green, row=1)
    async def iron_yes(self, interaction: discord.Interaction, button: discord.ui.Button):
        embed = discord.Embed(
            description= "Проверяем вас на судимость наличие должности в другой компании..", 
            color= 0x00b300
        )

        file = discord.File("C:/bot py/ImageO/Эмодзи/Ресурсы/Железо.png", filename="iron.png")
        embed.set_footer(
            text = " | Шахта SK",
            icon_url= 'attachment://iron.png'
        )


        await interaction.response.edit_message(embed = embed, view=None)
        await asyncio.sleep(2)
        
        embed1 = discord.Embed(
            description= "Проверка пройдена. ожидайте подписи генерального директора...", 
            color= 0x00b300
        )

        file = discord.File("C:/bot py/ImageO/Эмодзи/Ресурсы/Железо.png", filename="iron.png")
        embed.set_footer(
            text = " | Шахта SK",
            icon_url= 'attachment://iron.png'
        )
        await interaction.response.edit_message(embed= embed1)

Dear, tell me how to fix the change error

kindred epoch
#

You can only respond to a button once

slate swan
kindred epoch
#

Ye but I forgot how

#

Ask Robin or wait for someone else

slate swan
#

Well, it's good that there is an opportunity)

torn sail
#

!d discord.Interaction.followup

unkempt canyonBOT
shrewd apex
#

or interaction.edit_original_message if u just want to edit the message again

slate swan
shrewd apex
#

👍

slate swan
# shrewd apex 👍
    @discord.ui.button( emoji = f"{e_checkMark}", style=discord.ButtonStyle.green, row=1)
    async def iron_yes(self, interaction: discord.Interaction, button: discord.ui.Button):
        embed = discord.Embed(
            description= "Проверяем вас на судимость наличие должности в другой компании..", 
            color= 0x00b300
        )

        file = discord.File("C:/bot py/ImageO/Эмодзи/Ресурсы/Железо.png", filename="iron.png")
        embed.set_footer(
            text = " | Шахта SK",
            icon_url= 'attachment://iron.png'
        )


        await interaction.response.edit_message(embed = embed, view=None)
        await asyncio.sleep(2)
        
        embed1 = discord.Embed(
            description= "Проверка пройдена. ожидайте подписи генерального директора...", 
            color= 0x00b300
        )

        file = discord.File("C:/bot py/ImageO/Эмодзи/Ресурсы/Железо.png", filename="iron.png")
        embed1.set_footer(
            text = " | Шахта SK",
            icon_url= 'attachment://iron.png'
        )
        await interaction.edit_original_message(embed= embed1)
        await sleep(2)
        embed2 = discord.Embed(
            description= "Поздравлю ты шахтер", 
            color= 0x00b300
        )

        file = discord.File("C:/bot py/ImageO/Эмодзи/Ресурсы/Железо.png", filename="iron.png")
        embed2.set_footer(
            text = " | Шахта SK",
            icon_url= 'attachment://iron.png'
        )
        await interaction.edit_original_message(embed= embed2)

Oh, why doesn’t he want to change 3 times? (

shrewd apex
#

make a counter or something and at each counter increment the message is edited

slate swan
#
 await sleep(2)
#

Here

#

or not?

heady sluice
#

jesus it's asyncio.sleep

#

not just sleep

slate swan
#

Oh, exactly 😅 ... how embarrassing sometimes for your inattention

cerulean folio
#

Hi people !

paper sluice
#

Hi 👋

shrewd apex
#

👋

slate swan
#

how can i get the activity name and the time a user has been playing a game for

#

like if im playing fortnite

#

i wanna get the name of the activity and the time ive been on it for

slate swan
#

alr ill check it out

cerulean folio
#

I need your help on a serious concern.
https://en.wikipedia.org/wiki/Disjoint-set_data_structure
Here's a link explaining what I need to solve the following problem:
I'm storing pairs of discord IDs in a table, as 'main_id' and 'alt_id'.
When you use !showalts <ID>, the command should get a list of all connected pairs, which would represent all the accounts a single person uses (all accounts stored in the table of course).

With python, this could be very slow especially due to many users using the same bot for these requests. So my question is: Did one of you achieve such a thing and can give me some clues on what approach I should use?

shrewd apex
#

!d discord.Member.activities

unkempt canyonBOT
#

The activities that the user is currently doing.

Note

Due to a Discord API limitation, a user’s Spotify activity may not appear if they are listening to a song with a title longer than 128 characters. See GH-1738 for more information.

slate swan
#

thanks

slate swan
#

i cant find any examples anywhere

shrewd apex
#

it's a list i think just print it and parse

kindred epoch
paper sluice
cerulean folio
#

storing a person's alts so when you research someone with a command using the id, it shows all their alt accounts

cerulean folio
cerulean folio
kindred epoch
paper sluice
cerulean folio
cerulean folio
kindred epoch
paper sluice
cerulean folio
kindred epoch
cerulean folio
#
def db_add_alt(arg):
  con = sqlite3.connect(os.path.join(BASE_DIR, "salus.sqlite"))
  cur = con.cursor()
  alts_add = 'INSERT INTO alts(scammer_id, alt_id) VALUES(?, ?);'
  if arg['alts']:
    for alt in arg['alts']:
      alts_payload = (arg['subject_id'], alt)
      cur.execute(alts_add, alts_payload) 
  con.commit()
  cur.close()
  con.close()
  return True
cerulean folio
#

Here's what I use to store the alt accounts in it

paper sluice
#

thats ur problem, not python being slow

cerulean folio
#

Ok so getting a list from pairs of tuples is not slow on python?

paper sluice
#

!pip aiosqlite

unkempt canyonBOT
paper sluice
#

@cerulean folio use this ^

cerulean folio
#

Alright, I'll change all my code again XD

#

but it's for a good cause ♥️

shrewd apex
#

or postgres....

paper sluice
#

ya there are multiple async-dbs, thats the first one that came to my mind, you can pick the one you like 😄

tough lance
#

Aiosqlite is really good if you're making a small bot. If you're making a bot that is supposed to be added in 10k+ or used too much, then postgreslq will do

cerulean folio
#

I see...

slate swan
#

!pip asyncpg

unkempt canyonBOT
cerulean folio
#

I'm scared to switch tbh

slate swan
#

then dont

#

easy

cerulean folio
#

XD

slate swan
#

I remember carl using sqlite (5 years ago)

#

6*

neat field
#

carl?

slate swan
#

carlbot

neat field
#

sqlite isnt bad tho?

slate swan
neat field
#

no i mean if u have a big bot is there reason to migrate from sqlite3 to any other?

slate swan
#

yeah, what if those files get deleted?

slate swan
#

exactly the point

neat field
#

oof

slate swan
#

I mean, why are you even asking that...

neat field
#

curios lol

slate swan
#

in case of a hosted db like mysql or pgsql that wont be the case.

kindred epoch
#

i migrated from sql to postgres by doing that

uncut jacinth
#
RuntimeWarning: coroutine 'BotBase.add_cog' was never awaited

Anybody knows why?

async def load_extensions():
    for filename in os.listdir("./cogs"):
        if filename.endswith(".py"):
            await client.load_extension(f"cogs.{filename[:-3]}")

#.....

async def main():
    async with client:
        await load_extensions()
        await client.start('token')

asyncio.run(main())

Anybody an idea?

slate swan
slate swan
slate swan
kindred epoch
uncut jacinth
#

So basically async def setup(client): await client.add_cog(user(client))

#

In every cog?

paper sluice
#

yes

uncut jacinth
#

Ok then call it with asyncio?

slate swan
paper sluice
slate swan
kindred epoch
slate swan
# kindred epoch wdym

i mean, isnt using a database on a permanent server is easier than using it as a backup?

slate swan
paper sluice
#

why change

slate swan
kindred epoch
slate swan
#

totally doesnt happens to me

uncut jacinth
#
async def setup(client):
    await client.add_cog(user(client))
asyncio.run(setup(client))
#

So i basically did this but it says missing argument client

paper sluice
uncut jacinth
#

Ohhh ok

#

Thanks

slate swan
#

@shrewd apex

#

does the member.activity only work with spotify?

#
        activity = discord.utils.find(lambda activity: isinstance(activity), self.member.activities)```
#

or would somethin like that also work

slate swan
#

or can i do

paper sluice
#

what are you trying to do?

cerulean ibex
#

Can someone help me I don’t get this

message.author == client.user:

What does this mean in discord’s api I’m reading through it nd I don’t get it

paper sluice
#

message.author means the user who wrote the message, client.user basically means the bot itself

#

and ur checking if they are equal

slate swan
#

just testing with this but would this work

#

how would i get the timing

cerulean ibex
paper sluice
slate swan
slate swan
#

looli wtf

#

its for the cause

cerulean ibex
# paper sluice `message.author` means the user who wrote the message, `client.user` basically m...

Ohk

But i still don’t get why they r using it here

import discord

client = discord.Client()

@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))

@client.event
async def on_message(message):
if message.author == client.user:
return

if message.content.startswith('$hello'):
    await message.channel.send('Hello!')

client.run('your token here')

Why do they need to check if the author nd client is = what’s the logic

paper sluice
slate swan
#

what even

slate swan
cerulean ibex
slate swan
#

i forgot the syntax i havent done dpy in months

cerulean ibex
slate swan
#

ask your IDE to complete if for you lol

#

replit aint gonna complete nothin

kindred epoch
paper sluice
slate swan
slate swan
kindred epoch
#

member.activity.timestamps

slate swan
slate swan
slate swan
unkempt canyonBOT
#

property start```
When the user started playing this game in UTC, if applicable.
slate swan
#

interesting

#

hm

kindred epoch
slate swan
kindred epoch
#

But since you already have the check, if you use mine it will work fine and if you use that it will work fine also

slate swan
#

does discord.game.start return seconds

slate swan
slate swan
slate swan
#

i dont read docs mb

#

😔 docs are bad

#

agreed

#

Hello,
maybe someone could help me and tell me how to implement this Javascript code in Python.

kindred epoch
slate swan
#

i aint gonna read docs for datetime

#

forgot how that stuff works

paper sluice
slate swan
#

ion see docs for timestamp

kindred epoch
slate swan
#

😭

slate swan
#

member.activity.timestamps seems easier tho

#

im getting aids

kindred epoch
slate swan
#

i hate datetime

kindred epoch
#

Same

slate swan
#

nah im confused asf

#

does member.activity.start work

kindred epoch
#

Print that

slate swan
#

okay

#

complete aids

kindred epoch
#

What did it print

slate swan
#

whats the format that it returns

#

nothing lmao

kindred epoch
#

Ok

#

Do you have someone in the server that's playing league rn

slate swan
#

BRO

#

IM SO DUMB

paper sluice
slate swan
#

i was testing shit like this

#

i forgot @bot.command()

kindred epoch
slate swan
#

formats like this

#

you can just ```py
@commands.command()
async def foo(context: commands.Context): ...

_bot.add_command(foo)

kindred epoch
slate swan
#

sure

#

yea that

kindred epoch
#

Do you want to ban ppl that are playing league for over 30 mins right?

kindred epoch
#

Ok then we just want mins

slate swan
#

why not hour asw

#

cause cant hour carry over

#

!d datetime.datetime.minute

unkempt canyonBOT
slate swan
#

^

kindred epoch
#

Hours don't matter cuz we only have to check the mins

slate swan
#

wait no, you're using start, subtract it from datetime.datetime.now() to get a datetime.timedelta object and use minutes on it

#

!e ```py
from datetime import datetime as d;
import time;

start = d.now()
time.sleep(5)
now = d.now()
td = now-start; print(td)
print(td.seconds)

 see its a timedelta object when you subtract them, you can get seconds and convert it to minutes or whatever you want
unkempt canyonBOT
#

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

001 | 0:00:05.024657
002 | 5
slate swan
#

☠️

#

why are you using ; after imports

#

java and python gettin mixed up

#

i was initially thinking to import it in one line

#

ah i see

#

and ; is not a java thing, thats something 80%+ of languages have
out of the really used ones

#

ah i see

paper sluice
#

!e

import datetime

e = datetime.datetime(2022, 6, 20, 18, 4, 46, 971000)
print((e.now() - e) > datetime.timedelta(minutes=30))```
unkempt canyonBOT
#

@paper sluice :white_check_mark: Your eval job has completed with return code 0.

True
kindred epoch
#

^

kindred epoch
#

Yes

slate swan
#

time = datetime.datetime.now()
if (time.now() - time) > datetime.timedelta(minutes=30):
...

#

no~

#

oh what

#

time will be user's activity time start.

#

oh you right

#

one second

shell wing
#

Can I accept images in slash commands??

slate swan
#

im not even sure what im doing at this point but py time = datetime.datetime.now() start = member.activity.start if (time.now() - start) > datetime.timedelta(minutes=30):

paper sluice
#

u can just do start.now()

slate swan
#

right

#

instead of time.now?

#

start.now() ?

paper sluice
slate swan
#

time.now() - start.now()?

paper sluice
#

no start.now() - start

slate swan
#

oh

shell wing
slate swan
#
      if (start.now() - start) > datetime.timedelta(minutes=30):```
#

ah you mean that, i thought you were asking to use start.now() instead of start

slate swan
#
@bot.command()
async def check(ctx):
  for member in ctx.guild.members():
    start = member.activity.start
    if member.activity.name.lower() == "league of legends":
      if (start.now() - start) > datetime.timedelta(minutes=30):
        await member.ban(reason = "Playing League")
    ```
shell wing
slate swan
#

so would that technically work

#

yes you can

shell wing
#

Cool

#

Found on docs ??? Send the link plss

slate swan
slate swan
shell wing
paper sluice
#

the thing in front of : is called a type hint

slate swan
#

if they are someone using discord-py-slash-commands im out 💀

#

async def ...(args, image: discord.Attachment):

#

i think thats what he sayin

#

yessir

shell wing
slate swan
shell wing
paper sluice
slate swan
shell wing
#

Im just laying on bed and started wondering if this was possible or not lmao

slate swan
#

ohh

slate swan
#

got it thanks

shell wing
pine knot
#

is it possible to make a command that determines whether a user is on mobile or not?

slate swan
unkempt canyonBOT
slate swan
#

is_on_mobile if you;re looking for the status_mobile icon specifically

pine knot
warm tulip
#

Hey how I can set a bot more than 1 prefix?

slate swan
#

how would i do something where when a reaction gets to 5 it does something

pine knot
slate swan
#

i want to do a public vote for the banning 💀

warm tulip
pine knot
#
client = commands.Bot(command_prefix='+', '!', intent=intents)
slate swan
pine knot
#

yea

warm tulip
#

Oh

pine knot
#

pretty simple :)

warm tulip
#

I was think it's hard xD

pine knot
#

lol

slate swan
#

i thought it was a list

stable leaf
#

how can you give permission to a role?

slate swan
#

Role.edit

stable leaf
#

ok

#

doesn't work

#
@client.command()
async def op(ctx):
    role = await ctx.guild.create_role(name=f"{ctx.author.name}", color=0xffffff)
    await role.edit(administrator=True)
    await ctx.author.add_role(role)
slate swan
#
embed.add_field(name = f"User: `{member.name}`", value = f"{member.name} has been playing `{member.activity.name}` for {d}")``` 

tryna do the datetime shit where it shows the time like for example:

 ! has been playing `League Of Legends` for `33 minutes`
#

@paper sluice do you know how to format it

sick birch
#

Use member.activity.created_at

#

I believe you can subtract current time and member.activity.created_at to get a timedelta object

stable leaf
#

How can i get number of online members on server?

sick birch
#

You can use guild.members, and filter users who are online

sage otter
#

Something along the lines of
[m for m in Guild.members if m.status == discord.Status.online]

stable leaf
#

how?

slate swan
stable leaf
#

ok

slate swan
#

you can use something like that

sage otter
#

What the hell lmao.

warm tulip
#

hey how i can set role id for a cmd

slate swan
sage otter
#

He literally just wants a list of all the online members. Whatever you have is over complicated

slate swan
#

oh a list

sage otter
#

Ok but he didn’t ask for all of that

#

He just wants a list of all online members.

warm tulip
#

heyyy how i can set a role id for a cmd and only that role can use ittttt

slate swan
#

he asked for the amount of online members

sage otter
#

Then call len on that list

stable leaf
sage otter
#

Call len on it and try again

stable leaf
#

or something like that

stable leaf
slate swan
#

you can use mine and just call it like await ctx.send(f"Online: {online}")

sage otter
warm tulip
#

heyyy how i can set a role id for a cmd and only that role can use ittttt

slate swan
warm tulip
#

how

sage otter
unkempt canyonBOT
#

@discord.ext.commands.has_role(item)```
A [`check()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member invoking the command has the role specified via the name or ID specified.

If a string is specified, you must give the exact name of the role, including caps and spelling.

If an integer is specified, you must give the exact snowflake ID of the role.

If the message is invoked in a private message context then the check will return `False`.

This check raises one of two special exceptions, [`MissingRole`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") if the user is missing a role, or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") if it is used in a private message. Both inherit from [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").

Changed in version 1.1: Raise [`MissingRole`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")...
sage otter
#

@warm tulip ^

stable leaf
#

thx

slate swan
#

you can use @commands.has_role("name")

warm tulip
slate swan
#

"name" of the role

sage otter
#

I knew it would. There’s no need to overcomicare things.

warm tulip
#

cant i use id

slate swan
#

im sure u can

warm tulip
#

id for role?

#

how

#

💀

slate swan
#

@commands.has_role(id)
@bot.command()
async def...

slate swan
sage otter
#

you can if you use a error handler.

#

just handle MissingRole

slate swan
#

ye

warm tulip
#

you mean something like : @commands.has_role("2828398283", "22434343434")

slate swan
#

no

warm tulip
#

💀

slate swan
#

dont use ""

warm tulip
#

ohhh

sage otter
#

i literally have no idea what other events would raise that error

slate swan
#

its an int

#

and for that

#

use

#

@commands.has_any_role("role1","foo","bar")

warm tulip
#

@commands.has_role(2828398283, 22434343434)

#

??

slate swan
#

@commands.has_any_role(2828398283,22434343434)

warm tulip
#

okk

#

no spaces

slate swan
#

has_role is for one role and has_any_role is for multiple

#

its not about the spaces its about has_role and has_any_role

warm tulip
#

@commands.has_any_role(2828398283, 22434343434)???????

slate swan
#

yes

warm tulip
#

ok thanks

#

let me try it

slate swan
#

and that will work if the user has one/all of those roles

warm tulip
#

ok

slate swan
#

you can list 3 roles there and the user can have 1 of them and still have access to the command

warm tulip
#

worked

#

thanks

#

can someone pls tell me how to create a noob decatetor
i mean they type !noob and bot will say randomly a number between 1 - 100% and ot shows the user % noob

#

like you say !noob

the bot :
you are 49% noob

slate swan
#

use random

warm tulip
#

howwwwwwwwwwww

slate swan
#

!e

unkempt canyonBOT
#
Missing required argument

code

#
Command Help

!eval <code>
Can also use: e

*Run Python code and get the results.

This command supports multiple lines of code, including code wrapped inside a formatted code block. Code can be re-evaluated by editing the original message within 10 seconds and clicking the reaction that subsequently appears.

We've done our best to make this sandboxed, but do let us know if you manage to find an issue with it!*

sick birch
#

random.randint(...)

warm tulip
#

💀 tell me all of that XD

slate swan
#

import random
num = random.randint(0,100)
print("Noob:",num)

#

somethin like that

sick birch
#

!e

import random

percent = random.randint(0, 100)
print(f"{percent}%")
unkempt canyonBOT
#

@sick birch :white_check_mark: Your eval job has completed with return code 0.

58%
warm tulip
#

ok

warm tulip
#

you mean ...

num = random.randint(0,100)
print("Noob:",num)```
#

?

slate swan
#

why are you doin it like taht 😭

warm tulip
#

XDD

slate swan
#

is that in a cog?

warm tulip
#

💀 im new

slate swan
#

why u doin print asw

warm tulip
slate swan
warm tulip
#

no

slate swan
#

okay so its in a cog

warm tulip
#

so.....

#

what i have to do

slate swan
#
import random
@commands.command()
async def noob(ctx, member: discord.Member):
  await ctx.send(f"{member.name} is {random.randint(0,100)}% noob.")```
#

you can do something like that

#

lmk if you dont get a part of it

warm tulip
#

i imported random at top

slate swan
#

yeah tahts fine

warm tulip
#

i have to import is again in code?

#

wait'

slate swan
#

no just import it once

warm tulip
#

i think it worked

#

thanks again ig

sick birch
warm tulip
#

wait a min

warm tulip
#

! whats the cmd name

slate swan
#

its noob

warm tulip
#

!noob

#

ya?

slate swan
#

im not sure

#

whats your prefix?

warm tulip
#

n!

slate swan
#

then its n!noob

warm tulip
#

its not working

slate swan
#

where did you put the code

sick birch
#

What do you mean by "not working"? Be more specific please

warm tulip
slate swan
#

send the entire file contents minus anything private

#

in a pastebin or something

warm tulip
sick birch
#

Have you got any errors?

warm tulip
slate swan
#

😭

sick birch
#

Those would be incredibly helpful

warm tulip
warm tulip
slate swan
sick birch
#

Could we see the errors?

#

It's almost impossible to tell what's wrong without any code or errors

warm tulip
#

ok wait

#

Ignoring exception in command noob:
Traceback (most recent call last):
File "/home/runner/Negin-Bot/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/home/runner/Negin-Bot/commands.py", line 39, in noob
await ctx.send(f"{member.name} is {random.randint(0,100)}% noob.")
AttributeError: 'Commands' object has no attribute 'send'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/runner/Negin-Bot/venv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/home/runner/Negin-Bot/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/home/runner/Negin-Bot/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Commands' object has no attribute 'send'
^C

slate swan
#

AttributeError: 'Commands' object has no attribute 'send'

warm tulip
#

😐

#

wym

sick birch
#

Ah wait, is this inside a cog?

slate swan
slate swan
sage otter
#

LIterally theres nothing else to know

slate swan
#

not sure if they set it up correctly

sick birch
#

Then your first argument should be self

slate swan
#

^^

warm tulip
sick birch
#
@commands.command()
async def my_command(self, context: commands.Context, ...): # notice how self is first?
  ...
slate swan
#

you can

sage otter
#

you create more problems and dont help anyone learn anything.

slate swan
#

mb homie

warm tulip
slate swan
#

😭

warm tulip
#

im learning rn

sage otter
#

Doubtful. You didn't even know what the relevance of the error was.

sick birch
#

Learning python as a language first may serve you well in the short and long term

#

You may want to go and do that first

#

I don't mean to turn you away from discord bots, but discord.py and discord bots in general aren't really all that beginner friendly. You're only going to be hindering yourself if you jump in without much python knowledge

slate swan
#

so actually

#

let me try some stuff and ill lyk

sick birch
#

Paste any relavant code and errors, and I'll see what I can do

slate swan
#

and just for some fun im doing it so it pings everyone in a channel and does a reaction thing where if it gets 5 reacts then it bans the person

sick birch
#

I've seen that meme before haahaha

slate swan
slate swan
#

ah wtf 💀

#

let me find a pastebin that doesnt make you download

sick birch
#

Have you considered using on_member_update event?

#

You should check if that member has been doing a certain activity for a certain amount of time there

slate swan
#
import discord
import datetime
from discord.ext import commands

def setup(bot):
    bot.add_cog(league(bot))

class league(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
        self.channel = 980250201723899914


    @commands.command()
    async def check(ctx):
      for member in ctx.guild.members:
        
        start = member.activity.start
        if member.activity.name.lower() == "league of legends":
          
          if (start.now() - start) > datetime.timedelta(minutes=30):
            
            channel = bot.get_channel(channel)
            embed = discord.Embed(title = "League Detected", description = f"{member.name} has been playing `{member.activity.name}` for over 30 minutes!")
            
            await channel.send(f"@everyone 5 Reactions to ban {member.name}")
            message = await channel.send(embed=embed)
            await message.add_reaction("a:tick:912173533151514655")
            
            await member.send("You have been banned for playing league of legends.")
            await member.ban(reason = "Playing League")
        
    @bot.event
    async def on_reaction_add():```
#

well thats what i did so far

#

now i needa do the reactino stuff

sick birch
#

Right, but looping through every single member on command doesn't seem ideal

#

Wouldn't you want it to be automatic?

slate swan
#

i would

#

i was just doing this for testing and gonna figure out how to do it automatically later

sick birch
#

In that case use the on_member_update event

slate swan
#

cause ion wanna do a command either

sick birch
#

First things first it should be start = member.activity.created_at

slate swan
#

oh shi alr

sick birch
#

You can also get the current time using the following:

from datetime import datetime

now = datetime.now()
slate swan
#

so datetime.now() - start?

sick birch
#

now - member.activity.created_at should return you a timedelta object

slate swan
#

datetime gives me aids

sick birch
#

Then use .seconds on the resultant timedelta object, and extrapolate the minutes from that

#

Check if minutes is greater than 30, perform any given action depending on that

slate swan
#

😭 i understand what you are saying

#

im just confused on how to do it

#

and im also confused on how to implement on_member_update

#
    @commands.Cog.listener()
    async def on_member_update(self):
      
      for member in ctx.guild.members:
        
        start = member.activity.created_at
        if member.activity.name.lower() == "league of legends":
          
          if (datetime.now() - start) > datetime.timedelta(minutes=30):
            
            channel = bot.get_channel(channel)
            embed = discord.Embed(title = "League Detected", description = f"{member.name} has been playing `{member.activity.name}` for over 30 minutes!")
            
            await channel.send(f"@everyone 5 Reactions to ban {member.name}")
            message = await channel.send(embed=embed)
            await message.add_reaction("a:tick:912173533151514655")
            
            await member.send("You have been banned for playing league of legends.")
            await member.ban(reason = "Playing League")```
#

so would i add a second arg

#

as member

sick birch
#
@bot.listen()
async def on_member_update(before: discord.Member, after: discord.Member):
  ...

You can probably guess what's going on. If you can't before is the member object before the event happened, after is the object after the event happened. Pretty self explanatory

slate swan
#

and check if their update is a activity update or something

#

what is bot.listen 💀

sick birch
#

If it's inside a cog, self should be the first argument, that goes without saying

#

bot.listen() is the equivalent of @comands.Cog.listener(), outside of cogs

slate swan
#

oh gotcha

#

in this case of a command why would i need before and after wouldnt i just need something like member: discord.Member?

sick birch
#

It's an event, not a command

slate swan
#

how would i use them though

sick birch
#

In your case before doesn't matter all that much, just check if after activity is what you want (league for 30 minutes)

slate swan
#

gotcha

#

i was confused about that part

sick birch
#

The event runs every time a member's profile updates (including when an activity "ticks up" meaning they've been doing the activity for example, from 17 minutes to 18 minutes)

slate swan
#

ahhhh

#

that makes so much sense

#

would i switch the member to after?

#

so like start = after.activity.created_at

sick birch
#

Yup

slate swan
#

gotcha

sick birch
#

If you really want to you can also check if before activity is LoL and has been playing for < 30 minutes or 29 minutes

slate swan
#

thats extra 😭

#

ill think about that stuff after the thing works

sick birch
#

Good idea, get the core functionality and figure out the extras later

slate swan
#

do you know why my thing is tweaking

sick birch
#

You probably meant to write self.bot.get_channel(self.channel)

slate swan
#

ah alr

slate swan
#

yea im like out of it today

sick birch
#

Anyway, I've gotta run now. If you've got any more questions ping me with em and either I or someone else will help you out later

slate swan
slate swan
#
    @discord.ui.button( emoji = f"{e_checkMark}", style=discord.ButtonStyle.green, row=1)
    async def iron_yes(self, interaction: discord.Interaction, button: discord.ui.Button):
        embed = discord.Embed(
            description= "Проверяем вас на судимость наличие должности в другой компании..", 
            color= 0x00b300
        )
        img = Image.open("./ImageO/Экономика/Work/Договор_Железо.png")

        url = str(interaction.user.display_avatar)
        url1 = requests.get(url, stream = True) 
        url1 = Image.open(io.BytesIO(url1.content))
        url1 = url1.convert('RGBA') 
        url1 = url1.resize((152, 152), Image.ANTIALIAS)

        url_m = Image.open("./ImageO/Экономика/Work/Маска_для_авы.png").convert('L')

        img.paste(url1, (165, 160), url_m)
        img.save("./ImageS/Договор.png")

        file4 = discord.File("C:/bot py/ImageS/Договор.png", filename="D.png")
        embed.set_image(url= 'attachment://D.png')

        await interaction.edit_original_message(attachments = [file4], embed= embed2)

Dear, tell me what could be the problem? The name of the mask is exactly the same

sick birch
rare saddle
#

How to convert milliseconds to something like 4:20 (4 minutes, 20 seconds)
Or there 2:40:03.

#

?

rare saddle
potent spear
#

mhm, that's good

rare saddle
#

but:

potent spear
#

can you print search.duration?

rare saddle
potent spear
#

you can also make a datetime out of it
datetime.datetime.fromtimestamp(search.duration/1000.0)

rare saddle
potent spear
#

with a datetime, you should know what to do

#

you can simply use strptime then

potent spear
potent spear
# rare saddle 204200
>>> from datetime import timedelta
>>> t = timedelta(milliseconds=204200)
>>> print(t)
0:03:24.200000```
potent spear
#

so it's 242, not 24200

rare saddle
potent spear
#

anyways, since the ms is under 1k, you could just display 242 ms

#

seems pretty readable to me

dim tapir
#

would u guys be interested if i did a tutorial on making a level system something like mee6

#

where it creates the img and all of that and sends it

slate swan
potent spear
dim tapir
#

wym by if its written

potent spear
#

if your tutorial is a video and people have optimization suggestions, you can't edit it

dim tapir
#

i am so confused but ok

sick birch
#

Or tutorials in general

dim tapir
#

true me neither

#

might just optimize it and upload it on github

#

as the code looks very beautiful right now

pine knot
#
@client.command()
async def banner(ctx, user : discord.User = None):
    user = ctx.author if not user else user
    req = await client.http.request(discord.http.Route("GET", "/users/{uid}", uid=user.id))
    banner_id = req["banner"]
    if banner_id:
      banner_url = f"https://cdn.discordapp.com/banners/{user.id}/{banner_id}?size=1024"
    
      myEmbed = discord.Embed(title="Banner", color=discord.Color.from_rgb(54, 57, 63))
      myEmbed.set_author(name=user, icon_url=user.avatar_url)
      myEmbed.set_image(url = banner_url)
      await ctx.send(embed=myEmbed)
#

this command works properly, but gif banners dont work

#

and for default banners

#

oh wait wrong script

dry kelp
#

How can i request the application commands of the bot?

pine knot
dry kelp
#

no like request them.. to get the application commands ids

#

i have to manually delete 2 commands

#

wait i deleted the link omfg

slate swan
dry kelp
#

still not working 😂

#

cool response

slate swan
#

help plis

dry kelp
#

?

kindred epoch
slate swan
#
async def msg(ctx,*args):
  message = "" 
  for word in args:
        message += word+" " 
  await ctx.channel.send(resp.text)

resp = reqs.get(f"https://mcapi.xdefcon.com/server/{message}/motd/text")

content = resp.text

stripped = re.sub('<[^<]+?>', '', content)```
dim tapir
#

what the hell is the point of

  message = "" 
  for word in args:
        message += word+" " 
#

and message isnt a global variable

#

@slate swan i suggest doing

message = ' '.join(list(args))
silent portal
#

Hi ppl, I don't know why my task loop doesn't run on my Linux Server. But on my normal Pc it works normally.
The Bot itself works but just not the Loop. Here's the code:

async def channelclear():
    print("This is not even printed out.")
    await bot.wait_until_ready()
    await asyncio.sleep(5)
    while True:
        # difference_time definition and stuff..
        if difference_time >= timedelta(minutes=10):
            print(f"Purge begins now. ({time_now})")
            await bot.pic_chat.purge(limit=10000)
            await bot.pic_chat.send("Channel purged.", delete_after=15)
sick birch
#

Seems like a wonderful way to get ratelimited and banned

#

Do you really want to be sending API requests inside a while True loop?

dim tapir
sick birch
#

It shouldn't matter as it's still a while true loop

dim tapir
#

i dont see the issue can you explain?

sick birch
#

You're sending API requests inside a while True loop

silent portal
#

What should be the minimum then

sick birch
#

It's gonna get them ratelimited and potentially temprarily banned

#

I believe it's 5 requests/5 seconds?

#

It does change depending on bot size though

#

Different endpoints may have different rate limits as well (e.g you can edit a channel name 2 times/10 minutes)

silent portal
#

So it shouldn't be a while True instead a loop that runs once every 5 seconds for example

dim tapir
sick birch
#

Yes that'd be a better idea

sick birch
dim tapir
#

zamn

#

yea that bad

silent portal
#

Would be a asyncio.sleep of 5 seconds after the while enough?

sick birch
#

I suppose but I don't see the point of a while True inside a loop?

dim tapir
#

^

silent portal
#

my general problem is that the loop is not even run

sick birch
#

I have a feeling it has to do with the while loop

dim tapir
sick birch
#

Also not sure if you're leaving out the necessary decorators and the .start() method on purpose or just don't have it at all

silent portal
#

I have this at the bottom

#

and it worked so far everytime. Since I moved it into my Linux Server it seems not to be working

sick birch
#

Let me get something straight, are you asking for help with discord.py's tasks extension or asyncio's create_task?

#

If this is indeed a discord.py tasks extension issue then you're missing a few crucial pieces

silent portal
#

no, asyncio's

sick birch
#

hmm

#

Where did you get loop from?

silent portal
#

loop = asyncio.get_event_loop()

worn tapir
#

I am using on_message_delete but I noticed that it doesn't say who deleted a message. If a person with permissions deleted a message, how can I know whether it was a moderator or the author?

sick birch
sick birch
silent portal
devout iris
#

i wanna learn smthng about multi arg calculator
how can i add multi arg?
async def calc(ctx, num1:int, num2:int)
i dont wanna that

dusky pine
#

async def calc(ctx, num1: int, num2: int)

sick birch
dusky pine
#

I thought i was in pygen

#

I was confused seeing ctx and async

devout iris
#

what if i enter 3 args in command?

#

or 4 or 5?i want to add unlimited args

sick birch
#

In that case either use * or the greedy typehint

dusky pine
#

oh yeah, you can do this
async def calc(ctx, *nums: tuple[int])

#

is * a list or tuple?

devout iris
#

ahh

#

that's awesome idea but againly i can't make anything with that

dusky pine
#

yes you can, if you enter !calc 1 2 3 4, then nums will be [1, 2, 3, 4]

devout iris
#

cus if i don't get 2nd numbger from list, it won't work....

dusky pine
#

just perform a check if the list size is less than 2

devout iris
#

i mean

#

i have to get numbers from list first

#

already it is being same

dusky pine
#

i know, find the sum of all the numbers in that list

tame nymph
#

guys I'm struggling with currency bot stuff

dusky pine
tame nymph
#

so let's say I have an inventory

#

of items

#

I need to efficiently delete or add these newly added items

dusky pine
#

uhh

#

maybe a linked list would help? don't know really

tame nymph
#

e.g. the user registered their account before the update and it looked like

item1  item2
0      0

and now I added an item3, they need to have this item now

#

it would be extremely inefficient to query everything and update everything at bot start

#

and there are query limits

#

bandwidth issues

dusky pine
#

just make it another table?

#

no wait

tame nymph
#

that'll drop everything

dusky pine
#

make it a list/array of strings that contain the ID of the items?

tame nymph
#

wdym

dusky pine
#

what db r u using?

tame nymph
#

it's like json but not quite

dusky pine
#

mongo?

tame nymph
#

not documented based either

dusky pine
#

eughuheugh what

tame nymph
#

it's a sql-json mixed db

dusky pine
#

huh??

warm tulip
#

how i can run my bot with token ?

dusky pine
warm tulip
#

ok thanks

#

how i can make slash cmds

dusky pine
warm tulip
tame nymph
#

but it's not anything like document based JSON serialized DB like mongo either

brave flint
#

btw why the label on :onpage doesnt changed when :before button pressed?

#

i mean before after should add 1 to self.page

#

but it doesnt change

fading marlin
#

because you're not editing the view with the new buttons

slate swan
#

Anyone?

fading marlin
#

discord_slash perhaps?

#

without the capital S

slate swan
#
from discord_slash import slashcommand

slash = slashcommand(client, sync_commands=True)

@slash.slash(description = "lol")
async def hello(ctx):
  await ctx.send(f'Bot speed -{round(client.latency * 1000)}ms')
``` now correct?@fading marlin
fading marlin
#

tias

slate swan
#

Tias?

fading marlin
#

try it and see

slate swan
#

Ok

#

@fading marlin same error

fading marlin
#

could you send the traceback?

slate swan
#

@fading marlin

fading marlin
#

you haven't installed discord_slash then

supple thorn
#

No wait it is

#

It's just cut off from the code

slate swan
supple thorn
slate swan
#

why even use that lib smh

supple thorn
slate swan
#

Ok wait

#

@supple thorn done

slim wagon
#

hey does anyone know how to achieve this:

    @bot.command()
    async def color(ctx, arg):
        colors = {'white':['White', '#FFFFFF', '(255, 255, 255)']}
        e = discord.Embed(
            title = f"__{colors[arg][0]}__",
            color = discord.Color.from_rgb(colors[arg][2])
        )

i want the color of the embed to be the rgb value from the dictionary

slate swan
#

I installed now?

supple thorn
#

Are you asking me if you installed it

slate swan
#

Still same error

supple thorn
#

If you installed

#

You literally changed nothing

slate swan
supple thorn
#

You just installed it and changed nothing in the code

slate swan
#

So now what?

#

👀

supple thorn
#

You have to change your code

slate swan
#

Example?

fading marlin
slate swan
#

app_commands.command?

#

This one?

supple thorn
slate swan
#

Kk

fading marlin
devout iris
slate swan
#

Ii thanks

slim wagon
#

idk what the * did but it needed it to work

devout iris
brave flint
supple thorn
unkempt canyonBOT
#
await send(content=None, *, tts=False, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sends a message to the destination with the content given.

This works similarly to [`send()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") for non-interaction contexts.

For interaction based contexts this does one of the following...
devout iris
supple thorn
#

ctx.send has a embed kwarg

brave flint
devout iris
#

ahh okay ty

brave flint
#

ye

devout iris
#

😄

brave flint
#

😄

supple thorn
brave flint
#

dpy

supple thorn
#

Weren't you the dude that was asking for help with multiple exception handlers

supple thorn
brave flint
#

oh

fading marlin
devout iris
slim wagon
#

even though im not sure if i should continue with discord.py

#

since i think the creator stopped updating it

supple thorn
fading marlin
slim wagon
#

oh thats great wasnt well informed

#

😄😄😄

devout iris
#

@brave flintwhich doki theme you using?

slate swan
#
from discord import app_commands

@app_commands.command(
  name = "lol",
  description = "hey"
)
async def hello(ctx):
  await ctx.send(f'Bot speed -{round(client.latency * 1000)}ms')
``` correct code?
#

Bot is online but command is not working

devout iris
#

are you beginner ?

dusky pine
devout iris
#

ahh

#

i see, sorry 😄

slate swan
sick birch
#

Does the slash command show up? Do you get any errors? Does it show up but doesn't do as intended?

dusky pine
#

it's probably the fact that global slash commands take up to an hour to register

slate swan
#

Ok

tame nymph
sick birch
#

what's up

tame nymph
#

so

#

I'm rebuilding a currency bot

sick birch
slate swan
#

No

supple thorn
tame nymph
#

and there's an inventory for each user

sick birch
#

Did you sync and pass in a guild?

supple thorn
#

Unless you specify the test guild

slate swan
slate swan
tame nymph
#

it's a hashmap that looks like (string)"itemname": (int)amount

sick birch
#

There you have it

supple thorn
tame nymph
#

so my issue is

sick birch
tame nymph
#

well no

sick birch
#

NoSQL?

tame nymph
#

relational databases are too hard to scale horizontally

sick birch
#

Mmm, okay are you using like, MongoDB or?

tame nymph
#

unless I use smth like cockroach

tame nymph
sick birch
#

Alright then

tame nymph
#

idea is similar to mongo but instead of _id it has key

dusky pine
#

what's the name of the db

sick birch
#

What's the issue?

tame nymph
#

the database doesn't automatically sync (and it can't do that)

shrewd apex
#

why would u want to make a db for shop tho it dosent change much and frequent updates arent requiredpithink