#discord-bots

1 messages Β· Page 1087 of 1

maiden fable
#

Nice, nitro

pearl fjord
maiden fable
slate swan
#

did you pass it in the bot class?

slate swan
slate swan
maiden fable
#

I never bought it

#

Too expensive

slate swan
#

7+ times

#

oh lol Nice

maiden fable
#

I have also got nitro like 4-5 times, everytime it was a gift

slate swan
#

Lucky

maiden fable
#

Indeed

slate swan
#

fix?

heavy folio
#

show full code

slate swan
#

@bot.command()
async def daykey(ctx, amount):

    await asyncio.sleep(1)
    await ctx.send(f"i worked")
#

@heavy folio

#

is that after bot.run()

heavy folio
#

or did you make 2 clients

#

show the full file please

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.

spring flax
#

i have this func ```py
def convert_to_stars(overall):
ratings = []
stars = {1 : "full" , 0.75 : "three quater " , 0.5 : "half" , 0.25 : "quater"}

for star in stars:
    n = int(overall//star)
    ratings.extend([stars[star]] * n)
    overall -= star * n

return ratings
And based on the outcome of the func, I want it to send emojis from these:

FULL_STAR = bot.get_emoji(982990723660005436)
HALF_STAR = bot.get_emoji(982991530442784798)
THREE_QUARTER_STAR = bot.get_emoji(982991395595890758)
QUARTER_STAR = bot.get_emoji(982991561161838632)

#

this is what the func returns

maiden fable
#

What's the issue?

slate swan
#

!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.

slate swan
slate swan
#
class Select2(discord.ui.Select):
    def __init__(self):
        options=[
            discord.SelectOption(label="Deny",emoji=":cross8:",description="Choose to decline the donation"),
            discord.SelectOption(label="Hold",emoji=":load:",description="Choose to put the donation on hold"),
            discord.SelectOption(label="Accept",emoji=":tick:",description="Choose to accept the donation")
            ]
        self.add_item(options)
        super().__init__(placeholder="Choose an option here.",max_values=1,min_values=1,options=options)
    async def callback(self, interaction: discord.Interaction):
        if self.values[0] == "Deny":
            await interaction.response.send_message(f"Your donation has been denied by {interaction.user.mention}")
        elif self.values[0] == "Utility Commands":
            await interaction.response.send_message(f"Your donation has been put on hold by {interaction.user.mention}")
        elif self.values[0] == "Moderation Commands":
            await interaction.response.send_message(f"Your donation has been accepted by {interaction.user.mention}")
``` this?
#

not that, in ur view class

#

k

#
class SelectView1(discord.ui.View):
    def __init__(self, *, timeout = 180):
        self.add_item(Select2())
        super().__init__(timeout=timeout)
```?
#

yep try this

slate swan
fresh ferry
#

hey everyone, wanting to figure out if discord has a function that allows me to read a users custom activity messages im using it to Quarantine users who custom messages in there profile that have curse words or anything hurtful/racist/harmful to other users. anyone know of a way ?

vale wing
#

Yes I think there's an attribute

fresh ferry
#

was thinking of using the CustomActivity

@bot.command()
async def mycustomstatus(ctx):
    for s in ctx.author.activities:
        if isinstance(s, discord.CustomActivity):
            await ctx.send(s)
vale wing
#

I don't remember which one lemme check it out

fresh ferry
slate swan
vale wing
#

@fresh ferry so basically you are trying to get member's status text right?

fresh ferry
vale wing
#

Ok haven't ever worked with statuses lemme seek some info

slate swan
maiden fable
slate swan
slate swan
#

though it should be below

#

πŸ’€

#
class SelectView1(discord.ui.View):
    def __init__(self, *, timeout = 180):
        super().__init__(timeout=timeout)
        self.add_item(Select2())
slate swan
#

Yea

#

No errors

slate swan
#

hm k

fresh ferry
# vale wing Ok haven't ever worked with statuses lemme seek some info

thank you thank you, its sort of a problem iv been wanting to sort out as once said bot is made i want to release it on github, discord doesn't ban harmful words via the custom activity and i cant tell you some of the stuff iv come across... want a way to moderate these problems.

i however have a bot already coded up ready to be posted to github regarding the custom presences of a profile 'for example' β†’ user is playing call of duty | user changes name of call of duty to harmful/hateful word or words. β†’ my bot will then remove said users roles and give a Quarantine role where all other members will not see said Quarantined user so owner can further investigate the matter

vale wing
#

@fresh ferry ok yeah you were right, you just need to get CustomActivity activity and access its name attribute

#

I guess it will always be first activity in activities list

#

Also don't forget to enable presences intent on dev portal and in code

vale wing
crimson compass
#

How do i put β€œfooter” in my embed?

vale wing
#

!d discord.Embed.set_footer

unkempt canyonBOT
#

set_footer(*, text=None, icon_url=None)```
Sets the footer for the embed content.

This function returns the class instance to allow for fluent-style chaining.
crimson compass
#

Thank you

fresh ferry
# crimson compass How do i put β€œfooter” in my embed?

or you can use this

embed=discord.Embed(title="title", description="description", color=0xff0000)
embed.set_author(name="name", url="url", icon_url="icon")
embed.set_thumbnail(url="thumbnail")
embed.add_field(name="field", value="value", inline=False)
embed.set_footer(text="footer")
await ctx.send(embed=embed)
vale wing
#

set_footer that's it

fresh ferry
oak warren
#

nah you cant do that

#

only watching listening and playing is allowed

vale wing
#

Your way of reading status was correct

vale wing
oak warren
#

i k

#

i was talking about reading i dont think you can read it

vale wing
#

Well I just tested and read it

#

You can

slate swan
oak warren
#

oh well

vale wing
#
status = ctx.author.activities[0].name```
@fresh ferry seems like status activity will always be the first in this list but I am unsure of this
slate swan
#

i changed the emojis cause they won't work for me

vale wing
#

Or ctx.author.activity

slate swan
#

Hmmm

#

What could this be

fresh ferry
slate swan
#

do you by any chance have SelectView1 or Select2 defined again?

slate swan
fresh ferry
slate swan
fresh ferry
slate swan
# slate swan

tru adding a print statement in the view's and select'a init to see if the classes are initialised or not

#

hm k

slate swan
#

Added print at end of the class

#

Below self.add_item(Select2())

shrewd apex
slate swan
stiff fern
#

So I installed discord slash commands through pip but its not showing up in vscode I guess?

heavy folio
stiff fern
#

oh alright

heavy folio
#

and uninstall discord slash

stiff fern
slate swan
# slate swan

can you send the complete file? it will be easier to figure out the issue

#

πŸ’€

#

!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.

slate swan
#

ill dm the link

stable leaf
#

How to create role that will be displayed separately, have red color and will be at the top?

boreal ravine
#

Why do my slash commands not appear when I sync to a certain guild?

unkempt canyonBOT
#

await create_role(*, name=..., permissions=..., color=..., colour=..., hoist=..., display_icon=..., mentionable=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Creates a [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role") for the guild.

All fields are optional.

You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to do this.

Changed in version 1.6: Can now pass `int` to `colour` keyword-only parameter.

New in version 2.0: The `display_icon` keyword-only parameter was added...
heavy folio
maiden fable
#

hoist=True, color=discord.Color.red

boreal ravine
heavy folio
#

!d discord.app_commands.CommandTree.walk_commands

boreal ravine
stable leaf
boreal ravine
heavy folio
#

actually mb

#

this instead

unkempt canyonBOT
#

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

Fetches the application’s current commands.

If no guild is passed then global commands are fetched, otherwise the guild’s commands are fetched instead.

Note

This includes context menu commands.
stable leaf
paper sluice
#

is there something like setup_hooks in hikari/lightbulb or do i have to do it in the init dunder?

slate swan
#

use hikari.StartedEvent, its called only once in the complete runtime

paper sluice
#

ah ok

slate swan
#

( actually StartingEvent )

#

the startedevent is like on_ready which may get triggered multiple times if your bot reconnects to the gateway

stiff fern
paper sluice
slate swan
paper sluice
#

no

slate swan
#

use the init dunder then

paper sluice
#

aight

slate swan
#

subclassing BotApp/GatewayBot is better cuz they wont allow you to add custom attributes to them with the bot= lightbulb.BotApp(); bot.apple = "banana" method due to the presence of __slots__

paper sluice
#

ya i noticed that

slate swan
#

you can use bot.d.attribute tho d here is a dataclass ( added in lightbulb only )

paper sluice
#

ah k

#

this is nice, load_extensions_from ignores files starting with _ by default

slate swan
#

yeah, cause they are mostly __init__.py files

paper sluice
#

ya its good for me, i prefix files with _ if they are not finished

#

if there is like a syntax error or something in the one of the extensions, will it raise syntax error or what?

slate swan
#

yes, it should

paper sluice
#

hmm nice

pliant gulch
#

The one thing I will never understand, why does discord.py use so many generics

#

Like, commands.Bot is generic, iirc?

#

Cogs are generic, context is generic

#

There are probably more, I could look into it, but I'm too lazy

stiff fern
#

Do you think its better to make a new .py file for every command or to have files under a specific category and then have all commands relating to that category in a single file

paper sluice
stiff fern
#

thank ya

slate swan
stiff fern
#

How am I doing this wrong?

#

oh nvm

potent spear
slate swan
potent spear
unkempt canyonBOT
#

Hey @slate swan!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.

slate swan
#

new error

stiff fern
#

How would I get a bots activity

#

I know you can do change_presence but that just changes it?

stiff fern
#

I already solved that one ty tho

tacit token
#

sir!

heady sluice
heady sluice
stiff fern
#

ty

heady sluice
#

oe maybe bot.activity would work too

#

based on python

#

and that one for sure doesn't make an API call

stiff fern
#

yea

#

ill mess w/ it I just needed a guideline

slate swan
heady sluice
#

that sucks

#

ytdl or wavelink?

#

@slate swan

shrewd apex
frail flower
#

anyone have an idea on how to make a command that would message a member?

heady sluice
slate swan
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
shrewd apex
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.

The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.

To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/latest/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`File`](https://discordpy.readthedocs.io/en/latest/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.

To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`Embed`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
heady sluice
#

like I wouldn't know the rule

slate swan
heady sluice
#

nah Ashes I'm here everyday and you still think I'd help with a music bot

slate swan
#

Ashes

#

rude

heady sluice
#

one's Asher one's Ash

#

Ashes

shrewd apex
#

lmao

shrewd apex
heady sluice
#

doubt

#

spotify also doesn't like automatization

shrewd apex
#

welp idk abt that i am not exactly following tos anywaypithink

maiden fable
#

Downloading songs or doing stuff which isn't in the API docs isn't

heady sluice
#

you basically download songs when you play them in vc

maiden fable
#

Yup

#

They are being downloaded to the cache

heady sluice
#

from spotify

#

from spotify

#

internet?

#

bro I hate discording when I'm on my way

shrewd apex
#

my bad

heady sluice
#

...

unkempt canyonBOT
#

7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.

heady sluice
#

it is tho

slate swan
#

no

heady sluice
#

yes

#

also people are lacking asking for help

slate swan
#

Hello

heady sluice
#

hello

shrewd apex
#

welp its fine as long as i dont help others or show how to do the same

slate swan
#

I need the bot to write in the status looks for the "number" of servers

heady sluice
#

len(bot.guilds)

slate swan
#

what variable is responsible for the number of servers

shrewd apex
slate swan
#

Thanks

heady sluice
#

bot.guilds shows all guilds

#

len(bot.guilds) shows how long the list is

slate swan
#

Ok thanks

#

πŸ‘Œ

shrewd apex
heady sluice
heady sluice
#

but I doubt this

slate swan
shrewd apex
#

bot.members if i dont remember wrong

slate swan
#

Ok thanks 😊

heady sluice
#

!d discord.Client.users

unkempt canyonBOT
slate swan
#

!d discord.Client.get_all_members :)

unkempt canyonBOT
#

for ... in get_all_members()```
Returns a generator with every [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") the client can see.

This is equivalent to:

```py
for guild in client.guilds:
    for member in guild.members:
        yield member
slate swan
#

stop-

shrewd apex
heady sluice
slate swan
maiden fable
slate swan
#

it will have duplicate members too

maiden fable
#

yes

shrewd apex
#

makes ur number looks better

#

who is checking anyway i just put it for presence

heady sluice
#

is this how you count in how many servers from the bot's ones a member is in

slate swan
#

just use set on it :0, len(set(Bot.get_all_member()))

gaunt mortar
#

Heyo, is it possible to get every slash commands registered in each cog ? (I would want to make an help command with commands packed per cog)

gaunt mortar
slate swan
#

discord.py does not have cog-to-app-commands bindings

heady sluice
#
for cog in bot.cogs:
    for app_command in cog.application_commands:
#

smth like this

slate swan
#

?

heady sluice
#

there was something like this

heady sluice
#

!d discord.ext.commands.Cog

unkempt canyonBOT
#

class discord.ext.commands.Cog(*args, **kwargs)```
The base class that all cogs must inherit from.

A cog is a collection of commands, listeners, and optional state to help group commands together. More information on them can be found on the [Cogs](https://discordpy.readthedocs.io/en/latest/ext/commands/cogs.html#ext-commands-cogs) page.

When inheriting from this class, the options shown in [`CogMeta`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CogMeta "discord.ext.commands.CogMeta") are equally valid here.
shrewd apex
#

its app_command

stiff fern
#

Confused on what the int argument is?

heady sluice
#

I remember getting all commands

#

but I'm two countries away from my computer

heady sluice
shrewd apex
#

lmao yeah

#

just saw

stiff fern
#

its fine its not like the bot doesnt anything lol

potent spear
stiff fern
heady sluice
shrewd apex
#

it should be an error in the cog name general

stiff fern
#

o

#

ooh that makes more sense

#

I think there was something wrong with main other than the misspellin

spring flax
#

if I do asyncio.sleep on the bottom of this, will it, like ignore some reactions doing nothing? I don't want the overload the bot

@bot.listen()
async def on_reaction_add(reaction, user):
    if (
        reaction.message.channel.id != 957291513522585652
        or 
        user == bot.user 
        or
        reaction.message.author != bot.user
    ):
        return
    
    all_reactions = reaction.message.reactions
    
    sum_of_all = 0
    
    for idx, r in enumerate(all_reactions, start=1):
        product = idx * (r.count - 1)
        sum_of_all += product

    avg_rating = sum_of_all / sum(single_reaction.count -1 for single_reaction in all_reactions)
    overall_stars = convert_to_stars(avg_rating)
    e = reaction.message.embeds[0]
    e.description = f"""
    Current Community Rating: {overall_stars}
 
    {ONE} Poor

    {TWO} Fair

    {THREE} Good

    {FOUR} Very Good

    {FIVE} Excellen
    """
    await reaction.message.edit(embed=e) 
maiden fable
#

no that is just gonna wait for x seconds before running that code again

shrewd apex
spring flax
#

yeah, in that process, will it ignore the reactions that happened while asleep, or will it wait for the duration and handle those missed reactions

maiden fable
#

but it will eventually run it

maiden fable
#

They would be ignored?

shrewd apex
#

yeah

maiden fable
#

My bad then, really sorry

shrewd apex
#

but if the user leaves a reaction like his name is there then there would be data like this user reacted and stuff in the reaction object

spring flax
#

also, when I restart the bot, that code doesn't work when i react

shrewd apex
#

but any event handler or reaction won't work

shrewd apex
maiden fable
shrewd apex
#

altho that can be done

#

u have to store the message id and fetch the message using that id

shrewd apex
#

with fetching the message object u can get the reaction object replated to it too

shrewd apex
spring flax
#

no i mean why doesn't the on_reaction_add get triggered after a bot restart

shrewd apex
#

u just have to have a custom Id and set timeout = none i believe for that

shrewd apex
#

which is basically like the message object and checks if reactions are added

#

the payload or message object gets reset on bot restart

spring flax
#

what would be the ideal way to store the message ID, then

shrewd apex
#

a json

#

mostly if it's a small scale bot

spring flax
#

yep small

shrewd apex
#

yeah then json

spring flax
#

i will have multiple polls at once, would this affect?

shrewd apex
#

no

#

lemme give u pretty neat poll system using json see if i can find it first tho

dense swallow
#

if i want to hide certain cmds from help, i will have to do hidden=True in @lavish micamands.command() right?

slate swan
#

dont ping people randomly please

dense swallow
#

i didnt lol

slate swan
#

and yes

dense swallow
#

@commands.command

dense swallow
shrewd apex
#

u can add a check

#

if command.hidden

slate swan
shrewd apex
#

if hidden is true it will return a true else false

dense swallow
#

hm ok ill try that thanks

slate swan
#

Asher's smort

dense swallow
#

also the longest error, remember, Asher?
i fixed it

shrewd apex
shrewd apex
slate swan
spring flax
#

yeah, there will just be 10 polls at specific times

dense swallow
spring flax
slate swan
spring flax
#

nope

shrewd apex
spring flax
#

just the message ID

slate swan
#

oh well then

spring flax
#

i think

slate swan
#

nicetbh

maiden fable
stiff fern
#
class discord_status(commands.Cog):
    def __init__(self, bot: commands.Bot) -> None:
        self.bot = bot

    @app_commands.command(
        name="setbotstatus",
        description="Change the bots active status.")
    @app_commands.describe(
        Status = "Bot Status"
    )
    @app_commands.choices(stat=[
        Choice(name='online', value='online'),
        Choice(name='idle', value='idle'),
        Choice(name='dnd', value='dnd')
    ])
    @app_commands.checks.has_permissions(manage_messages=True)
    async def setbotstatus(
            self, interaction: discord.Interaction,
            stat: str):

        mapping = {
            "online": (discord.Status.online, "Working"),
            "idle": (discord.Status.idle, "Updating"),
            "dnd": (discord.Status.do_not_disturb, "Offline")
        }

        if not stat in ('idle', 'online', 'dnd'):
            print('Invalid argument')
        else:
            await self.client.change_presence(
                status=mapping[stat[1]], 
                activity=discord.Game(mapping[stat[2]]))
            await interaction.response.send_message(f'Status updated.')

Getting an error for TypeError: unknown parameter given: Status

slate swan
stiff fern
#

I dont know which status its talking about

spring flax
maiden fable
#

better was to store the whole message payload but for some reason Danny didn't want to provide access to it πŸ˜”

maiden fable
spring flax
slate swan
maiden fable
spring flax
#

oh wait, it would fetch the message each time. Yeah that's bad

#

what are alternatives do i have?

stiff fern
maiden fable
spring flax
#

no like really lol

#

no other alternatives?

shrewd apex
maiden fable
shrewd apex
maiden fable
#

Gimme like 1 min

#

u using disnake or dpy?

shrewd apex
spring flax
spring flax
shrewd apex
shrewd apex
maiden fable
maiden fable
spring flax
#

yeah I went through it briefly and didn't understand a thing. i'll look at it later

shrewd apex
#

ok

#

lmao ||dandy|| srsly

spring flax
#

okay so that github code uses a lot of json.
I'm not looking to entirely change my code, I just want to store and fetch the message in a single json

maiden fable
shrewd apex
#

nah lmao i was just finding it funny not offended in any way🀣

shrewd apex
dull terrace
#

This is a weird question, but if you have a function that's low priority is there a way to make it only take up a small amount of cpu and run slower

maiden fable
#

no

dull terrace
#

oh i could just do sleeps i guess

shrewd apex
#

small amount of cpu should be possible ig

spring flax
shrewd apex
#

u could check os lib on that not really sure

shrewd apex
spring flax
#

Actually I mean, I don't know how not to keep fetching the message

shrewd apex
#

just fetch it once on on ready

#

Ash would prolly know better on this than me

#

u can ask her

lyric apex
#

How to do this? Like i send a cmd help and edited the message to addemoji then the bot's message was also changed this follow as many time we edit it

dull terrace
#

"DELETE FROM submissions, likes WHERE link = ?" is this how you delete from two tables at once

heady sluice
slate swan
dull terrace
#

😀

#

just gonna do it in two things to make it simpler

shrewd apex
heady sluice
#

well

#

well nowhere

shrewd apex
#

...

heady sluice
#

make a task that you only start once

maiden fable
#

just use asyncio.run before bot.run instead dude, if u r making a task with 1 count

shrewd apex
#

hmm yeah

spring flax
shrewd apex
#

just as hunter said u just have to fetch the message object once u can do that before bot.run by creating an async function for those messages and running it using asyncio.run()

spring flax
#

Oh okay didn't know that was for me

shrewd apex
#

u could do it in on_ready also but it doesn't seem professional ig

maiden fable
#

I also didn't know I sent that for yr issue

spring flax
#

Yeah, api calls on the on_ready event aren't suggested

shrewd apex
#

btw if u are using bot.start u can just await the asynchronous function

potent spear
#

you're looking for a startup task I suppose?

spring flax
#

Yeah Im still confused what to do

slate swan
spring flax
#

Maybe I'd be better off creating a help channel

potent spear
spring flax
#

Thanks, basically what I want is the on_reaction_add to be triggered after a bot restart on each poll (there will be 10 polls happening simultaneously)

potent spear
#

this can be done when extending a botclass too... depends on when you want to run the startup task

maiden fable
#

won't work

#

u cannot access bot.loop anymore

potent spear
#

are we talking about v2 stuff?

#

since I'm on v1.7.3 without issues with this

maiden fable
#

In v2, yes

potent spear
#

v2 is just a setup hook...

maiden fable
#

I remember someone not being able to access it

maiden fable
potent spear
#

Ah, big F ig

maiden fable
#

And idk what changes disnake still has, from dpy

shrewd apex
slate swan
#

cog_load exists for cogs, why not use it? πŸ™‚

maiden fable
slate swan
#

!d disnake.ext.commands.Cog.cog_load

unkempt canyonBOT
shrewd apex
spring flax
#

Yeah other than making the loop, I just dont know what the loop func should have

shrewd apex
#

welp i am gonna dip

#

gn guys

maiden fable
#

night

spring flax
slate swan
slate swan
fringe island
#

can discord bot own his storage ?

sick birch
#

whoa whoa whoa what's that above

lyric apex
#

Replit Qtpie

sick birch
#

Can you post your full code?

#

Something's not right

slate swan
lyric apex
maiden fable
sick birch
#

Post full code and the entire traceback, not a picture of it

slate swan
#

in case you're using 2.0, bot = True is not required anymore

sick birch
lyric apex
sick birch
#

Yes but please post your entire code

lyric apex
#

Yep

sick birch
#

I'm not sure what the while True: await on_guild_channel_... stuff above it is

slate swan
sick birch
#

but we need to get that fixed

slate swan
#

create a secret (env var)

#

!d discord.Client.run

unkempt canyonBOT
#

run(*args, **kwargs)```
A blocking call that abstracts away the event loop initialisation from you.

If you want more control over the event loop then this function should not be used. Use [`start()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.start "discord.Client.start") coroutine or [`connect()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.connect "discord.Client.connect") + [`login()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.login "discord.Client.login").

Roughly Equivalent to:

```py
try:
    asyncio.run(self.start(*args, **kwargs))
except KeyboardInterrupt:
    return
```...
sick birch
slate swan
#

bare exceptπŸ˜”

sick birch
#

what is this name

slate swan
#

nice event

slate swan
maiden fable
sick birch
#

reported for impersonation of staff πŸ‹

slate swan
#

shipit recursion

slate swan
spring flax
#

is that a raiding thing?

spring flax
sick birch
#

I'm not sure what the while True: await on_guild_channel_create(channel) is going to do except cause a recursion error

slate swan
#

Robin i added my real name is that oklemon_raised_eyebrow

slate swan
spring flax
#

creating 500 "Spam Channels"

sick birch
#

This seems like it's against TOS

#

I uh, don't believe we can help you with this

slate swan
#

good

sick birch
#

That's good

fringe island
#

Can the Discord bot work offline?

lyric apex
#

What a good guyQtpie

slate swan
sick birch
#

if you need help with an actual bot, feel free to come again

maiden fable
slate swan
#

yes they can

maiden fable
fringe island
#

why

sick birch
slate swan
#

just change the status 🧠

sick birch
#

And you need internet access to connect to the websocket, as obviously, it's over the web

spring flax
#

Robin, would it be a bother if I ask you to check #help-rice

slate swan
slate swan
sick birch
sick birch
fringe island
maiden fable
slate swan
slate swan
unkempt canyonBOT
#

You are not allowed to use that command here. Please use the #bot-commands channel instead.

slate swan
#

wait, what was the event

lyric apex
slate swan
#

!d discord.on_message_edit

unkempt canyonBOT
#

discord.on_message_edit(before, after)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Message "discord.Message") receives an update event. If the message is not found in the internal message cache, then these events will not be called. Messages might not be in cache if the message is too old or the client is participating in high traffic guilds.

