#discord-bots

1 messages · Page 94 of 1

glad cradle
#

wth

wicked atlas
#

get_channel attempts to get the channel object from it's internal cache. If it's not in there, it returns None. You can fix it by doing something like this to fetch the channel with an API call if it's not in the cache

answer_channel = interaction.client.get_channel(ac) or await interaction.client.fetch_channel(ac)
  • Me, about 20 minutes ago
white citrus
#

I tried fetch channel

shut tendon
#

Fixed! Thank you so much!

weary flume
#

?

slate swan
weary flume
#

they send like this

#

a
A
A

#

if it goes past 3 lines in 1 message

#

itll delete their message

slate swan
# weary flume a A A

hmm not sure. get the message_content and see how its returned. cause i don't know if the message will actually be returned like that if getting from the bot

wicked atlas
#

@weary flume ```py
if message.content.count("\n") > 3:
await mesasge.author.ban("D: D: D: D:")

primal token
#

and reason is a kwarg

wicked atlas
primal token
#

Or maybe you made an honest mistakepithink

#

No need to be embarrassed ducky_beer

wicked atlas
#

I mean, the mesage one was

vague zephyr
vital glacier
#

How can I store a username change if a member changes their username on discord? (if my bot is in the same guild as them it should store it into a db, but i need a way to detect the username change)

primal token
unkempt canyonBOT
#

*args and **kwargs

These special parameters allow functions to take arbitrary amounts of positional and keyword arguments. The names args and kwargs are purely convention, and could be named any other valid variable name. The special functionality comes from the single and double asterisks (*). If both are used in a function signature, *args must appear before **kwargs.

Single asterisk
*args will ingest an arbitrary amount of positional arguments, and store it in a tuple. If there are parameters after *args in the parameter list with no default value, they will become required keyword arguments by default.

Double asterisk
**kwargs will ingest an arbitrary amount of keyword arguments, and store it in a dictionary. There can be no additional parameters after **kwargs in the parameter list.

Use cases
Decorators (see !tags decorators)
Inheritance (overriding methods)
Future proofing (in the case of the first two bullet points, if the parameters change, your code won't break)
Flexibility (writing functions that behave like dict() or print())

See !tags positional-keyword for information about positional and keyword arguments

primal token
#

!positional

unkempt canyonBOT
#

Positional vs. Keyword arguments

Functions can take two different kinds of arguments. A positional argument is just the object itself. A keyword argument is a name assigned to an object.

Example

>>> print('Hello', 'world!', sep=', ')
Hello, world!

The first two strings 'Hello' and world!' are positional arguments.
The sep=', ' is a keyword argument.

Note
A keyword argument can be passed positionally in some cases.

def sum(a, b=1):
    return a + b

sum(1, b=5)
sum(1, 5) # same as above

Somtimes this is forced, in the case of the pow() function.

The reverse is also true:

>>> def foo(a, b):
...     print(a, b)
...
>>> foo(a=1, b=2)
1 2
>>> foo(b=1, a=2)
2 1

More info
Keyword only arguments
Positional only arguments
!tags param-arg (Parameters vs. Arguments)

primal token
# unkempt canyon

somtimes,

Note
A keyword argument can be passed positionally in some cases.

def sum(a, b=1):
    return a + b

sum(1, b=5)
sum(1, 5) # same as above

A keyword argument can be passed positionally in some cases

But they're showing a positional argument with a default value🤔

sick birch
#

good catch

#

actually wait

#

I think it's just showing you can use kwargs in place of positional arguments

#

The wording is a bit confusing but the point stands

slate swan
#

Hey!

When trying to run my bot, the bot goes online
But also returns this error

discord.errors.HTTPException: 400 Bad Request (error code: 30034): Max number of daily application command creates has been reached (200)

And some of my commands are missing...
How would i fix it

primal token
#

You can only sync your app commands 200/d iirc

slate swan
#

sounds gay

primal token
#

Unnecessary comment that makes no sense

slate swan
primal token
#

Wait a day

slate swan
#

"around it"

#

ive used multiple applications

sick birch
#

They're there for a reason and should be respected

slate swan
#

sounds like a girl on there period shrug

sick birch
#

What?

#

Trying to circumvent ratelimits would probably just get you banned

#

Well not really a "rate limit"

#

But a "rate limit" to app commands, if you will

pliant gulch
#

You could've circumvented the whole problem to begin with if you only synced commands when you needed

primal token
slate swan
#

Can i make it so when someone types the other persons id in chat it adds them into a private channel?

slate swan
# sick birch What?

I'm sorry to bother you, but If I tell you an idea for a bot, would you be able to generalize some instructions on how to do it?

sick birch
#

I might be able to

slate swan
#

In one week if the thumbs ups don't get to above 5 in a week, they are deleted.

#

I know how to do the reactions, I'm just not sure how to check how many of a reaction is clicked, and also I'm not able to know if it's been a week or not.

unkempt canyonBOT
#

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

Sleep until a specified time.

If the time supplied is in the past this function will yield instantly.

New in version 1.3.
sick birch
#

or asyncio.sleep()

slate swan
#

Okay so like this:

#
When message is recieved --> Add 2 reactions, await asyncio.sleep(week_in_seconds) # Do check here
#

This would work?

sick birch
#

Looks good

slate swan
#

Just quick thing, would this halt every single.... would this halt the program, or would it thread? (Would it run asynchronously so they don't interfere)

sick birch
rare echo
#

async :)

slate swan
marsh maple
#

Been awhile since I messed around with coding. Made a decent bot with discord.py and now trying to rewrite it using nextcord. Anyone know of a nextcord server?

sick birch
marsh maple
#

Because it's been acting up and I thought it might have to do with .py being discontinued

sick birch
#

it's strong as ever py_strong

primal token
primal token
wary shadow
sick birch
#

That's to be seen

primal token
slate swan
sick birch
unkempt canyonBOT
slate swan
sick birch
#

if you wanted to get the first emoji reaction count, it'd just be print(message.reactions[0].count)

slate swan
#

Oh

#

alright, thank you.

normal bolt
#

GM, is it possible to create an interaction with a spoiler tag? ex: As soon as the member clicks on the spoiler tag and displays the word, the discord bot prints that word in the terminal.

worn terrace
torn sail
#

Because I think that’s all there is that’s written down in the docs

modern pecan
torn sail
#

I may be able to. Have to go soon tho

modern pecan
#

its quick

#

why does every single python file i oopen close

#

open\

#

even the ones made by other people

torn sail
#

Wdym by close

#

Like the open function?

modern pecan
#

like

#

when i run a file

torn sail
#

So does the code not run?

modern pecan
#

I have no idea it opens the window then closes instantly

torn sail
#

Oh

#

I’ve got no clue.

unkempt canyonBOT
#

Hey @modern pecan!

It looks like you tried to attach file type(s) that we do not allow (.mkv). We currently allow the following file types: .gif, .jpg, .jpeg, .mov, .mp4, .mpg, .png, .mp3, .wav, .ogg, .webm, .webp, .flac, .m4a, .csv, .json.

Feel free to ask in #community-meta if you think this is a mistake.

modern pecan
#

bruh

#

see

#

Like it dosent really show on the video

#

but a little windows appears

primal token
# modern pecan

You tried to run a python file with pythons interpreter but the file raised an error and closed

slate swan
vocal snow
#

Aren't you already doing that? You're returning of the target id is in the json

slate swan
#

i tried, but even though it says that

#

i am authed and i tried adding stuff to myself it just returned telling me run the ecoclaim command

#

i think it has something to do with the way the .json file is formatted

Code:

{
    "authed": [
        "295499172994351105",
        "",
        "755155481458114630"
    ]
}
vocal snow
slate swan
#

how owuld i do that

primal token
#

JSON as a db and blockingio😬

slate swan
#

idk its just supposed to be a simple thing

primal token
#

sqlite with a asynchronous driver is quite easy as well and it's good because it's actually intended to store allot of data and commit CRUD operations

slate swan
#

i know...

primal token
#

Then why are you not using a db if you know its advantages?

slate swan
#

cause this is meant to be simple for like 3 people

#

not anything special

primal token
#

My point still stands

slate swan
#

ok

rare echo
#

doing a lot for 3 people 👀

slate swan
#

yea

#

idk i have free time

rare echo
#

it would be better to switch before you end up growing it

#

might turn into a bigger project, might as well start off right

slate swan
#

what i was planning to do

#

when the bot is finally done and shit

#

with more that a couple people

primal token
#

If you want a large crowd of people using your bots database i wouldnt recommend sqlite either

slate swan
#

im not that popular lmao

primal token
#

Depends what you define on a "large crowd of people"

slate swan
primal token
#

It would depend on the application

rare echo
#

discord bot ofc

#

general application

primal token
#

It would still depend on abstractions and usage

rare echo
#

just an overall database say storing a guild and all the info that could apply to the bot being nearly custom

primal token
#

Would depend on how much data you're storing and how you want to store it

rare echo
#

say ~50 guilds, each guild containing around 15 different variables ie id’s or bools for toggles and how storing doesn’t matter

primal token
#

sqlite or mongodb or sqlalchemy are good with an asynchronous driver

#

Depending on the growth of the data you can go for something like postgresql which is great

lone sail
#

For 50 guilds you'll still be fine with just a json doc. Sqlite is the light weight database option, and is easier to migrate to something like postgres later if you do need to scale

heavy folio
#

json is bad, just use sqlite

primal token
# lone sail For 50 guilds you'll still be fine with just a json doc. Sqlite is the light wei...

If you use something like aiofiles and JSON it wouldnt really be an issue, just quite a hassle, you just would have a few limitations and no basic integrity but can be implemented, if you want a JSON like database you can always use mongodb but sqlite would be recommended as sqlites purpose is being a lightweight SQL based database and since it's based on SQL you can use the query language for other SQL based databases as you stated, postgresql

lone sail
#

My point was that with 50 guilds, it shouldn't matter what you use. It won't bottleneck on it.

#

unless you plan on writing/reading once every half a second per guild.

#

And still then... probably not

primal token
lone sail
#

They mentioned 15 variables, as long as those aren't huge datasets it wont affect anyything

north wind
#

Hello there - I'm new to Discord bots, and I'm curious about what options I could go for with this challenge-
I need a prewritten string to be posted every week - the prewritten string should vary every week, and not have duplicates until it has run through the whole list. 🙂 Any idea where I shouls start?

lone sail
#

How would you approach it yourself?

#

I could give you a possible solution out of the bat, but I don't think it would help you solve something similar in the future :)

north wind
#

I'm entirely new to discord bots, not selecting the items :).

primal token
lone sail
#

So you're good on the getting a new string every week, without showing duplicates?

#

What library are you using?

north wind
#

I'd probably write a list of strings, and then randomly use an int within range of the indexes to pick one - and then remove the entry from that list, add it to an "used" list, and if the next pick exists in the used one, reselect

#

I'm totally new to it, so I have no idea what libraries to use for Discord bots 😦

lone sail
#

Seems reasonable

#

I'd just shuffle the list once, and pop the end entry off until it's empty. But yours should work just as well

#

I can't say I'm super up to date on the libraries these days, but I know discord.py had tasks.loop which is set to run every x amount of time

#

I wouldn't trust the "x amount of time" to figure out when to post your string, so storing a datetime it should post and constantly checking if it's past that time is a bit more robust

vague zephyr
#

i'm pretty sure loops are just while not client.is_closed

#

so there isn't any amount of time

north wind
#

Okay, now I just need to know how to automate it and do it regularly.

white citrus
#

Is there a free Hosting client ?

#

Or does anyone know one?

rugged shadow
#

the best "free hosting" is your own pc

#

or any spare pc

#

if you have a raspberry pi even better

slate swan
ionic edge
#
    @commands.command()
    async def banner(self, ctx, member: discord.Member = None):
        if member is None:
            member = ctx.author
        embed = discord.Embed(
            title=f"Test",
            color=0x9C84EF
        )
        embed.set_image(url=member.banner)
        await ctx.send(embed=embed)
#

how to get the banner of a user??

naive briar
unkempt canyonBOT
slate swan
#

and i was constantly accessing the db

meager chasm
#

That what he said, they are good when you use it with async driver

vale wing
tawdry adder
#

hello, mornin!
just got a simple question please... is there a way to test things that i cant as the owner? like i want to test as a simple user or something like that if that simple-user can do something i tried blockin and etc.

gilded gust
tawdry adder
#

oke

#

and what about making commands in separated files? for ex. welcome.py , ping.py , cls.py and so on..

#

???

slate swan
#

Hey!

I have a command thats supposed to set something in sqlite

Code:
https://hastebin.com/nabalodoge.py

Error:
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'Cursor' object has no attribute 'ececute'

But my other command that looks simular if not the same doesnt error

naive briar
slate swan
#

im dumb

pulsar solstice
vocal snow
#

Pillow

#

!pypi pillow

unkempt canyonBOT
pulsar solstice
#

I am not able to get the heart overlapping the images in it

primal token
primal token
#

since it would be a clear png you can use it

#

Not sure if thats your issue or if it's related to pillow😅

slate swan
#

the heart emoji on discord is not a normal image format picture, its a svg so you won't be using that here

primal token
#

I'm pretty sure you just use inspect element and you can just ge the img from their which I've done before?

slate swan
#

that's still a svg file
and downloading a png image from internet doesn't hurt anyways

primal token
#

¯_(ツ)_/¯

#

All i know is i used it for guild emojis a long time ago

slate swan
#

again guild emojis are images, not vectorized web formats

#

reason why default emojis don't have a url

primal token
#

i know?

slate swan
#

sure.

primal token
#

ok

pliant gulch
#

It is very easy to get PNG versions of any twemoji asset, they are all public on GitHub after all

pulsar solstice
#

how to put a user's avatar in the description of a embed

#

???

glad cradle
#

also what lib are you using?

pulsar solstice
pulsar solstice
placid knot
#

embed.set_image(url=f"{member.banner.url}")

#

this isn't working form me

dull terrace
#

Is it because the person you're doing it to has no banner image

placid knot
#

they have

dull terrace
#

What's the error

placid knot
#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'url'

#

@dull terrace

dull terrace
#

Dude... It's exactly what I said it was

placid knot
dull terrace
#

member.banner = None

#

I'm telling you, it's not there, whether you have the wrong member or something

placid knot
#

he got banner right?

dull terrace
#

And your bot is in a server with the person you're getting None for member.banner?

dull terrace
#

Have you tried directly copying their id, fetching the user and then printing banner URL?

#

Then you can determine if it's something in your code or something probably with permissions

slate swan
#

!d discord.User.banner

unkempt canyonBOT
#

property banner```
Returns the user’s banner asset, if available.