If this occurs increase the [`max_messages`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") parameter or use the [`on_raw_message_edit()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_raw_message_edit "discord.on_raw_message_edit") event instead.

The following non-exhaustive cases trigger this event...
sick birch
slate swan
#

oh, πŸ˜” its MessageUpdateEvent in hikari so uh lmao

lyric apex
dull terrace
#

would it be faster to:

for link, future_time in decay:
    if future_time <= time_stamp:
        try:
            for prompt_type, user_data in submissions.items():
                for id in user_data:
                    del submissions[prompt_type][id][link]
        except:
            pass
        await c.execute(delete_queries["submissions"], (link,))
        await c.execute(delete_queries["likes"], (link,))```
or rebuild everything after
```py
for link, future_time in decay:
    if future_time <= time_stamp:
        await c.execute(delete_queries["submissions"], (link,))
        await c.execute(delete_queries["likes"], (link,))

await c.execute("SELECT * FROM submissions")
for link, id, prompt_type, future_time in await c.fetchall():
    if id in submissions[prompt_type]:
        submissions[prompt_type][id][link] = []
    else:
        submissions[prompt_type][id] = {link: []}

await c.execute("SELECT * FROM likes")
for link, id, prompt_type in await c.fetchall():
    submissions[prompt_type][id][link].append(id)```
maiden fable
#

yes

slate swan
slate swan
maiden fable
#

or time.perf_counter

dull terrace
#

bit difficult without a ton of data

sick birch
fringe island
#

The Internet is storage devices and cables connected between them, is this true? If Discord Bot has its own storage device, why does it need access to other devices (internet)

slate swan
slate swan
lyric apex
slate swan
#

so much love in this channel right now, i love it

sick birch
maiden fable
#

can we take this to an ot channel?

slate swan
#

damn hunter doesnt like loveπŸ˜”

sick birch
#

The internet, in a very simplified manner, is a world wide connection of smaller networks, not wires and storage devices

dull terrace
#

actually from previous tests it's about 10x faster searching data and changing it rather than building dictionaries so ill go off of that 7739monkathink

slate swan
sick birch
# fringe island i dont understand

The internet can be quite difficult to get your head around. I've been studying networking for a while now and picked it as my chosen career and still don't understand it fully

fringe island
#

world wide connection of smaller networks.. isnt storage devices

sick birch
#

A storage device in itself is quite useless

#

A HDD, SSD, hybrid drives, etc

slate swan
#

https://www.youtube.com/watch?v=UXsomnDkntI this is a good example it showed me allotπŸ’€

Dr Binocs will explain, "How The Internet Works? | What Is Internet? | How Internet Works | Internet | Kids Learning Video | Technology "

Make sure you watch the whole video to know all the answers to your curious questions about internet and how internet works.

For more fun learning videos SUBSCRIBE to Peekaboo Kidz: http://bit.ly/SubscribeTo...

β–Ά Play video
sick birch
#

Your home network, for instance, is a small network in and of itself

#

The home networks of everyone on this world together could be considered an "internet"

fringe island
#

so its small storage and world storage , right?

sick birch
#

A network is then composed of multiple hosts and intermediate devices, switches, hubs, hosts (computers, phones, laptops), routers, etc

dull terrace
#

the internet is just cables carrying a bunch of signals with some complicated switches in the middle

sick birch
sick birch
sick birch
#

And switches are part of an internal network (assuming we're talking about layer 2 switches)

#

You can assign a IP for maintenance on their VLAN port, other than that they operate exclusively off MAC addresses on layer 2

fringe island
#

Well, what does websocket have that no one else has like discord? Within all of this

sick birch
#

You can build your own websocket client/server without much effort

fringe island
#

client/server not storage right?

sick birch
#

Client/server are both computers, yes

#

But not necessarily storage

fringe island
#

so discord dont have client/server

slate swan
#

websockets is like a phone you first have to call the person which is like a handshake and then you talk with them sorta like sending heartbeats so the conversation doesnt get all silent

sick birch
#

They do, most things do

fringe island
#

so why discord bot cant work offline

sick birch
#

Websockets are special because they're live, and discord tells you whenever there's an event (new message, new channel, etc)

sick birch
fringe island
#

ok

slate swan
fringe island
#

What does Discord Bot need on my device?

#

and i can't put it in his Discord for storage

#

If you're offline, your computer can't connect to discord's servers
why it need my computer , discord bot have one or more

sick birch
slate swan
#

you don't save the discord bot in your storage? you just have a token which is like an API Key, you send requests to discord with that token as headers, like "hey, this is my bot's identity and i wanna do X operation"

sick birch
#

Yeah I believe you're also misunderstanding how a discord bot works, as it's not a file or folder that you can put on your computer

fringe island
#

So everything the bot needs can be transferred from my computer to its own computer, and it works in an offline state

sick birch
#

You need to tell Discord's server what you want your bot to do, for example you can tell it "hey, can you make my bot say X in channel Y? thanks"

sick birch
#

For this reason a storage device isn't even necessary to run a discord bot (serverless computing)

slate swan
#

and the file you save on your device, its just a way to communicate to the API using a programing langauge

sick birch
#

The actual code, yes

#

But don't mistake the code for being the actual discord bot

fringe island
fringe island
#

so no need to me to tell him and no need to me online

sick birch
#

When you do this for example:

await ctx.send("Hello, world!")

That's instructions for discord on what it should do to your bot

sick birch
#

And when you save your .py file on your computer, that's a list of instructions on to tell discord

fringe island
#

Let's say one of the things I tell Discord to do is launch the bot

sick birch
#

Right

fringe island
#

Is it possible to put an automatic command for Discord somewhere that has it (launch the bot)

sick birch
#

That's what bot.run()/client.run() does

#

It's a command to start your bot

slate swan
#

its a method pWut

fringe island
#

Can it be made temporary or automatically without my intervention?

sick birch
#

It is, but I don't want to confuse them more than I've already done

slate swan
#

lmao

sick birch
#

As long as they get the general concept now the details can come later

maiden fable
sick birch
tacit token
#

how can i put this to role by ID?

        if payload.emoji.name=='Muted':
            role = discord.utils.get(guild.roles,name="Muted")
        if role is not None:
            member = discord.utils.find(lambda m : m.id == payload.user_id, guild.members)
            if member is not None:
                await member.add_roles(role)

So, i want to delete Muted and solve with Muted role id

sick birch
fringe island
#

I replace myself and my device with another temporary or automatic code that is inside a discord server or somewhere there , is this make it will work offline? offline = without me and my device

#

😭 i try to understand , sorry

sick birch
tacit token
sick birch
#

Buy a VPS and put your code on it, and your bot will always be up regardless of if you have your device or not

sick birch
tacit token
#

oooo i so dumb!

sick birch
#

Returns the discord.Role object from ID

tacit token
#

ty sir!

sick birch
#

Also same deal for member, use guild.get_member(id)

fringe island
#

can i ask more thing

maiden fable
#

Don't ask to ask, this channel is for questions only

fringe island
#

and thanks for your time, and your care to teach me

fringe island
maiden fable
#

Huh?

maiden fable
#

Nope

#

VPS is like an online computer which runs 24/7 and u gotta pay companies to rent those VPS out to u

sick birch
maiden fable
digital mason
#

How much time does it take to verify a bot ? I just submitted my id to Stripe but discord keeps saying this : We are unable to verify your identity because one or more of the documents you provided are invalid. Please try again.

maiden fable
alpine pewter
#

Does anyone know how you'd be able to get a message ID from a message your bot sends?
Read it's something like this
edited = await channel.history() ...

slate swan
stiff gorge
#
    @commands.command(name='time', pass_context=True)
    async def _time(self, ctx):
      now = datetime.datetime.now()
      current_time = now.strftime("%H:%M:%S")
      print("Current Time =", current_time)
      await ctx.send('Date is: **{0}**\nTime is: **{1}**'.format(time.strftime("%A, %B %d, %Y"), time.strftime("%H:%M:%S %M")))#("%I:%M:%S %p")))
      ind_time = datetime.datetime((timezone("Asia/Kolkata")).strftime('%H:%M:%S'))
      await ctx.send(f"IST: {ind_time}")
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Asia/Kolkata' object has no attribute 'strftime'
maiden fable
#

I mean that is the easiest way to say it

stiff gorge
#

how to send ist time ?

digital mason
#

Is it instant

digital mason
#

So I have to keep trying ?

maiden fable
digital mason
#

Thanks but Im happy here lol

maiden fable
#

Haha that is the official discord server and its basically made so that people can ask questions related to Bot Verification and other discord products, that is why I suggested it

digital mason
#

I know, but I might not be welcomed there

digital mason
#

Could be like so

maiden fable
digital mason
#

It's asking me if im human

tacit token
#

how can i make a video fun with command? i have a white wall mp4 video, and if i write >hello asd the bot send one video with my white wall but write to the wall "asd"

#
@client.command()
async def hello(ctx,*,szoveg="hello"):
    clip = VideoFileClip("crab.mp4") 
    clip = clip.subclip(0, 5) 
    clip = clip.volumex(0.5) 
    txt_clip = TextClip(szoveg, fontsize = 75, color = 'green') 
    txt_clip = txt_clip.set_pos('bottom').set_duration(5) 
    video = CompositeVideoClip([clip, txt_clip]) 
    file = File(filename="crab.png")
    await ctx.send(file=file)

i try this with moviepy

digital mason
#

I went through the id part but now I have need a terms of service url

#

Does it have to be a link to a website or can it be a link to a file

maiden fable
#

website sadly

#

Ask in the server tho what to do

digital mason
#

I dont have a website

#

I had to leave it

#

Because they say in the rules dont put a link to your bot in bio so i will remove it now

slate swan
digital mason
#

Wait

digital mason
#

My friend has vps where my bot is hosted

#

Might start a flask server that points to the terms of service

#

Would that be ok

#

Because I only have ip

maiden fable
digital mason
#

Is this an official python discord

maiden fable
#

What is there to laugh...

digital mason
#

What you said about websites

maiden fable
#

She just said what Discord expects us to do, not a thing to laugh on if I or anyone else doesn't like it

maiden fable
digital mason
#

I know and Im planning to use flask

#

I might even start the server when the bot starts

#

Like in repl

maiden fable
#

cool, so yea no need to laugh on anyone here, who knows u hurt whom

digital mason
#

I was just wondering if I could use an ip link instead of a domain

sick birch
slate swan
sick birch
#

plain CSS hyperventilating noises

dapper stirrup
#

from discord.ext import tasks

hey guys, what does it mean?)

slate swan
slate swan
#

my bad

maiden fable
#

no one even reads the ToS and Privacy Policy before he/she gets into a situation

sick birch
dapper stirrup
#

this was my qua)

sick birch
#

Ahh, it's an extension to help dealing with interval based things easier, for example if you wanted to run a function every 2 minutes, you'd use the tasks extension

#

Sort of like background polling if that makes sense

slate swan
slate swan
#

for example

@tasks.loop(seconds=1) #ofc not gonna run it ever second
async def _():
  c = get_channel(...) or await fetch_channel(...)
  await c.send("uwu")

_.start()
#
await _[0]()

what have i done

fringe island
#

so , dose discord own a VPS ?

slate swan
#

they have private servers

maiden fable
sick birch
slate swan
sick birch
#

Most likely from cloud service providers as having your own large scale datacenter is difficult

fringe island
#

So, the Discord program that we are using ..can work without VPS

slate swan
sick birch
#

It communicates to discord's server via their user API, however

slate swan
#

aka a client

sick birch
#

Your bot does the same thing, except using the bot API

#

The discord API is more or less a way for bots to be able to use discord sort of like you are

fringe island
#

Very valuable information, I do not know how to thank you for your time and interest, and all those who shared the knowledge with me

maiden fable
#

I do agree that Robin is great at explaining things

slate swan
#

look who's saying that

fringe island
#

. I will make sure this information comes to fruition that would be a thank you

maiden fable
sick birch
#

No problem, feel free to ask anytime. I do love explaining how things work more than I like fixing problems

maiden fable
#

either way, I ain't really as good as Robin when it comes to explaining stuff

slate swan
#

inarguable

fringe island
#

I know it's hard to explain how things work, because the listener, or the reader, doesn't have the same terminology, but I try as much as I can.

maiden fable
#

Nice

slate swan
slate swan
#

it has either to be a coro, or return a coro

slate swan
#

or am i wrongπŸ˜…

pliant gulch
#

You are correct

slate swan
#

im using a decorator to make a list of decorated coros and then i index the list and i call them

#
[{identifier: functionobject}]

something like this

#

the underscore makes it look cursed.

#

its lovely

maiden fable
#

nice readiblity tho

slate swan
#

!e

from datetime import datetime as _
from datetime import timedelta as __

def ___():
  ____ = _.utcnow() + __(seconds=10)
  return ____

print(___())
unkempt canyonBOT
#

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

2022-06-05 19:22:39.386592
slate swan
#

ah

maiden fable
#

Ashley, just use __import__ and lambda and go to #esoteric-python for that code next time

slate swan
#

lmao

magic pond
#

is this correct way ?

chrome lance
#

I need help

#

It keeps saying this and it keeps me from getting my bot online and it is so dam annoying

#

Like deadass, someone help me fix this stupid error. Nothing is wrong with my code this error happens out of nowhere ong

sick birch
#

Looks like you may be getting rate limited?

chrome lance
sick birch
#

Hard to tell though, can you paste the entire thing into a pastebin?

sick birch
slate swan
sick birch
#

In this case the only reason

chrome lance
#

you guys got any other good coding softwares? with webserver support?

sick birch
#

Unless you're doing something in your code that's getting ratelimited which I doubt

sick birch
slate swan
#

i'll suggest writing the code on ur device, and deploying it later on a vps

chrome lance
#

alr

slate swan
magic pond
#

the cmnd works with prefix

#

but not with slash

chrome lance
#

so im guessing, if i were to get a vps synced with the replit service it would run off the vps and not replits service?

slate swan
magic pond
#

ok

slate swan
magic pond
#

i had added a cmnd 2-3 days back but still not registered

waxen python
#

what library are you using?

slate swan
#

dear, please help me how to attach a link from a disk to a laptop?

        embed.set_image(url = )
#

!local-file

unkempt canyonBOT
#

Thanks to discord.py, sending local files as embed images is simple. You have to create an instance of discord.File class:

# When you know the file exact path, you can pass it.
file = discord.File("/this/is/path/to/my/file.png", filename="file.png")

# When you have the file-like object, then you can pass this instead path.
with open("/this/is/path/to/my/file.png", "rb") as f:
    file = discord.File(f)

When using the file-like object, you have to open it in rb mode. Also, in this case, passing filename to it is not necessary.
Please note that filename can't contain underscores. This is a Discord limitation.

discord.Embed instances have a set_image method which can be used to set an attachment as an image:

embed = discord.Embed()
# Set other fields
embed.set_image(url="attachment://file.png")  # Filename here must be exactly same as attachment filename.

After this, you can send an embed with an attachment to Discord:

await channel.send(file=file, embed=embed)

This example uses discord.TextChannel for sending, but any instance of discord.abc.Messageable can be used for sending.

slate swan
#

in case you mean a local image

main tide
#

this is how i defined my buttons, how do i delete it after interaction?

    @discord.ui.button(label='Cancel', style=discord.ButtonStyle.red)
    async def Cancel(self, interaction: discord.Interaction, button: discord.ui.Button):
        await interaction.response.send_message('Profile Cancelled', ephemeral=True)
        self.can = True
        self.stop()
slate swan
slate swan
slate swan
#
@bot.on("READY")
async def connect(payload: dict[str, "Any"]) -> None:
    print(payload)

what do you guys think?πŸ€”

#

sarthak check the impl, plsshipit

slate swan
slate swan
slate swan
#

sounds good then

#

i have allot to doπŸ˜”

alpine cove
#

yea i'll help ya:
first import os (at the top of the file):
import os
second get the current path:
path = f"{os.path.dirname(os.path.abspath(__name__))}/"
now lets get the image:

        file = discord.File(f"{path}Π±Π°Π½/clear.png", filename="file.png")

        embed.set_image(url = "attachment://file.png")
#

this should work

#

assuming your folder structure:
C:/bot py/
-> Π±Π°Π½
-> main.py
-> -> clear.png"

slate swan
#

show your work dir

alpine cove
slate swan
# slate swan show your work dir
from pydoc import describe
from turtle import title
from urllib import response
import discord
from discord.ext import commands
from PIL import Image
import requests
from requests import request
from PIL import Image, ImageFont, ImageDraw, ImageOps # Для рисования ΠΊΠ°Ρ€Ρ‚ΠΎΡ‡ΠΊΠΈ ЕстСствСнно
import io
import os
import sys

class pillow(commands.Cog):
    def  __init__(self, bot) -> None:
        self.bot = bot

    @commands.command( name = '123', aliases = ["321"])
    async def command_123(self, ctx,):
        img = Image.new('RGBA', (8000,4800), '#232934' )

        embed = discord.Embed(
            title="Π‘Ρ‹Π» Π·Π°Π±Π°Π½Π΅Π½ ΠœΠ•ΠœΠ‘Π•Π ",
            color= 0xff0000
        )

        embed.set_footer(
            text="| ΠŸΡ€Π°Π²ΠΈΡ‚Π΅Π»ΡŒΡΡ‚Π²ΠΎ SK",
            icon_url= ctx.guild.icon_url,
        )
        path = f"{os.path.dirname(os.path.abspath(__name__))}/"

        file = discord.File(f"{path}Π±Π°Π½/clear.png", filename="file.png")

        embed.set_image(url = "attachment://file.png")

        embed.add_field(name="Π‘Π°Π½ Π²Ρ‹Π΄Π°Π½:", value="China", inline=True) 
        embed.add_field(name="Π‘Ρ€ΠΎΠΊ Π±Π°Π½Π°:", value="2 дня", inline=True) # ΠΏΠΎ ΠΎΡ‡Π΅Ρ€Π΅Π΄ΠΈ ΠΏΠΎΡ‚ΠΎΠΌΡƒΡ‡Ρ‚ΠΎ Π² ΠΊΠΎΠ½Ρ†Π΅ True
        embed.add_field(name='\u200b', value='\u200b', inline=False)
        embed.add_field(name="ΠŸΡ€ΠΈΡ‡ΠΈΠ½Π° Π‘Π°Π½Π°:", value="ΠŸΡ€ΠΈΡ‡ΠΈΠ½Π°", inline=True) 
        embed.add_field(name="Π”Π°Ρ‚Π° Π²Ρ‹Π΄Π°Ρ‡ΠΈ:", value="Π”Π°Ρ‚Π°", inline=True)

        await ctx.send(embed=embed)
def setup(bot):
     bot.add_cog(pillow(bot))
#

i said your work directory not your cog?

slate swan
#

i recommend not using absolute paths

#

And how then?

#

you would check the path relatively

slate swan
slate swan
#
# Discod Module
import discord                      # ΠœΠΎΠ΄ΡƒΠ»ΡŒ дискорда 
from discord.ext import commands    # ΠžΡΠ½ΠΎΠ²Π½Ρ‹Π΅ ΠΊΠ°ΠΊΠΈΠ΅ Ρ‚ΠΎ ΠΌΠΎΠ΄ΡƒΠ»ΠΈ

# Installed modules
import random # Π­Ρ‚ΠΎ потрСбуСтся для начислСния ΠΎΠΏΡ‹Ρ‚Π°
import requests # Π­Ρ‚ΠΎ для получСния Π°Π²Π°Ρ‚Π°Ρ€Π° ΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»Ρ
from io import BytesIO # Π£ΠΆΠ΅ Π½Π΅ помню, Π²Ρ€ΠΎΠ΄Π΅ для ΠΊΠΎΠ½Π²Π΅Ρ€Ρ‚Π°Ρ†ΠΈΠΈ Π°Π²Π°Ρ‚Π°Ρ€ΠΊΠΈ
from PIL import Image, ImageFont, ImageDraw, ImageOps # Для рисования ΠΊΠ°Ρ€Ρ‚ΠΎΡ‡ΠΊΠΈ ЕстСствСнно

# Import SQLITE Module
import sqlite3 # НУ ΠΈ примитивная Π‘Π°Π·Π° Π΄Π°Π½Π½Ρ‹Ρ…)

# Installed modules
import os # ΠžΡ‡ΠΈΡΡ‚ΠΊΠ° ΠΊΠΎΠ½Ρ‡ΠΎΠ»ΠΈ

# Cliear console [Linux]
os.system("cls") # ΠžΡ‡ΠΈΡ‚ΡΠΊΠ° консоли ΠΎΡ‚ мосура

# Cosg list
cogs = [        # Коги из нашСй папки
    "mod",
    "pillow"
]

# Class Main 
class Main(commands.Bot):                   # ΠžΠ±ΠΎΠ·Π½ΠΎΡ‡Π°Π΅ΠΌ Ρ‡Ρ‚ΠΎ наш основной Ρ„Π°ΠΉΠ» являСтся основным 
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)


# Π”Π°Ρ‘ΠΌ ΠΏΠΎΠ½ΡΡ‚ΡŒ Ρ‡Ρ‚ΠΎ дальшС ΠΌΡ‹ Π±ΡƒΠ΄Π΅ΠΌ оброщятся ΠΊ client
client = Main(
    help_command = None,                # Π£Π±ΠΈΡ€Π°Π΅ΠΌ help
    command_prefix = ".",               # ΠŸΡ€Π΅Ρ„ΠΈΠΊΡ Π±ΠΎΡ‚Π°
    intents = discord.Intents.all())    # Intenst ΠΈΠ»ΠΈ ΠΊΠΎΡ€ΠΎΡ‚ΠΊΠΎ Ρ€Π°Π·Ρ€ΠΈΡˆΠ΅Π½ΠΈΡ для Π±ΠΎΡ‚Π° ΠŸΠΎΠ±Ρ€ΠΎΠ±Π½Π΅Π΅ здСсь "https://discord.com/developers/applications"

            


@client.event
async def on_ready():
    print("READY!")


# ΠžΡ‡Π΅Ρ€Π΅Π΄Π½Π°Ρ ΠΏΡ€ΠΎΠ²Π΅Ρ€ΠΊΠ° Π½Π° обозночСния Ρ„Π°ΠΉΠ»Π° Ρ€ΠΎΠ΄ΠΈΡ‚Π΅Π»ΡŒΡΠΊΠΈΠΌ Π° Ρ‚ΠΎΠ΅ΡΡ‚ΡŒ основным
if __name__ == "__main__":
    # НАчала Π·Π°Π³Ρ€ΡƒΠ·ΠΊΠΈ ΠΊΠΎΠ³ΠΎΠ²
    for extension in cogs:
        cog = f"cogs.{extension}"

        # Π—Π°Π³Ρ€ΡƒΠΆΠ°Π΅ΠΌ Ρ„Π°ΠΉΠ» ΠΊΠΎΠ³ΠΎΠ²
        try:
            client.load_extension(cog)
        
        # Если ΠΏΡ€ΠΎΠ΅Π·ΠΎΡˆΠ»Π° ошибка ΠΏΡ€ΠΈΠ½Ρ‚Π°Π½Ρ‘Ρ‚ Π² консоль
        except Exception as e:
            print(e)

client.run( "Token" )
#

This?

#

i said your work directory! e.g

β”œβ”€β”€β”€Videos
    └───Captures
#

videos is a folder and captures is a subfolder!

#

that is called a directory!

#

i want to know where the photo is compared to your cog so i know its location and i can show you the relative path!

#

Hope. Just don't hit me

#
"../imageO/clear.png"

this should work

#

having all the media in your bot project's directory is always an better idea

#

oh, it is

#

or even better in the dir where you need them😳

slate swan
slate swan
#

is should be Image0/my keyboard doesnt support that language/clear.png

#

        path = f"{os.path.dirname(os.path.abspath(__name__))}/"

        file = discord.File(f"{path}Π±Π°Π½/clear.png", filename="file.png")

        embed.set_image(url = "attachment://file.png")
slate swan
maiden apex
#
@client.command()
async def help(ctx):
    embed = discord.Embed(title=" ", color=0xff7b00)
    embed.set_author(name="Help", icon_url="https://s2.coinmarketcap.com/static/img/coins/200x200/14481.png")
    embed.add_field(name="_inputbruteforce (_ibf)", value="Bruteforce all possible inputs for a straight momentum.",
                    inline=True)
    embed.add_field(name="_inputbruteforce45 (_ibf45)",
                    value="Bruteforce all possible inputs for a facing 45 momentum.", inline=True)
    embed.set_footer(text="uwu")
    await ctx.send(embed=embed)``` can someone help me finding what is wrong in this embed ?
#

i keep getting error messages

slate swan
fading marlin
slate swan
#

does windows have a tree command in their cmd?

slate swan
slate swan
#

they could just use it and send their file structure here, quite easier to help then

maiden apex
# fading marlin send the error
  File "C:\Users\arsbu\Documents\CODE\PKbot\main.py", line 353, in <module>
    async def help(ctx):
  File "C:\Users\arsbu\Documents\CODE\PKbot\testpy\lib\site-packages\discord\ext\commands\core.py", line 1263, in decorator
    self.add_command(result)
  File "C:\Users\arsbu\Documents\CODE\PKbot\testpy\lib\site-packages\discord\ext\commands\core.py", line 1149, in add_command
    raise CommandRegistrationError(command.name)
discord.ext.commands.errors.CommandRegistrationError: The command help is already an existing command or alias.

Process finished with exit code 1
slate swan
#

because that path totally depends on their bot.py

#

Β―_(ツ)_/Β―

fading marlin
slate swan
#

remove the 2 periods

#

that was my fault

#

and dont add the path variable

#

no need for it

#
file = discord.File("/imageO/Π±Π°Π½/clear.png", filename="file.png")
#

this is enough

#

need help

#

Hooray. it doesn't throw an error❀️

#

nice

maiden apex
slate swan
#

It just doesn't show the picture.(((

#

need help with this code

fading marlin
#

roles

slate swan
#

thanks

slate swan
#
embed.set_image(file=file)
#

this should work

fading marlin
# slate swan thanks

and you probably want to iterate through the member's role's instead of checking if they only have the 'perms' role

warped mirage
#

Hey

slate swan
#

        file = discord.File("/imageO/Π±Π°Π½/clear.png", filename="file.png")

        embed.set_image(file = file)

😭

#

help me pls

warped mirage
#

Guys I was told before that people can get ur bot counterfeited , it was quite a bit ago , can someone explain what they mean by that

slate swan
#

also how do i add lots of it?

fading marlin
fading marlin
slate swan
#

can you show me how to add it?

fading marlin
#

add what?

slate swan
#

comparing a list to a string?

slate swan
slate swan
#

i recommend you check your path correctly

fading marlin
fading marlin
slate swan
#

I dont know how to add it

slate swan
fading marlin
#

what do you want to add?

slate swan
#

that?

fading marlin
#

ctx.author.roles returns a list of the roles that the member has

slate swan
#

comparing an int to a string🀨

fading marlin
#

again, ctx.author.role isn't a thing

slate swan
#

how do you do roles id?

slate swan
fading marlin
slate swan
#

okay

fading marlin
#

!d discord.Member.roles here's the link

unkempt canyonBOT
#

property roles```
A [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role") that the member belongs to. Note that the first element of this list is always the default [β€˜@everyone](mailto:'%40everyone)’ role.

These roles are sorted by their position in the role hierarchy.
slate swan
# slate swan how to do it

windows + r and then type in cmd and then type inside the console tree and you will see your computers directory

latent spear
#

Any way to make a discord bot that replys with a file when someones says !file? Please dm me or respond hereπŸ˜€ ( TAG ME )

warped mirage
#

Guys has Ashley quitted

unkempt canyonBOT
#

await reply(content=None, **kwargs)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

A shortcut method to [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") to reply to the [`Message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Message "discord.Message").

New in version 1.6.

Changed in version 2.0: This function will now raise [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.10)") or [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError "(in Python v3.10)") instead of `InvalidArgument`.
slate swan
#

it takes a file argument, use it

#

what to enter. tell me please

slate swan
latent spear
slate swan
#

that would just... spam his console

fading marlin
#

I'd recommend first changing to the directory where your bot file is, otherwise you're gonna get a whole lot of useless directories

slate swan
#

navigate to the bot's folder first

slate swan
slate swan
#

:(

slate swan
#

just tell the person to find the parent folder and send the dir its easier to helpπŸ˜”

#

i'd just upload it to a cdn and use its url

#

So. he gave me a tree. Do I need to find the final clear.png file?

slate swan
#

python files

#

find the parent directory where your whole bot is in and send the directory

#

only the bot!

#

something from this

slate swan
gaunt mortar
#

Good evening, does the function Cog.get_commands() provides the list of slash commands or only standard commands ?

heady sluice
#

standard only

gaunt mortar
#

By any chance, do you know if there is a way to gather a list of slash commands contained in a cog ?

slate swan
#

weird its named differently in dpy?

heady sluice
#

docs don't show it

#

but a pro programmer move is to get a Cog instance, write a dot and scroll through the attributes

slate swan
#

ah dpy doesnt have it

heady sluice
#

disnake does for sure

#

!d disnake.ext.commands.Cog.get_application_commands

unkempt canyonBOT
gaunt mortar
heady sluice
#

no I meant maybe there's an undocumented thing

slate swan
#

i mean yeah something unique that specifies all methods that use slash commands and checking the class's attribute with dir is a good idea ig

heady sluice
#

what's the tree class called

torn sail
#

!d discord.app_commands.CommandTree

unkempt canyonBOT
#

class discord.app_commands.CommandTree(client, *, fallback_to_global=True)```
Represents a container that holds application command information.
heady sluice
#

thanks

#

!d discord.app_commands.CommandTree.get_commands

unkempt canyonBOT
heady sluice
#

bot.tree.get_commands()

#

gets all, not just those from a cog

gaunt mortar
#

Yep, I already saw it and I think I'll just send every commands sorted per name, I'd love to sort them by cog and something with a dropdown menu but it seems.. tricky to find them per cog xD

torn sail
#

Would it be possible to do cog.__cog_app_commands__?

heady sluice
#

dunno, that's why we suggested dir

slate swan
#

@slate swanI checked a couple of times and couldn't find it. copied to vs clicked replace bot py. he did not find. or did i do something wrong?

#

discord.errors.NotFound: 404 Not Found (error code: 0): Interaction is unknown (you have already responded to the interaction or responding took too long) Possible solutions for this error?

#

I think its try: except discord.NotFound: something like this

#

how can I add multiple buttons?

#
async def command_dashboard(interaction: discord.Interaction,) -> None:
    embed = discord.Embed(
        colour=0xa1cbf0, title="Social Media", description="."
    )
    embed.set_footer(text="snkrsgroup | by", icon_url=")
    view = discord.ui.View()
    view.add_item(discord.ui.Button(style = discord.ButtonStyle.url, url= "url", label="Twitter"))
    await interaction.response.send_message(embed=embed, view=view)```
stone beacon
#

The same way you added the first one

slate swan
stone beacon
#

View.add_item yea

slate swan
#

ah yea. I also copied view = disc... . thats the mistake

bronze gyro
#

Can anyone help me make a discord bot?

elfin moon
#

how do i send a message to a user with a given ID outside of a command in an async function? Right now I have this code but it doesn't work. ablobsadpats

async def onVote(userid):
    def isUserAvailable():
        return userid not in farmusers

    condition = asyncio.Condition()
    await condition.wait_for(isUserAvailable)

    user = bot.get_user(int(userid))

    print(user)

    if user is not None:
        await user.send('Thanks for voting!')

The last line seems to be causing the error.

#

The error is Timeout context manager should be used inside a task

round knoll
#

hello! im looking for some documentation about roles.. i want my bot to check if someone went into streamer mode and is live on twitch, then assign the Live role.. would that work? im trying this so far

# checks if discord activity is streaming, if true, assign LIVE role, if Flase, remove LIVE role
@loop(seconds=90)
@bot.event
async def set_live_role():
    for user in discord.Guild.fetch_members():
        if discord.Member.activity == "Streaming":
main tide
#

how do i pass in an arg in wait_for? also how do i loop it to constantly wait on smth else

slate swan
#

How can I pass an arg in a task?

unkempt canyonBOT
#
Not in a million years.

No documentation found for the requested symbol.

dull terrace
#

you ever write like 100 lines of code and then realise everything you've written is completely unnecessary and delete it 3142painwithcoffee

slate swan
#

you can pass in the args to task.start

slate swan
slate swan
#

@slate swan How do I do it with a task?

#

just do it like you do normally?

slate swan
#

!d discord.Client.get_guild

unkempt canyonBOT
#

get_guild(id, /)```
Returns a guild with the given ID.

Changed in version 2.0: `id` parameter is now positional-only.
slate swan
#

I want to use utils though

#

discord.utils.get(ctx.guild.channels, name="test")

#

@slate swan ?

slate swan
#

why is everyone so dependent on ctx

slate swan
#

guild = bot.get_guild(guild_id)?

#

thats all.

#

what if it's in more than one server

#

what do you want to do?

slate swan
round knoll
#

anyone can help? does it look like im going somewhere with this? im trying to print the member list of my discord, no luck so far lol

# checks if discord activity is streaming, if true, assign LIVE role, if Flase, remove LIVE role
@loop(seconds=90)
@bot.event
async def set_live_role():
    members_list = discord.guild.members
    print(members_list)

    for member in members_list:
        if discord.ActivityType == "streaming":
            pass
slate swan
#

how do i make an embed look like this?

boreal ravine
boreal ravine
slate swan
#

just all of it

#

looks clean

pliant gulch
#

That doesn't look like an embed, more so it's an ANSI codeblock

#

Well, the coloured stuff at least, the rest is a regular embed

slate swan
#

what so with a title and thats just the description?

fresh ferry
#

hey everyone,
how can one make the bot give a role once a if statement was detected ?

i have said bot removing roles when the user as used a banned word but needing help to find a solution to have it give a role once that original role was taken, for clarification its a quarantine role im trying to give to said user

pliant gulch
#

The description is the ANSI codeblock, yes

slate swan
#

ok thank you

pliant gulch
#

πŸ‘

#

Keep in mind, discord ANSI support is limited, you'll only have the basic colours and different styles but not all styles & colours

#

That should still be more than enough to make something good looking though

slate swan
#
  • that looks cursed on mobile phones
pliant gulch
#

Mobile is bad anyways

slate swan
#

πŸ‘€

zenith agate
#

Are there are discord bots that can help with banning recent bot raids?

lofty olive
#

hey guys i have a question i always get this error:

from discord_slash import SlashCommand
ModuleNotFoundError: No module named 'discord_slash'

this is what the lines where the error is looks like:
from discord_slash import SlashCommand

i already tried several time
pip install discord-py-slash-command

sick birch
#

Make sure it's installing in the right version

#

Besides you don't really need it, since discord.py in itself has slash commands

slate swan
#
\u001b[40;38;2;255;255;0mHello
#

why wont it work?

pliant gulch
#

You need to copy paste the character, the one you just sent only works when the bot does it from code