New in version 2.0.

Note

This information is only available via [`Client.fetch_user()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.fetch_user "discord.Client.fetch_user").
slate swan
#

read the note

jagged inlet
rugged shadow
#

discord.os?

dull terrace
#

And why would it only work for one person and not the other with his code 7739monkathink

slate swan
#

or maybe discord.py Just doesn't save that, im unsure

pulsar solstice
#

how to check if a object is a discord.Member object or not

dull terrace
#

Why would you want to do that 8ster?

#

First way that pops into my head is doing hasattr(object, "username")

pulsar solstice
pliant gulch
#

isinstance(..., discord.Member)

pulsar solstice
dull terrace
#

Yeah is instance is much better, I forgot about that froggy_chill

pliant gulch
#

Your hasattr wouldn't have worked anyways

#

username doesn't exist in discord.py it's name and since Member inherits fields from it's underlying user it has the same attributes and more

#

So hasattr(..., "name") would've worked on Member and User

#

But they aren't the same thing, as member has more than user which isn't exactly ideal

dull terrace
#

😤

keen dust
#

Hi

meager chasm
# dull terrace 😤

well, that is because andy is very smart in the aspect of developing. so when andy explains something to someone who doesnt have the same knowledge, it may be looked at as confusing because andy is explaining something with the assumption it can be understood as simply as he/she understands the topic. so yeah it creates confusion. thats why you ask more and more. the more you ask the more you know. dont walk away misunderstanding the topic because one explanation didnt give you the knowledge needed. im sure andy would have been willing to break down the explanation.

keen dust
#

is there a way to fetch all the data from a database and display the results in one embed

dull terrace
#

Hmm, I've used isinstance before but yes Andy a smart dude doge_kek

glad cradle
dull terrace
#

I end up doing janky things because I don't think about things for long enough

keen dust
slate swan
#

Exception has occurred: TypeError
BotBase.init() missing 1 required keyword-only argument: 'intents'
File "C:\Users###\Desktop####\Discord_Bot.py", line 5, in <module>
bot = commands.Bot(command_prefix = settings['prefix'])

keen dust
#
intents = discord.Intents.all()
bot = commands.Bot(command_prefix="$", intents=intents)
#

if its nextcord

#

u also have to enable the intent permissions in the discord developer portal for the bot

slate swan
#

hmm

keen dust
keen dust
#

replace nextcord with discord

slate swan
#

Ok

keen dust
#

under applications > bot enable the intent privileges

glad cradle
shell wing
#
staff_role = 1024293502621843456
        ticket_main_channel_overides = {
            interaction.guild.default_role: discord.PermissionOverwrite(read_messages=False),
            interaction.user : discord.PermissionOverwrite(read_messages=True, send_messages=True),
        interaction.guild.staff_role : discord.PermissionOverwrite(read_messages=True, send_messages=True)}
        ticket_main_channel = await interaction.guild.create_text_channel(f"{interaction.user.name}'s channel", overwrites=ticket_main_channel_overides)

Says guild has no staff role
how do i define it ??

primal token
keen dust
#

kinda surprised me too

primal token
#

what

keen dust
primal token
#

Making a reference of Intents and using it twice isnt a part of any update?

glad cradle
keen dust
keen dust
#

its below

#
@bot.command()
async def display_bdays(ctx):
    async with aiosqlite.connect("bday.db") as db:
        async with db.cursor() as cursor:
            await cursor.execute("SELECT * FROM bd")
            data = await cursor.fetchall()
            for row in data:
                bdem2 = nextcord.Embed(title="ALL BDAYS", description="blank")
                bdem2.add_field(name="Name:", value=row[1], inline=False)
                bdem2.add_field(name="Month:", value=row[2], inline=False)
                bdem2.add_field(name="Date:", value=row[3], inline=False)
                await ctx.channel.send(embed=bdem2)

#

the main part

brazen raft
#

As per best practices, you should keep one database connection in the bot

#

Instead of connecting every time in each command or event or whatever

glad cradle
primal token
keen dust
#

oh ye, u can do that too

maiden fable
#

This is a damn nice feature

glad cradle
#

!d nextcord.ext.commands.Context.send

unkempt canyonBOT
#

await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=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` or `embeds` parameter must be provided.

To upload a single file, the `file` parameter should be used with a single [`File`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.File "nextcord.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://nextcord.readthedocs.io/en/latest/api.html#nextcord.File "nextcord.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://nextcord.readthedocs.io/en/latest/api.html#nextcord.Embed "nextcord.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://nextcord.readthedocs.io/en/latest/api.html#nextcord.Embed "nextcord.Embed") objects. **Specifying both parameters will lead to an exception**.
maiden fable
#

Python bot when nextcord docs requested: Wait, what the fuck is that

glad cradle
#

I have never used nextcord, luckily the structure has not changed

maiden fable
slate swan
#
import asyncio, websockets, discord
from discord.ext import commands
bot = commands.Bot(command_prefix='!', intents=discord.Intents.all())

async def handler(websocket, path):
    await websocket.send("hello")
ws = websockets.serve(handler, "localhost", 8000)

@bot.command()
async def crash(ctx):
    print("detected crash command")
    # await ws.send("hello") doesnt work

bot.run("bot token")
asyncio.get_event_loop().run_until_complete(ws)
asyncio.get_event_loop().run_forever()
```So basically i want to send a message to websocket when a command is fired
glad cradle
#

everything under bot.run is not executed when the bot is online

#

!d discord.ext.commands.Bot.run

unkempt canyonBOT
#

run(token, *, reconnect=True, log_handler=..., log_formatter=..., log_level=..., root_logger=False)```
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/ext/commands/api.html#discord.ext.commands.Bot.start "discord.ext.commands.Bot.start") coroutine or [`connect()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.connect "discord.ext.commands.Bot.connect") + [`login()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.login "discord.ext.commands.Bot.login").

This function also sets up the logging library to make it easier for beginners to know what is going on with the library. For more advanced users, this can be disabled by passing `None` to the `log_handler` parameter.

Warning

This function must be the last function to call due to the fact that it is blocking. That means that registration of events or anything being called after this function call will not execute until it returns.
glad cradle
#

Read the warning

slate swan
glad cradle
#

you should create a main coroutine function and calls inside it await bot.start(...) and the other functions, then you could call the main function with the asyncio module

slate swan
#

ok i will try that.

robust fulcrum
#

Guys is there any UI improvement i should do in my game?

worn terrace
pearl fjord
#

i have a discord bot, and i'm using sys.exit() to close it because await client.close() takes ages and sometimes just does nothing, how do i stop it from giving the error raise RuntimeError('Event loop is closed') RuntimeError: Event loop is closed
i don't mean like fix the error cuz i know what it is, i just mean catch it and not print the damn error every time

pulsar solstice
#
@bot.command()
async def ship(ctx, user1=None, user2=None):
        if isinstance(user1, discord.Member):```
#

how to get the user1 name if it's a discord.Member object?

slate swan
#

user1 and user2 will always be a string or None here. never a Member

pulsar solstice
#

HELP

#

HELP

warm goblet
#

How often can I change a bot’s name and picture before it times me out?

severe rampart
#

you should just use a slashcommand tbh

#
@app_commands.command(name = "ship")
async def _ship(interaction: discord.Interaction, m1: discord.Member, m2: discord.Member) -> None:
  ...
eternal fox
severe rampart
#

that way there's no way they could supply a non member argument

slate swan
#

can someone help me with my bot

pulsar solstice
severe rampart
slate swan
severe rampart
#

because it will always be a member object in that case

severe rampart
unkempt canyonBOT
#

property member_count```
Returns the member count if available.

Warning

Due to a Discord limitation, in order for this attribute to remain up-to-date and accurate, it requires [`Intents.members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.members "discord.Intents.members") to be specified.

Changed in version 2.0: Now returns an `Optional[int]`.
pulsar solstice
severe rampart
#

why?

pulsar solstice
#

I wanna get names or member objects

#

that's why

severe rampart
#

you'll have a list

slate swan
severe rampart
#

of essentially every member in the entire guild

#

so there's no need to enter a string of any kind

slate swan
#

@severe rampart??

severe rampart
#

here's an example @pulsar solstice ^

severe rampart
pulsar solstice
severe rampart
#

no for that you have to loop through all the servers that the bot is in and add the member counts together @slate swan

slate swan
#

the bot is only in one server

severe rampart
severe rampart
pulsar solstice
#

I want this feature in my bot

slate swan
#
@tasks.loop(seconds=120)
async def change_status():
        guild = bot.get_guild(246691336776843265) 
        membercount = guild.member_count
        await bot.change_presence(status=discord.Status.dnd, activity=discord.Activity(type=discord.ActivityType.watching, name="{} members".format(membercount)))```
pulsar solstice
#

pls

severe rampart
slate swan
#

yay

#

thanks

#

found that in the code i did before a long tim,e finally

#

tysm

severe rampart
#

yw :)

slate swan
severe rampart
slate swan
#

um no

#

i will wate

slate swan
# pulsar solstice bruh pls

use typing.Union[discord.Member, str] for typehinting and then check your isinstance stuff that you were doing earlier

pulsar solstice
#

if yes then that's just common sense!!!

warm goblet
#

Can anyone tell me how often I can change my Bot’s username and picture before timing out?

slate swan
#

@severe rampart waited and still dowsnt work

slate swan
pulsar solstice
slate swan
#

import it, its an inbuilt python module...

severe rampart
#

import typing

pulsar solstice
slate swan
#

if you're using py3.10 you can do ```py
discord.Member | str

slate swan
#

bc it doesnt work

slate swan
slate swan
vocal snow
# slate swan wdym

That task loop isn't going to start on its own... You need to start it

vocal snow
#

What

slate swan
#

how to start it

vocal snow
#

That's how you run a python script

slate swan
#

yes

vocal snow
#

You need to start the task loop in your python code

slate swan
#

how

vocal snow
#

!d discord.ext.tasks.Loop.start

unkempt canyonBOT
vocal snow
#

change_status would be the Loop for you

slate swan
#

where do i put it

#

@tasks.loop(seconds=120) async def start(*args, **kwargs): guild = bot.get_guild(246691336776843265) membercount = guild.member_count await bot.change_presence(status=discord.Status.dnd, activity=discord.Activity(type=discord.ActivityType.watching, name="{} members".format(membercount)))

vocal snow
#

In your code, where you want to start the task

slate swan
#

like this?

vocal snow
#

Ok i give up @slate swan you explain

slate swan
#

no wait

#

i just started learning

#

please?

vocal snow
slate swan
#

@slate swan@pulsar solstice

pulsar solstice
#

?

#

I already know this bruh

slate swan
pulsar solstice
slate swan
#

oh

#

but can u like idk

naive briar
# slate swan how

Let's say this is a loop

@tasks.loop(...)
async def some_loop(*args, **kwargs):
    ...

Now you gotta use start to start the loop in on_ready or setup_hook

some_loop.start()
pulsar solstice
slate swan
#

i think i got it

#

so it would be like that -

#
@tasks.loop(seconds=120)
async def change_status(*args, **kwargs):
        guild = bot.get_guild(246691336776843265) 
        membercount = guild.member_count
        await bot.change_presence(status=discord.Status.dnd, activity=discord.Activity(type=discord.ActivityType.watching, name="{} members".format(membercount)))
        change_status.start()```
#

@naive briar?

naive briar
#

I'd suggest that you'll have to wait until the bot is ready before starting the loop

slate swan
#

ill see

naive briar
#

You have to start the loop for the loop to work. By putting change_status.start() in the loop will do nothing

severe rampart
#
@bot.event
async def on_ready():
  change_status.start()
#

perhaps

slate swan
#

ok i will try

slate swan
#

thank u sm.

severe rampart
#

awesome

slate swan
#

can someone help me with verify system

normal bolt
#

GM, Does anyone have any idea how I can make it so that after X time the discord buttons are removed using await button.delete() ?

keen dust
pulsar solstice
#

if I put a type hint of string and if the user enters a member then will the member object change into a str

feral frost
#

whats the new avatar_url code ?

pulsar solstice
#

I am sick of this

feral frost
#

ye same it worked like a few days ago and now it broke

#

i found it guys

#

it just like this embed.set_thumbnail(url=user.display_avatar) this is for embed btw

ocean lantern
#

so I made a bot on replit, and it's basically webscraper bot that sends message when it find what it's looking for, and for me it's manga update, and I want it run couple of times every hour, but it only checks it once when I start up the code. How can I change that?

soft heart
#

Is it possible to get the message id of a message when a button attached to the message gets pressed?

hushed galleon
grand willow
ocean lantern
#

how can I send messages on schedule?

rare echo
#

is there a way to grab a users pfp as a png?

astral ether
#

hello, I watched a video to add a drop-down menu to my bot, but by putting the module imports, it does not work 😦

slate swan
#

doed anyone knows how to install buckettype?

#
@bot.event
async def on_command_error(ctx, error):
    if isinstance(error, commands.CommandOnCooldown):
       msg = '**Still on cooldown**, please try again in {:.2f}s'.format(error.retry_after)
       await ctx.send(msg)

@bot.command(aliases=["H"])
@commands.cooldown(1,30,commands.BucketType.user)
async def h(ctx, *,message='No Reason ! ❌'):```
#

it says

#

also i did

#

from discord.ext.commands import cooldown, BucketType

slate swan
slate swan
pastel basin
#

Why does it say Choose wisely.?

#

This action is irrevocable! Why they are saying it?

#

Also should I create a application and bot on my main discord account or create an alt account?

wispy sequoia
#

does discord.app_commands.context_menu need the member and message intents? because I wanted to create one but it just doesn't show up

slate swan
maiden fable
wispy sequoia
maiden fable
#

They take upto 2 hours to sync. Discord Limitations @wispy sequoia

wispy sequoia
#

I ofc use a test guild

maiden fable
#

Did u specify the guilds kwarg?

wispy sequoia
#

?

maiden fable
#

R u registering those as global commands?

slate swan
#

Hey guys, is there away to send the modal using a command? All examples I found is that it lets you to click on a button

wispy sequoia
maiden fable
wispy sequoia
#

just style stuff, don't worry

maiden fable
# wispy sequoia yes

Registering global commands take upto 2 hours
Registering commands in certain guilds by specifying the guilds kwarg is instant

sick birch
wispy sequoia
#

stupid discord

sick birch
#

It’s doable though. I had to do it for one of my PRs

#

Hang on a sec let me find it

#

python-discord/bot#2269

lament depotBOT
sick birch
#

@wispy sequoia here I had to create a context menu from within a cog

wispy sequoia
sick birch
slate swan
#

can someone help me with verify system?

sick birch
#

Right about here

slate swan
#

!d add roles

#

can someone help me with verify system?

slate swan
wispy sequoia
slate swan
#

lmfaooooo

#

this is why i never used dpy lol. so behind on things i get that they left but still.

glad cradle
slate swan
#

does anyone knows why is it like that?

#

thats the code -

#
@bot.event
async def on_member_join(member):

    channel = bot.get_channel(1023615552477995080)

    background = Editor("pic.png")
    profile_image = await load_image_async(str(member.avatar.url))

    profile = Editor(profile_image).resize((150, 150)).circle_image()
    poppins = Font.poppins(size=50, variant="bold")

    poppins_small = Font.poppins(size=20, variant="light")

    background.paste(profile, (325, 90))
    background.ellipse((325, 90), 150, 150, outline="white",stroke_width=5)

    background.text((400, 260), f"Welcome To {member.guild.name}", color="white", font=poppins, align="center")
    background.text((400, 325), f"{member.name}#{member.discriminator}", color="white", font=poppins_small, align="center")

    file = File(fp=background.image_bytes, filename="pic.png")
    await channel.send(f"Hello {member.mention}! Welcome to **{member.guild.name}** Have fun!")
    await channel.send(file=file)```
sick birch
# slate swan wtf why?

Context menus do not support group contexts (e.g. Cog or Group). This is for a few reasons.

- Within Discord itself, they cannot be bound to a group. There is no such thing as a "sub context menu" right now, and if it exists in the future it probably will not be in the same category as a Group would be.
- If added, the Group and the Cog would need to handle and maintain a mapping of context menus to eventually add back and remove from the tree. This complication and extra space doesn't seem worth it to me, especially considering you can only have 5 context menu commands anyway.
- The context menu would have to store bindings (the self parameter) which is an incredibly complicated thing to do that has been a common source of bugs within the library.

This is kind of ironic but this is one of those things that is actually significantly easier to do yourself rather than the library generalising it to fit to everyone's needs. For example, in a cog you can do the following:

class MyCog(commands.Cog):
    def __init__(self, bot: commands.Bot) -> None:
        self.bot = bot
        self.ctx_menu = app_commands.ContextMenu(
            name='Cool Command Name',
            callback=self.my_cool_context_menu,
        )
        self.bot.tree.add_command(self.ctx_menu)

    async def cog_unload(self) -> None:
        self.bot.tree.remove_command(self.ctx_menu.name, type=self.ctx_menu.type)

    # You can add checks too
    @app_commands.checks.has_permissions(ban_members=True)
    # @app_commads.guilds(12345)
    async def my_cool_context_menu(self, interaction: discord.Interaction, message: discord.Message) -> None:
        await interaction.response.send_message('hello...')

This lets you manually add the context menu to the bot tree when a cog is created. The Python runtime handles the self binding for you as well, rather than the library.

sick birch
bold kernel
#

Hi, is it possible to use selenium with discord's api ?

sick birch
bold kernel
sick birch
#

You could thread it or run on seperate processes

bold kernel
#

asyncio_tothread ?

sick birch
#

Hm?

slate swan
bold kernel
sick birch
#

If you want a more simpler, beginner friendly library, or aren't as good with Python, one of the forks may be of use

If you want more control and your bot may be complex, then discord.py may be the library for you

#

Just weigh their pros and cons with your usecase, as with most technologies in this field

slate swan
#

true

primal token
sick birch
primal token
#

The things you guys need to do to see whats wrong with an abstraction of the library is probably allot, going from a public method to an internal that has submethods which those submethods have submethods and it keeps going

livid jacinth
#

Hey, does anyone know how to send a message with a discord bot if a minecraft server turns online or offline?

slate swan
#

it is against minecraft eula though i believe well my version is

#

you would create a minecraft account. you create a bot in javascript or python where it would connect to the minecraft server. if connection is successful it sends a webhook request or a message to a discord bot to send to the server

sick birch
edgy plinth
#

Hello, im making a bot and i need a way to save into the database (replit) without preventing "heartbeat" from stopping is there anyway i can save data when the bot disconnects from discord or just regualrly?

sick birch
edgy plinth
sick birch
edgy plinth
sick birch
#

and..?

edgy plinth
#

thats async and await right?

sick birch
#

right

edgy plinth
#

it didnt work

sick birch
#

How exactly did it not work?

edgy plinth
#

i can get it to do it again 1 second

#

the heartbeat didnt pass though

#

(shard id)

sick birch
#

How are you monitoring heartbeats? You've got logging enabled?

edgy plinth
sick birch
#

Hm. If it's async, and it still does that, might just be a replit thing

edgy plinth
#

mayve

#

is there a way to detect when the bot disconnects from discord to save?

bold kernel
#

Even when bot doen't have errors or warnins, is it even possible to find the problem, for example : a for loop who doesn't work as well ?

edgy plinth
sick birch
bold kernel
edgy plinth
sick birch
edgy plinth
old token
#
            if role in after.roles:
                print("found role")
                beforeactivity = discord.utils.get(before.activities, type=discord.ActivityType.custom)
                print('1')
                if beforeactivity != afteractivity:
                    if beforeactivity and afteractivity is not None:
                        print('2')
                        if string not in afteractivity.name:
                            print('3')
                            try:
                                print('4')
                                await after.remove_roles(role, reason=f"Removed {string} from status.")
                            except:
                                traceback.print_exc()```

This code works to remove the role when the status is not None but not `string`, but if I completely remove my status, it won't remove the role
edgy plinth
sick birch
sick birch
slate swan
old token
#

it sucks rooSob

slate swan
#

make a function that checks the users custom status.

old token
slate swan
#

and return True or False

old token
#
    @commands.Cog.listener()
    async def on_presence_update(self, before, after):
        try:
            afteractivity = discord.utils.get(after.activities, type=discord.ActivityType.custom)
            beforeactivity = discord.utils.get(before.activities, type=discord.ActivityType.custom)
            if afteractivity is None:
                return
            if beforeactivity and beforeactivity.name == afteractivity.name:
                return
            record = await self.bot.db.fetchrow("SELECT role, channel, string FROM vanity WHERE guild_id = $1", after.guild.id)
            if record is None:
                return
            role, channel, string = record
            role = after.guild.get_role(role)
            channel = after.guild.get_channel(channel)
            if not any([role,channel,string]):
                return
            if channel and not role:
                pass
            if role and string:
                if afteractivity.name is not None:
                        if string in afteractivity.name:
                            try:
                                await after.add_roles(role, reason=f"Has {string} in status.")
                            except:
                                traceback.print_exc()
                        else:
                            pass
            if channel and role and string:
                    if beforeactivity != afteractivity:
                        if beforeactivity and afteractivity is not None:
                            if string in afteractivity.name:
                                try:
                                    await after.add_roles(role, reason=f"Has {string} in status.")
                                    await channel.send(embed=discord.Embed(description=f"{self.bot.yes} {after.mention}: You have been given {role.mention} for putting **{string}** in your status.", color=0x303135))
                                except:traceback.print_exc()
                    else:
                        pass
            if role in after.roles:
                print("found role")
                beforeactivity = discord.utils.get(before.activities, type=discord.ActivityType.custom)
                print('1')
                if beforeactivity != afteractivity:
                    if beforeactivity and afteractivity is not None:
                        print('2')
                        if string not in afteractivity.name:
                            print('3')
                            try:
                                print('4')
                                await after.remove_roles(role, reason=f"Removed {string} from status.")
                            except:
                                traceback.print_exc()
        except:
                traceback.print_exc()
#

my code is so bad i can't figure it out

slate swan
#

holy lmao

old token
#

I know there is easier ways, but I don't know how

primal token
#

bare exceptspithink

slate swan
old token
#

i need to rewrite all of this wanna help me lmfaooo

slate swan
#

File "application.py", line 18
REDIRECT_URI = f"{DOMAIN}/discordauth"
^
SyntaxError: invalid syntax

slate swan
old token
#

do you use presence update or member update

old token
#

it works to give the role, but not to take it

slate swan
#

make a function with that code return True if they have the required_activity return False if they dont.

#

then just check if the function is False and the member has the role

#

and if they do then remove the role

old token
#
            if role in after.roles:
                print("found role")
                beforeactivity = discord.utils.get(before.activities, type=discord.ActivityType.custom)
                print('1')
                if beforeactivity != afteractivity:
                    if beforeactivity and afteractivity is not None:
                        print('2')
                        if string not in afteractivity.name:
                            print('3')
                            try:
                                print('4')
                                await after.remove_roles(role, reason=f"Removed {string} from status.")```
#

I just want to figure out how to make it remove if there is no status at all

slate swan
#

just check if they have role and if they dont have the activity

#

thats alot of unnecessary code.

#
activity = discord.utils.get(after.activities, type=discord.ActivityType.custom)
if str(activity).lower() != string and any(role.id == int(role) for role in after.roles):
    await after.remove_roles(role)
#

@old token

slate swan
#

the users activity

#

ill fix

old token
#

no error but it wouldn't even give the role

slate swan
#

show code

slate swan
#
  File "/usr/local/lib/python3.5/dist-packages/requests/compat.py", line 11, in <module>
    import chardet
ImportError: No module named 'chardet'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "application.py", line 1, in <module>
    import requests
  File "/usr/local/lib/python3.5/dist-packages/requests/__init__.py", line 45, in <module>
    from .exceptions import RequestsDependencyWarning
  File "/usr/local/lib/python3.5/dist-packages/requests/exceptions.py", line 9, in <module>
    from .compat import JSONDecodeError as CompatJSONDecodeError
  File "/usr/local/lib/python3.5/dist-packages/requests/compat.py", line 13, in <module>
    import charset_normalizer as chardet
  File "/usr/local/lib/python3.5/dist-packages/charset_normalizer/__init__.py", line 24, in <module>
    from .api import from_bytes, from_fp, from_path, normalize
  File "/usr/local/lib/python3.5/dist-packages/charset_normalizer/api.py", line 71
    previous_logger_level: int = logger.level
                         ^
SyntaxError: invalid syntax```
#

fix

fading marlin
#

read the error

tiny ibex
slate swan
#

oh nice another disnake user

tiny ibex
slate swan
tiny ibex
#

And when I used to they were made without the help of any wrappers

torn sail
slate swan
#

he does

tiny ibex
#

Oh yeah

#

He is on 3.5

#

@torn sail what's asyncify-python?

torn sail
#

My library

tiny ibex
#

usage?

torn sail
#

Well it was to make it a bit easier to make blocking code non blocking but that got boring so I expanded it to more async related stuff

pastel basin
thorny flint
#

Why am I getting this when it reach await collection.find_one(find)

slate swan
#

fix

rugged shadow
#

you sent a screenshot of an internal server error captioned with "fix"

#

do you really expect someone to know how 😭

slate swan
#

how do i paste large amount of code

#

!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
rugged shadow
#

bruhhhh

#

show your code

slate swan
#

what part 💀

#

im not sending the whole file

rugged shadow
#

the one where you make the request to API_ENDPOINT

slate swan
#

okay 1s

robust fulcrum
slate swan
#

r = requests.post(
"{API_ENDPOINT}/oauth2/token",
data=data,
headers=headers
)

#

@rugged shadow

rugged shadow
slate swan
#

bc the f strings r gone?

rugged shadow
#

Yes

#

Without the f it's just a normal string

slate swan
#

ight, ill add them

upbeat marsh
#

If I make a command that recites one line of the verse of a song each second, would it overload the Discord API?

rugged shadow
#

you'll get ratelimited

#

but i wouldn't call it "overloading"

upbeat marsh
wispy spade
#

you'll just get ratelimited tho

dull terrace
#

5 per second per guild

#

But that's also rule of thumb, I'm sure how they calculate stuff is more complex than that

vale wing
#

Yeah there are per-route ratelimits that are private

slate swan
#

How can I sync my slash commands to every guild rather than using guild = . . .

vocal snow
#

Just sync them globally

slate swan
#

Ye... how?

naive briar
#

!d discord.app_commands.CommandTree.sync

unkempt canyonBOT
#

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

Syncs the application commands to Discord.

This also runs the translator to get the translated strings necessary for feeding back into Discord.

This must be called for the application commands to show up.
slate swan
#

How do I get the error if the bot can’t dm a user inside a command

hazy oxide
#

discord.Forbidden

ionic edge
#

i know its messed up

#

discord.ext.commands.errors.MemberNotFound: Member "890131928454410270" not found.

slate swan
#

see your parameter definition, anythinf after *will be coverted to a string by dpy

ionic edge
#

same error

slate swan
#

show your command parameters?

#

the code*

#

make sure it's like Context, member: ...

naive briar
#

Why are you fetching member? Isn't "member" already a member object?

slate swan
#

oh lol

ionic edge
#

if the member is not in guild it shows the same error

slate swan
#

how is it a member then

ionic edge
#

umm?

slate swan
#

if the user isn't in a guild, then how is it supposed to be a member of that guild. why would anyone mention someone like that

#

or you can simply typehint member as a Union of discord.Member and discord.User and discord.py will do the work for yoh

#

smh

vivid gate
#

guys

#

can anyone help me with coding a bot

#

when i want the bot to answer me how can i make it to happen

tacit prairie
#

What is that
[ERROR]: Message contents cannot be null

#

@solemn cradle

naive briar
tacit prairie
#

@naive briar that is my help cmd error

#

@naive briar i cant send the error pic in your dm

#

@vagrant crescent

rare echo
#

@tacit prairiejust send the code and the error here

slate swan
#

!rule 9

unkempt canyonBOT
#

9. Do not offer or ask for paid work of any kind.

slate swan
#

you can ask your problems while coding one and people will help with it

#

Ohhh

#

Thanks and sorry

#

Does anyone knows why is it like that

#
@bot.event
async def on_member_join(member):

    channel = bot.get_channel(1023615552477995080)

    background = Editor("pic.png")
    profile_image = await load_image_async(str(member.avatar.url))

    profile = Editor(profile_image).resize((150, 150)).circle_image()
    poppins = Font.poppins(size=50, variant="bold")

    poppins_small = Font.poppins(size=20, variant="light")

    background.paste(profile, (325, 90))
    background.ellipse((325, 90), 150, 150, outline="white",stroke_width=5)

    background.text((400, 260), f"Welcome To {member.guild.name}", color="white", font=poppins, align="center")
    background.text((400, 325), f"{member.name}#{member.discriminator}", color="white", font=poppins_small, align="center")

    file = File(fp=background.image_bytes, filename="pic.png")
    await channel.send(f"Hello {member.mention}! Welcome to **{member.guild.name}** Have fun!")
    await channel.send(file=file)```
#

Thats the code

#

whats the issue? the welcome thing?

solemn cradle
slate swan
#

Its little there

#

Its supposed to be in the middle and bigger

slate swan
# slate swan Yes

the image size is much smaller than that of the background so it appears small. resizing both images to an optimal size would be the fix

unkempt canyonBOT
#

Image.resize(size, resample=None, box=None, reducing_gap=None)```
Returns a resized copy of this image.
slate swan
#

Now i am at school so whrn ill come back ill try tysmm

#

np

onyx ravine
#

raise CommandInvokeError(exc) from exc discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'async_generator' object has no attribute 'flatten' how to solve this error in dpy2

#

@slate swan

meager chasm
slate swan
slate swan
#

hi, how to build bot using javascript?

pastel basin
#

Any good course/guide for discord bots?

slate swan
pastel basin
slate swan
pastel basin
#

What does Client do?

slate swan
#

Client represents your bot in the code

pastel basin
#

Oh.

slate swan
#

thats totally outdated

pastel basin
#

Yes.

#

Also, they are making bot in replit.

#

And that's bad, cuz replit files are public

#

unless you have bought some plans.

slate swan
pastel basin
#

This is the documentation?

slate swan
#

yes thats the doc page

slate swan
pastel basin
#

Thanks!

#

@slate swan One question.

#

How will my bot stay online forever?

slate swan
#

@slate swan

slate swan
pastel basin
#

I believe there are other ways...

#

(free)

slate swan
#

um

#

i dont know them

slate swan
slate swan
slate swan
slate swan
#

OHH

#

@slate swan

#

i did put a pfp now and it still doesnt work

#

also there r ppl w no pfp so now when they dont have a pfp then the bot will not do that?

#

you can use display_avatar

#

!d discord.User.display_avatar

unkempt canyonBOT
#

property display_avatar```
Returns the user’s display avatar.

For regular users this is just their default avatar or uploaded avatar.

New in version 2.0.
slate swan
#

instead of member.avatar.url?

#

(str(member.display.avatar))

vale wing
#

member.display_avatar.url bru

slate swan
#

yes yes

#

it worked

#

finally

slate swan
#

how to send colored text on behalf of a bot?

vagrant crest
#

hello guys

#

how can i add time duration for kick or bans

#

i create a bot but i can't find the code for it in discord.py

slate swan
vagrant crest
#

thanks bro

soft heart
#

How do i pass a variable from a button to a Modal in nextcord?

naive briar
#

Simply pass the "message_id" to the instance you are creating

await interaction.response.send_modal(
    Name(message_id)
)
soft heart
#

ok and where do i get it in the modal?

naive briar
# soft heart ok and where do i get it in the modal?

You can set the class's variables by using self.varname = var and then get them using self.varname. In your case, that will be self.message_id = message_id

def __init__(self, message_id):
    ....
    self.message_id = message_id
#

I don't know if I used the words right, but I think it can give you a fair idea

soft heart
#

I think i get it ill try

robust fulcrum
#

Guys is there any platform which provides free discord bot hosting for like 5-6 months for free?

slate swan
soft heart
#
class ModMail_Response(nextcord.ui.Modal):
    def __init__(self, message_id) -> None:
        super().__init__(
            "ModMail Response",
            timeout=900
        )
        self.question = nextcord.ui.TextInput(
            label="What is youre answer?",
            min_length=1,
            max_length=500,
            required=True,
            placeholder=f"EE"
        )
        self.add_item(self.question)
        self.message_id = message_id


    async def callback(self, interaction: nextcord.Interaction) -> None:
        print(self.message_id)



class modmail_button(nextcord.ui.View):
    def __init__(self):
        super().__init__(timeout=None)

    @nextcord.ui.button(
        label="Respond",
        style=nextcord.ButtonStyle.green,
        custom_id="respond:green"
    )
    async def report_user(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
        message_id= interaction.message.id
        
        await interaction.response.send_modal(ModMail(message_id))

here is the code again

slate swan
#

im not sure how nextcord modals work

#

!d nextcord.ui.Modal

unkempt canyonBOT
#

class nextcord.ui.Modal(title, *, timeout=None, custom_id=..., auto_defer=True)```
Represents a Discord modal popup.

This object must be inherited to create a modal within Discord.

New in version 2.0.
slate swan
#

seems fine to me

slate swan
soft heart
robust fulcrum
slate swan
#

its literally just pkg install python install dependencies and python filename

robust fulcrum
#

It says me respository under maintainence

slate swan
#

lemme check

#

you can also use pydroid fyi

robust fulcrum
#

I prefer termux

naive briar
robust fulcrum
# naive briar It works fine for me <:pithink:652247559909277706>
Get:1 https://mirrors.tuna.tsinghua.edu.cn/termux/science-packages-24 science InRelease [8011 B]    Ign:2 https://main.termux-mirror.ml stable InRelease
Ign:3 https://dl.bintray.com/grimler/game-packages-24 games InRelease
Err:4 https://dl.bintray.com/grimler/game-packages-24 games Release
  502  Bad Gateway                                Err:5 https://main.termux-mirror.ml stable Release
  Redirection from https to 'http://ww38.main.termux-mirror.ml/dists/stable/Release' is forbidden
Reading package lists... Done                     E: The repository 'https://dl.bintray.com/grimler/game-packages-24 games Release' does not have a Release file.
N: Metadata integrity can't be verified, repository is disabled now.
N: Possible cause: repository is under maintenance or down (wrong sources.list URL?).
E: The repository 'https://main.termux-mirror.ml stable Release' does not have a Release file.
N: Metadata integrity can't be verified, repository is disabled now.
N: Possible cause: repository is under maintenance or down (wrong sources.list URL?).

I got this error

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied mute to @slate swan until <t:1664375264:f> (10 minutes) (reason: discord_emojis rule: sent 25 emojis in 10s).

The <@&831776746206265384> have been alerted for review.

cerulean geyser
#

!unmute 803509687541956648

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: pardoned infraction mute for @slate swan.

slate swan
#

i just needed help..

cloud dawn
#

We're always watching 👀

cerulean geyser
slate swan
#

Okay

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied mute to @slate swan until <t:1664375499:f> (10 minutes) (reason: discord_emojis rule: sent 24 emojis in 10s).

The <@&831776746206265384> have been alerted for review.

naive briar
cloud dawn
#

lmao

cerulean geyser
#

uhoh

sly shuttle
#

Hey, someone knows how I could do a simple reminder ? :)

cerulean geyser
#

!unmute 803509687541956648

cloud dawn
#

@slate swan screenshot the question in another server and post the screenshot here.

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: pardoned infraction mute for @slate swan.

cerulean geyser
#

Sorry, I'll just paste your message if you dont mind

#

Is there any way to scrape a site then send it to bot? I wanna send that image as
🟩🟩🟩🟩🟩
🟩🟥🟩🟩🟩
🟩🟥🟩🟩🟩
🟥🟩🟩🟩🟩
🟩🟩🟩🟩🟩
Is it possible?

slate swan
#

yeah

#

its possible or nah?

cloud dawn
#

Well it's possible but is it live edited? What do you have in mind?

slate swan
cloud dawn
#

Well do you want to update the message accordingly?

slate swan
#

no

robust fulcrum
cloud dawn
# slate swan its possible or nah?

Then it is pretty viable. You would just need to use aiohttp then use asyncio.create_task (recommend to use loop) to use beautiful soup 4 (bs4) asynchronous.

slate swan
#

or video

cloud dawn
#

Depending if you need to login of course.

slate swan
#

it doesnt require any login

cloud dawn
#

@slate swan Do you code on phone only?

slate swan
#

no

slate swan
#

i code on pc too

cloud dawn
#

"You would just need to use aiohttp then use asyncio.create_task (recommend to use loop) to use beautiful soup 4 (bs4) asynchronous."

vagrant crest
cloud dawn
unkempt canyonBOT
cloud dawn
#

I recommend getting the voice channel the iterate over the members, I'd still make a check if the voice state is not None to avoid potential issues.

slate swan
cloud dawn
fossil nebula
#

geth init --datadir node1 genesis.json

robust fulcrum
naive briar
robust fulcrum
# naive briar What?

I can't get terminal like termux in fdroid
Frdroid only shows me some packages

naive briar
#

I don't understand what is only shows some packages 🫠

robust fulcrum
naive briar
#

You have to download termux from it

robust fulcrum
#

@naive briar this?

naive briar
#

Ye

robust fulcrum
#

@naive briar i have one question
How can I run file?
I did python t.py and it said no such file or directory t.py
But i have that file

naive briar
robust fulcrum
#

I even tried cd downloads/ but not worked

naive briar
#

Any errors?

robust fulcrum
#

How can I run files from my internal mobile storage?

naive briar
#

I mean by using cd

robust fulcrum
robust fulcrum
naive briar
#

What is your current directory?

slate swan
primal token
#

You can create a task, dont use requests or time as they block the event loop

pastel basin
#
import hikari 

bot = hikari.GatewayBot(token='removed')

@bot.listen(hikari.GuildMessageCreateEvent)
async def print_message(event):
    print(event.content)

bot.run()
``` It's keep on printing `None`, whenever I type something in # general in my test server.
old token
#

do you have message intents?

#

idk about hikari, but in dpy you have to specify intents

pastel basin
#

I guess you don't neeed intents in hikari.

#

I'll read their documentation.

old token
primal token
#

You can use history but it's limited afaik

old token
unkempt canyonBOT
#

loop.create_task(coro, *, name=None)```
Schedule the execution of [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine) *coro*. Return a [`Task`](https://docs.python.org/3/library/asyncio-task.html#asyncio.Task "asyncio.Task") object.

Third-party event loops can use their own subclass of [`Task`](https://docs.python.org/3/library/asyncio-task.html#asyncio.Task "asyncio.Task") for interoperability. In this case, the result type is a subclass of [`Task`](https://docs.python.org/3/library/asyncio-task.html#asyncio.Task "asyncio.Task").

If the *name* argument is provided and not `None`, it is set as the name of the task using [`Task.set_name()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.Task.set_name "asyncio.Task.set_name").

Changed in version 3.8: Added the *name* parameter.
primal token
#

Took @unkempt canyon a while, i thought it wasnt going to respond kek

pastel basin
old token
pastel basin
#

Don't really know what happened...

slate swan
#
@tasks.loop(seconds=120)
async def change_status(*args, **kwargs):
        guild = bot.get_guild(393401064264564746) 
        membercount = guild.member_count
        await bot.change_presence(status=discord.Status.dnd, activity=discord.Activity(type=discord.ActivityType.watching, name="{} members".format(membercount)))

#

why is it not working

vale wing
#

My bot is a fricking genius

vale wing
slate swan
#

its the guild id

vale wing
#

!d discord.Client.fetch_guild

unkempt canyonBOT
#

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

Retrieves a [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild "discord.Guild") from an ID.

Note

Using this, you will **not** receive [`Guild.channels`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.channels "discord.Guild.channels"), [`Guild.members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.members "discord.Guild.members"), [`Member.activity`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member.activity "discord.Member.activity") and [`Member.voice`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member.voice "discord.Member.voice") per [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member").

Note

This method is an API call. For general usage, consider [`get_guild()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.get_guild "discord.Client.get_guild") instead...
vale wing
#

Try this

vale wing
slate swan
#

where do i put that

primal token
vale wing
#

Yes he forgor the dot at the end

#

I always do

primal token
#

It's called a period.

slate swan
vale wing
#

I never studied grammar sorry

primal token
#

😡

vale wing
slate swan
vale wing
#

Microsoft blocked 22h2 in Russia but I still downloaded it lmao microsoft go take the L

slate swan
#

how can i use the voice client to play a music ?

vale wing
slate swan
#

yes

vale wing
#

!d discord.Intents.guilds

unkempt canyonBOT
slate swan
#

on_member_join()

#

i have that

vale wing
#

Are you sure the bot whose token you are authenticating with is in the guild with ID you put to fetch_guild

#

And what intents do you have enabled

slate swan
#

OHHHH

#

I FORGOT TO PUT THE TOKEN

vale wing
#

Wtf

slate swan
#

TYSM HAHAHAHHAHAHHAHAHHA

#

?

vale wing
slate swan
vale wing
#

That's illegal

slate swan
#

so is spotify supported ?

vale wing
#

Check if they have public API

#

Idk myself

slate swan
vale wing
#

I don't make music bots, but you need a service with public API

slate swan
#

oh

vale wing
#

Ok so they have it, now explore the endpoints and find out if you can search the song and then stream it

slate swan
#

ok

#

you can't make music bots for the mass

#

discord will not verify it

old token
#

    @commands.command(aliases=["img", "g"])
    #@commands.cooldown(1, 30, commands.BucketType.user)
    async def image(self, ctx, *, query):
        try:   
            api_key = "api"
            resource = build("customsearch", "v1", developerKey=api_key).cse()
            result = resource.list(q=query, cx="72281f48bb8b04598", searchType='image', safe='active').execute()
            class Menu(discord.ui.View):
                def __init__(self):
                    super().__init__()
                    self.value = None
                
                @discord.ui.button(label="next", style=discord.ButtonStyle.grey)
                async def nextbutton(self, button: discord.ui.Button, interaction: discord.Interaction):
                    self.current_p = +1
                    url = result['items'][self.current_p]['link']
                    embed = discord.Embed(color=0x303135)
                    embed.set_image(url=url)
                    await interaction.response.edit_message(embed=embed)
            view = Menu()
            current_p = view.current_p
            try:
                url = result['items'][current_p]['link']
                embed = discord.Embed(color=0x303135).set_footer(text="Powered by Google - Safemode: active")
                embed.set_image(url=url)
                await ctx.send(embed=embed, view=view)
            except:
                await ctx.send(embed=discord.Embed(description=f"{self.bot.warn} {ctx.message.author}: No **results** found for **{query}**."))
        except:
            traceback.print_exc()```

```py
    current_p = view.current_p
AttributeError: 'Menu' object has no attribute 'current_p'```

idek i guess i'm overlooking it, never used buttons before
slate swan
#

guys

#

howdo i put an emoji

#

like that the bot will send a message w emoji

honest shoal
slate swan
#

Like

honest shoal
#

yeah

slate swan
#

with \ at start

#

tysmm

honest shoal
#

no

slate swan
#

oh

honest shoal
#

and you will get an emoji

slate swan
#

it doesnt work

honest shoal
#

yup

honest shoal
slate swan
#

oh

#

then how do i make it work

#

you can also just post the unicode

#

literally just copy paste the emoji as is from emojipedia

#

if its custom then yea do that way

faint blade
#

guys someone sent me this and its a discord bot

slate swan
#

oh

honest shoal
#
.send("This is my fav. duck - ![ducky_lemon](https://cdn.discordapp.com/emojis/753353851058520256.webp?size=128 "ducky_lemon")")```
unkempt canyonBOT
slate swan
#

yes i did it

#

and it doesnt work on discord

#

because the bot doesn't have the emoji then

honest shoal
slate swan
#

yeah

honest shoal
#

windows key + .

slate swan
#

huh no i literally just copy the emoji and paste it lmao

#

but

#

this one FlashWhiteHeart

#

It is from the server

#

adn it didnt work

#

if the bot doesn't share and a server where that emoji is then it won't work

honest shoal
slate swan
#

it is from the server

#
embed = disnake.Embed(description="❎ This is a premium feature
honest shoal
slate swan
honest shoal
slate swan
#

oh

#

its animated

#

so you need to do <a:

#

oh

#

tyyy

#

ill try now

#

still doesnt work

honest shoal
slate swan
#

how do i put an access

#

is it animated?

#

yes

#

<a:theemoji:theid>

#

because ctx.respond doesn't return a message object

#

you need to get the message separately

slate swan
#

yes

#

and your sure thats the right name of the emoji?>

#

let me check

#

yes

#

:FlashWhiteHeart: