#discord-bots

1 messages Β· Page 1006 of 1

eager bough
#

then instead of client replace with bot

#
@bot.command()
#

@slate swan

#

Np bro

#

ok so

#

send ss

#
@bot.command()
@commands.has_permissions(administrator=True)
async def clear(ctx, amount: int):
  await ctx.channel.purge(limit = amount)
  await ctx.send(f"Suscessfuly deleted {amount}")
#

@flat solstice u been typing for a wile everything good??

flat solstice
#

So I set a lot of my embed colours very dynamically, take this voice state update event for example```py
@Cog.listener()
async def on_voice_state_update(
self, member: Member, before: VoiceState, after: VoiceState
):
embed = Embed(timestamp=datetime.utcnow())

if before.channel is None:  # Example of a positive log
    embed.colour = Colour.dark_teal()

if after.channel is None:  # Example of a negative log
    embed.colour = Colour.dark_magenta()
flat solstice
eager bough
#

alr cool man

eager bough
flat solstice
#

it's just standard discord.py but cool, thanks for taking a look

eager bough
#

No problem bro i will have another look to see if i missed anything

eager bough
flat solstice
#

np

eager bough
#

thanks

eager bough
stone beacon
#

If you mean transfer the on_voice_state thingy into an class that subclasses discord.Embed then no

#

You'd Have to subclass Cog and I think that's a global listener so having multiple of it across different classes might be problematic

flat solstice
# stone beacon U got a rough example of what ur talking abt?

yeah, I have this 'basse' class for all of my log embeds which ensures they all have a timestamp even if i don't declare it, I'm thinking of subclassing embed again and doing a similar thing but for the colourpy class LogEmbed(Embed): def __init__(self, *args, **kwargs): if "timestamp" not in kwargs: kwargs["timestamp"] = datetime.utcnow() super().__init__(*args, **kwargs)

#

but since, as seen in my previous example, I set the embeds colour so dynamically I'm not sure if it's possible, or even worth it, to make something likepy class PositiveLog(Embed): def __init__(self, *args, **kwargs): if "colour" not in kwargs: kwargs["colour"] = Colour.dark_teal() super().__init__(*args, **kwargs)

flat solstice
eager bough
#

Hi everyone how is today?

flat solstice
#

yeah I'm doing good today, how about you

eager bough
#

im alr

smoky cedar
#

I'm trying to code a discord bot with discord_slash library for Slash Commands. I want the bot's slash commands to work on any guild that it is in. How do I do this without needing the guild id?

If someone where to add my bot to their server, it wouldn't work unless the id was added to the code, which isn't ideal, the bot should just work when added.

Or is there a client event that can be configured for when the bot joins a new server, and I can modify my guild_ids array?

eager bough
#

To make /commands in every server.

unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

hollow agate
#

Use that @slate swan

#

Why do you have 2 ctx.send?

supple thorn
#

What is UserWarning

hollow agate
#

It sends the same thing, but twice

supple thorn
#

Also the 2nd embed looks better than the first one

#

The order?

lyric apex
#

Why don't use ctx.author?

supple thorn
#

Just use ctx.author

lyric apex
#

ctx.author

#

Yeah

#

You defined two embeds for what?

#

@slate swan bro

autumn crypt
#

is there a way to either have a task wait until the previous iteration is finished or have more than one iterations go at the same time?

lyric apex
#

LoL

#

Maybe coz you have defined two embed with same name and yeah if it works it will send 2 embeds that the user was banned @slate swan

#

Maybe You Can Send The Another Embed To The user who was banned

stone beacon
#

ohh

flat solstice
stone beacon
#

Yea that makes sense I've been doing something similar

stone beacon
lyric apex
#

Try Using The Command

#

If Any Error Then Get Back To Us

#

Did You Try?

#

Show The Ss Where Your Code Is @slate swan

#

@slate swan remove the name='ban'

#

Yes

stone beacon
eager bough
#

pls don't past my code in python server

lyric apex
#

Wait What

eager bough
#

Yeah i helped him lol

#

in dms

stone beacon
#

🀣 🀣 🀣 🀣

eager bough
#

Need proof??

flat solstice
lyric apex
#

No its not the area of judge lemon_unamused

eager bough
#

Anyways he is my friend and all i ask is for him not to send it

lyric apex
#

Ohk

stone beacon
eager bough
#

Np

#

it not that big of a problem

lyric apex
#

No Need

stone beacon
#

btw in the future it's good to add a quick try/except block to catch when member.ban throws a HTTPException or anything

supple thorn
covert garden
#

Can someone help me setup a auto recover

smoky cedar
torn sail
smoky cedar
#

Or just not support newer functionality

torn sail
#

The latter

eager bough
smoky cedar
livid hinge
#

is there something weird going on with prefix commands ?

hollow agate
oak oar
#

or are you asking about a certain bot?

livid hinge
#

weird... I reset the bot token and re-added and then the command starts working again. before that it kept saying message content intent wasn't enabled (despite working for months)

#

just wondering if they made message intent not available by default or smth

pliant gulch
#

You will probably have to manually add the intent

#

Once you do so, you can verify by running the bot & seeing or printing dict(Bot.intents)

livid hinge
#

at least that's what pip list says

pliant gulch
#

just wondering if they made message intent not available by default or smth
It wouldn't make sense to default the intent, this is because MESSAGE_CONTENT intent is privlleged

#

Discord itself just hasn't started enforcing it yet

slate swan
#

Yo greyblue92 in discord bots

quaint turret
#

hey guys out of curiosity i was wondering if the python discord bot is made from discord.py

quaint turret
#

cool

slate swan
#

Also there are some forks like disnake

supple thorn
#

not by

quaint turret
#

it would be pretty funny if it was made with discord.js or something

boreal ravine
daring olive
#

is it?

#

but we have plural bots

supple thorn
boreal ravine
#

he said python discord bot pithink

daring olive
#

and yes, we use discord.py though briefly we were on disnake until dpy's unarchival

supple thorn
daring olive
#

ah ok

quaint turret
#

anyone here know anything about remote connections and stuff with python

quaint turret
#

neither do i but im trying to make a chat room thing

#

i made a help but it seems i am being ignored

boreal ravine
quaint turret
#

ok thanks

eager bough
#

hi

supple thorn
slate swan
quaint turret
#

thats more likely cokecane

pliant gulch
quaint turret
#

thats ipc stuff right

boreal ravine
supple thorn
#

seockets?

eager bough
#

sockets

#

he meant

slate swan
eager bough
#

k

supple thorn
eager bough
#

ok then

supple thorn
pliant gulch
slate swan
eager bough
#

who is good with python

quaint turret
#

i like to think i am but in reality i havent used it in a while

#

whats your question

eager bough
#

Kinda like networking

#

i guess

quaint turret
#

yeah no i have no idea lol

#

im mainly only good with discord.py or just random basic stuff

eager bough
#

What i want is like how dank memer it would say "you got a alert by the devs type pls alert to read it" how do i do that

supple thorn
quaint turret
#

ans = num1 + num2

livid hinge
#

or first buy a computer, then install python

supple thorn
quaint turret
#

if that doesnt work throw some parentheses somewhere in it

eager bough
supple thorn
#

or are you going to send that message to their dms

slate swan
quaint turret
#

num1 = 1 num2 = 2

supple thorn
# eager bough .kinda

you could have a database with everyone's info and have piece of data called SeenAlert that's a boolean and just have that be False every time you make the global alert message

quaint turret
#

is it possible to do neural networks in python

supple thorn
#

if it's false then show the message then when they see the message make it true

quaint turret
#

thanks

eager bough
slow fog
supple thorn
pliant gulch
#

Surprisingly a lot of neural network & data-science is done in python

pliant gulch
livid hinge
# slate swan *num1 not defined*

you know what python is missing? the ability to auto declare stuff set in environment variable.. i think php actually has that

quaint turret
#

interesting

supple thorn
#

as i've been told

supple thorn
pliant gulch
#

I guess the speed is negligible then?

pliant gulch
#

I mean, if your data set is that large anyways you will probably be using some cudas

eager bough
#

so can somone help me i need sleep soon

livid hinge
#

its ok, so was that

supple thorn
eager bough
supple thorn
eager bough
#

not rlly lol

supple thorn
#

now you just have to code the logic behind that idea

supple thorn
eager bough
#

im tired ill firgure this out tomrorow ig

#

good night everyone

supple thorn
#

ok

oak oar
livid hinge
spring flax
#

Can you subclass disnake interaction?

#

Like how you do with ctx

boreal ravine
spring flax
boreal ravine
# spring flax Quick example?
class NewInteraction(disnake.Interaction):
    async def send(self, defer, **kwargs):
        if defer:
            await self.response.defer()
        await self.response.send_message(**kwargs)

disnake.Interaction = NewInteraction
slate swan
#

hi

boreal ravine
#

hello sparky

slate swan
boreal ravine
#

gtg classes

spring flax
slate swan
#

hey raven πŸ‘‹

boreal ravine
#

Subclassing copies all the inherited class's objects into the new class (unless you overwrite them in the new class)

slate swan
#

im in past

spring flax
#

Also, what the best way to stop the bot from running

boreal ravine
#

bot.close()? I don't really know

oak oar
spring flax
oak oar
#

not sure tho

sly hamlet
#

am i able to do this? async self.api.start_loop()

#

bc i keep on geting SyntaxError: invalid syntax

oak oar
#

what's that for

boreal ravine
slate swan
#

how do i set views work only 1 time

sly hamlet
#

oooo ok

oak oar
slate swan
oak oar
#

wait

boreal ravine
sly hamlet
spring flax
boreal ravine
oak oar
sly hamlet
#

It's for a library don't worry about that part

boreal ravine
spring flax
oak oar
oak oar
spring flax
boreal ravine
# slate swan example pls?
class MyView(View):
    used = False

    async def interaction_check(self, interaction):
        if hasattr(self, 'msg') and self.used:
            for item in self.children:
                item.disabled = True # what hello said earlier
            await self.msg.edit(view=self)

    @button(label='yo')
    async def yo(self, ...):
        self.used = True

view = MyView()
view.msg = ...
sly hamlet
#
class DiscordListsPost(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
        self.api = discordlists.Client(self.bot)  # Create a Client instance
        self.api.set_auth("top.gg", "token") # Set authorisation token for a bot list
            async def func():
              await self.api.start_loop()``` I know this isn't right so could someone help me out?
boreal ravine
boreal ravine
#

no, you can't await inside an normal method do ```py
async def start(self):
await self.api.start_loop()

cls = DiscordListsPost(bot)
await cls.start() # this must be inside an async function

little ether
#

define the embed variable before sending it, put the embed = ... above the ctx.send(embed=embed)

frozen patio
#

And discord.embed should be --> discord.Embed

#

Welcome

slate swan
#

disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: ValueError: too many values to unpack (expected 1)
(BAD AT JSON)

#

a = discord.Embed(title="Hi")

slate swan
boreal ravine
slate swan
# boreal ravine show full error

Ignoring exception in command g:
Traceback (most recent call last):
File "C:\Users\hp\AppData\Local\Programs\Python\Python38\lib\site-packages\disnake\ext\commands\core.py", line 169, in wrapped
ret = await coro(*args, **kwargs)
File "c:\Users\hp\Desktop\bot\giveaway.py", line 143, in giveaway
new_dict = [message.id] = list
ValueError: too many values to unpack (expected 1)

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

Traceback (most recent call last):
File "C:\Users\hp\AppData\Local\Programs\Python\Python38\lib\site-packages\disnake\ext\commands\bot_base.py", line
570, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\hp\AppData\Local\Programs\Python\Python38\lib\site-packages\disnake\ext\commands\core.py", line 920, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\hp\AppData\Local\Programs\Python\Python38\lib\site-packages\disnake\ext\commands\core.py", line 178, in wrapped
raise CommandInvokeError(exc) from exc
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: ValueError: too many values to unpack (expected 1)

boreal ravine
#

what're you tryna do

slate swan
boreal ravine
boreal ravine
#

h?

oak oar
#

put embed = discord.Embed(title='Help !', description=f'Les commandes enregistrΓ© sont :') above await ctx.send(embed=embed)

slate swan
#

but this doesnt work

#

ryuga suggest me to use update

#

so

oak oar
#

what's the list anyways

slate swan
#

str int and all

#

1st str then all int

boreal ravine
slate swan
#
with open("giveawaytime.json", "w") as f:
              json.dump(logs1, f)
boreal ravine
#

why do list and not [] though

slate swan
#
with open("giveawaytime.json") as f:
         logs1 = json.load(f)
slate swan
#

bro

#

put that embed var above ctx.send

oak oar
#

embed has to be above await ctx.send(embed=embed)

sly hamlet
slate swan
sly hamlet
#

so async await self.api.start_loop()

slate swan
#

try it out

sly hamlet
slate swan
#

try it out

slate swan
#

!d async

unkempt canyonBOT
#

8.9. Coroutines

New in version 3.5.

slate swan
#

lmao

sly hamlet
# slate swan u cant do like that

so

class DiscordListsPost(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
        self.api = discordlists.Client(self.bot)  # Create a Client instance
        self.api.set_auth("top.gg", "token") # Set authorisation token for a bot list
            async def func():
              await self.api.start_loop()```
slate swan
#

iirc when your bot gets verified

#

πŸ₯²

#

but no, hunter doesnt have it

#

you can't get it anylonger

#

that used to be a thing like 1.5yrs ago l

slate swan
#

oh yeah

#

that guy didnt know how to code and he has that badhe

#

"early" verified developer badge

#

idk why im making bots

#

too much free time to kill?

#

@sly hamlet which lauguage do u code before python

slate swan
#

😢

#

imagine having that badhe

#

flex

sly hamlet
#

Java?

unkempt canyonBOT
#

Indentation

Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.

Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.

Example

def foo():
    bar = 'baz'  # indented one level
    if bar == 'baz':
        print('ham')  # indented two levels
    return bar  # indented one level

The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.

Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines

More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation

slate swan
#

dont ping admins

sly hamlet
slate swan
#

..

#

me who causally read the message from Discord and ignored it

slate swan
#

sad life

#

πŸ₯²

slate swan
#

anyways, what would go Better with a help command? a paginated view with cogs embeds or a select menu with cogs options?

slate swan
#

now I regret opening echo bot's dashboard

#

..

slate swan
slate swan
#

i mean mix

#

like moderation menu

#

i initially made it like r danny's help command

#

and utility menu

silver agate
#

AttributeError: 'Bot' object has no attribute 'slash_command'. Did you mean: 'add_command'?
tf is this

slate swan
#

you can select different categories from the select menu and not go through every page looking for the specific options like a paginator

slate swan
#

oh hm, that makes more sense

silver agate
slate swan
#

😢

#

from universe import pycord , discord
pycord + discord = "discord.py"

#

never used pycord so uhh

#

eito help me

slate swan
slate swan
#

idk

slate swan
slate swan
# slate swan idk

you are already putting the message id in the list, and setting it to a list again*
plus you are updating the json file with a list instead of a dictionary

#

uh how do i fix it

slate swan
#

with some more lines

#

ill tell u what i want to do

#
logs1[message.id] = list
with open("giveawaytime.json", "w") as f:
              json.dump(logs1, f)
#

something like that

slate swan
#

and what is message.id?
since its an integer and json cant have integer keys

#
with open("giveawaytime.json") as f:
         logs1 = json.load(f)
slate swan
slate swan
slate swan
slate swan
#

list = [newDate,b11,a11,winlimit]

slate swan
slate swan
#

.

slate swan
slate swan
slate swan
torn sail
slate swan
#

LIST CLASS

#

TF

#

@slate swan btw there is no need to change that to str

#

it auto change it to str

slate swan
slate swan
slate swan
#

hm understandable

#

still....an average person got 4 spaces as indents so....

#

im not an average person πŸ’€

#

imagine error
json.decoder.JSONDecodeError: Expecting value: line 1 column 25 (char 24)

slate swan
slate swan
#

i thought u r calling me.. nvm

#

eito's here, he will help you

#

CHANGE UR NAM

slate swan
torn sail
#

Problem in there

slate swan
#

{"968715269822369803": [

slate swan
#

ok..

#

NO TYPO

#

WTF

#

change ur name

slate swan
#

ye

#

a json is expected to have some value.. what is the value it? lmao a list? not even closed..

#

and it is also expected to have curly brackets on both the "ends"

#

can ya just come vc? lmao πŸ’€ i'm feeling lazy to text today

slate swan
#

wait

#

ok

#

let me wear my headphones

#

tell me the languages that u know lmao

#

ok say something

#

more words

#

πŸ’€

slate swan
slate swan
#

we in DM call rn :'/

#

nah its okay, but the timing was just too right lmao

#

um hi

#

πŸ˜‚ oh gawd

slate swan
slate swan
slate swan
#

Nope

slate swan
#

Wait

#

mhm

#

back @slate swan @slate swan

slate swan
torn sail
#

You need to close the brackets

slate swan
#

^^

#

huh?

#

i didnt added that

#

its dump not me

#

....?

slate swan
slate swan
#

listen

#

ill make a video real quick

slate swan
#

wait

#

shit that recorder only record games

#

json before

#

json after

#

cuz of

#
            logs1[message.id] = noobvar
            with open("giveawaytime.json", "w") as f:
              json.dump(logs1, f)
#

OK?

#

so close those brackets and try again

#

wait

slate swan
slate swan
slate swan
slate swan
slate swan
#

hm ic

#

let me print the list real quick

#

sure

#

IMAGINE
[datetime.datetime(2022, 4, 27, 10, 23, 29, 165235), 1, 1, 3]

#

let me change it to str

#

nvmd i solved my error by myself

#

lmao

#

πŸ‘

slate swan
#

@slate swan amazing asuna pfp πŸ˜„

slate swan
#

I know that thanks looks awkward but thats all i have

#

question, anyone know how I could play music from a soundcloud link?

slate swan
maiden fable
#

IIRC sc allows streaming music

slate swan
#

You can, but breaches their terms of service

maiden fable
#

O

#

Thought it allowed

slate swan
#

There is almost no streaming platform allowing such things

slate swan
#

Those who allow it are most likely not so big and their music choice is small

slate swan
#

true.

#

Just like website scraping most likely is against terms of services of multiple platform

#

Yet the data you get is the same you could get with a normal user

boreal ravine
slate swan
#

it says it's legal if it's used for personal use.

#

And where

#

Also, Discord bots is not personal use so yeah

#

That would already be a no go

slate swan
#

Then how about using their actual player

#

(iii) You must not use any Content (other than Your Content) in any way that is designed to create a separate content service or that replicates any part of the Platform offering. (iv) You must not employ scraping or similar techniques to aggregate, repurpose, republish or otherwise make use of any Content.

to create any kind of alternative digital content service, including: any service that aggregates and streams User Content from multiple users into an on-demand listening service, or any playback experience which aggregates and streams User Content with content from other service

#

Ah I see,

#

For me SoundCloud's stance is just like YouTube - ask them directly if you're unsure

#

how

midnight gorge
#

any idea why my commands don't work? it loads all the cogs and all but commands work (2.0)

#

Im new to discord.py 2.0 so I don't know if im doing something wrong

midnight gorge
slate swan
#

Do you have an on_message event? @midnight gorge

slate swan
# maiden fable IIRC sc allows streaming music

if any service allowed doing that, it would shut down since it would bypass the ads and people would make seperate applications which queried the api and played songs from there as a result depriving the organization of ad revenue

boreal ravine
slate swan
slate swan
#

yeah buttons would be more uwu

slate swan
# midnight gorge no

Then without code and potential errors we can't make a guess, we also can't see your screen to get this information manually coffeegopher

slate swan
#

any kind of webscrapping / automation is against their Tos

boreal ravine
slate swan
# slate swan

Actually you should more likely take a look at the API terms

#

Which has

to create any kind of alternative digital content service, including: any service that aggregates and streams User Content from multiple users into an on-demand listening service, or any playback experience which aggregates and streams User Content with content from other service

In its "do not" list

slate swan
#

why this returns Nonetype?

#
msg = self.bot.get_message(id)
#

with valid id

#

Message is not in cache

#

oh ye

#
m = get_message() or await fetch_message()
#

okay

slate swan
#

Or if you use a different library it might have something like getch_message

#

getch

slate swan
#

disnake only has getch_user iirc

#

Yeah it doesn't have getch_message

slate swan
#

Has getch_user/member(s)

#

disnake doesnt have fetch_message

slate swan
#

It does

#

It's not on bot

#

..

slate swan
#

It should be done on a channel like object

#

i dont have channel but :<

#

!d disnake.TextChannel.fetch_message

unkempt canyonBOT
#

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

Retrieves a single [`Message`](https://docs.disnake.dev/en/latest/api.html#disnake.Message "disnake.Message") from the destination.
slate swan
#

~do i need channel for that ? thats the only way?

#

Yes

#

uh

slate swan
#

disnake 🐍

#

!d disnake.Client.get_message

unkempt canyonBOT
slate swan
#

If you have a Context object you can use it on that one

#

doesnt work

#

you just need the id

slate swan
slate swan
#

ohh

#

Read above....

#

well then fetch it?

#

Read again above

#

lol

vast gale
# slate swan Yeah it doesn't have `getch_message`

hi, am a disnake dev.

The reason getch_user can exist is because getting the user from cache and fetching the user from the api both require only the user ID

In the case of Messages, those are stored in the cache by message ID. But to fetch them, the channel ID is also required. For this reason, we (or anyone else) are unable to make a reliable getch_message method.

slate swan
#

Literally repeating KEKW

slate swan
# slate swan lol

maybe store the channel id with the message id or if you have a better way

slate swan
slate swan
slate swan
vast gale
slate swan
#

Ok

maiden fable
#

Oh hi arl

vast gale
#

hello hunter

slate swan
#

;-;

#

now i need to add it all over

vast gale
#

I found a race condition in interaction responses last week @maiden fable

maiden fable
#

Cool

vast gale
#

all dpy based libraries are affected unless they already patched it

maiden fable
#

O

eager bough
#

Hi, friends!

maiden fable
#

BTW did u think bout the views thing? @vast gale

vast gale
#

what views thing

slate swan
eager bough
#

@vast gale Has no roles!, Yay

slate swan
#

weird how they named it get, even tho its an api get request

maiden fable
slate swan
#

Shouldn't always make API calls either way

vast gale
slate swan
#

self.bot.fetch_channel(channel).fetch_message(id)

maiden fable
#

No

vast gale
#

!d disnake.PartialMessageable

unkempt canyonBOT
#

class disnake.PartialMessageable```
Represents a partial messageable to aid with working messageable channels when only a channel ID is present.

The only way to construct this class is through [`Client.get_partial_messageable()`](https://docs.disnake.dev/en/latest/api.html#disnake.Client.get_partial_messageable "disnake.Client.get_partial_messageable").

Note that this class is trimmed down and has no rich attributes.

New in version 2.0...
slate swan
#

uh wait

#

Don't just do API calls NotLikeThis

slate swan
#

Because cache exists and has a clear use

vast gale
#

using the http client is undocumented and could change at any time

slate swan
#

that sucks yert

eager bough
#

It is you again

slate swan
#

what do i do

#

:<

vast gale
#

if you want a message from just a channel id and message ID you can use an annoying chain of code that should have a way to simplify it but uh

slate swan
#

πŸ‘€

vast gale
#

message = await bot.get_partial_messageable(channel_id).fetch_message(message_id)

slate swan
#

wo

#

partial_messageable

#

wth is that

vast gale
#

gimme a minute

slate swan
# slate swan what do i do

well as many people already told ```py

get the channel

c = bot.get_channel(c_id)
#and fetch the message
msg= await c.fetch_message(id)

vast gale
#

okay so get_channel relies on the cache, but if the cache doesn't exist then you would want to use get_partial_messageable

eager bough
#

lol

slate swan
#

nvmd

eager bough
#

):

slate swan
eager bough
#

guess who i am?

slate swan
eager bough
#

uh

slate swan
#

i thought eito changed his name again

slate swan
eager bough
#

lemme fix thatt lol

slate swan
#

lol

vast gale
#

Please change your nickname and display avatar back to normal

vast gale
#

who else

slate swan
#

i have not added that
if someone deletes the channel or msg ;-; its pain

eager bough
#

um

#

well lemme think

#

Idk

slate swan
#

the future of this world

eager bough
#

Hi

slate swan
#

hey sparky

eager bough
#

Hey

slate swan
#

bro, why?

eager bough
#

huh?

slate swan
#

woah a jet plane just fly above my house

eager bough
#

nice

slate swan
#

heyo

eager bough
#

hi

slate swan
#

stop

eager bough
#

me

slate swan
#

yes

eager bough
#

ok

slate swan
#

!ot and grow up :exit:

unkempt canyonBOT
slate swan
#

change ur nick

maiden fable
#

I, uhhh, stop spamming u both

slate swan
#
  • pfp
eager bough
slate swan
boreal ravine
#

@slate swan @eager bough ??

maiden fable
#

And the other is Krypton

slate swan
#

lmaoo

eager bough
slate swan
blissful lagoon
#

!mute 857785190625181698 πŸ”

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied mute to @eager bough until <t:1651038084:f> (59 minutes and 59 seconds).

slate swan
#

thanks :D

maiden fable
slate swan
#

lmao

slate swan
blissful lagoon
slate swan
slate swan
#

lol

boreal ravine
#

they have bot dev badge?

silent portal
#

Hey guys! Did something change with Discord's Embeds? I can't use them for some reason.. It doesn't give me an error but the message is not being sent..
I have checked everything. Using Discord.py 2.0 btw

slate swan
boreal ravine
#

who

maiden fable
vast gale
# slate swan i have not added that if someone deletes the channel or msg ;-; its pain

so if you use get_channel, that relies on the cache. Using get_partial_messageable will always give you a channel to work with, whether it exists or not.
From these, you can use fetch_message()
Using that, you can limit it to just a single api request to determine the following

  • the channel exists and you have access
  • the message exists and you can read it
silent portal
#

strange..

silent portal
#

give me a sec

slate swan
vast gale
maiden fable
slate swan
#

why not here

maiden fable
slate swan
#

Wouldn't that count towards intentionally advertising another server

#

that server is specifically for disnake help, and there would be other core devs to help you out if they miss out

slate swan
plucky swan
#

uwu

slow fog
slate swan
silent portal
# maiden fable Show code
@bot.command()
async def banner(ctx, user: discord.Member = None):
        if user != None:
            try:
                user = await bot.fetch_user(user.id)
            except:
                pass
            try:
                banner = user.banner.url
                embed = discord.Embed(title="Banner", color=0x2c2f33)
                embed.set_image(url=banner)
                embed.set_author(name=f"{user}",
                                 url=f"https://discord.com/users/{user.id}",
                                 icon_url=f"{user.display_avatar}")
                await ctx.send(embed=embed)
            except:
                await ctx.send(
                    f"{ctx.author.mention} this user does not have a banner.",
                    delete_after=15)
slate swan
#

:<

plucky swan
#

owo

slate swan
silent portal
#

it worked before but not anymore I don't get it..

maiden fable
#

@blissful lagoon he's back

blissful lagoon
#

!mute 690812216009818112 πŸ”

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied mute to @plucky swan until <t:1651038386:f> (59 minutes and 59 seconds).

slate swan
#

:(

maiden fable
#

Wrong one

slate swan
#

no

#

Nope

#

lol

maiden fable
#

Wait

#

What the 😐

#

My brain can't process anything now

oak oar
slate swan
#

um how about getting back to topic

slate swan
#

on_error/on_command_error event

maiden fable
#

He's using bare try except

slate swan
#

why ppl bullying me :<

maiden fable
#

That's eating all the errors

fierce sand
#

hi

silent portal
oak oar
slate swan
#

ban him hes making alts

#

:(

blissful lagoon
#

!mute 853271972657758228 πŸ”

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied mute to @fierce sand until <t:1651038581:f> (59 minutes and 59 seconds).

slate swan
#

ban

slate swan
#

he will come back >:(

slate swan
blissful lagoon
#

on the off-chance that this isnt the same person: stop or we're going to assume you are

vast gale
slate swan
#

How can I connect to a voice channel?

boreal ravine
#

!d discord.VoiceChannel.connect

unkempt canyonBOT
#

await connect(*, timeout=60.0, reconnect=True, cls=..., self_deaf=False, self_mute=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Connects to voice and creates a [`VoiceClient`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceClient "discord.VoiceClient") to establish
your connection to the voice server.

This requires [`voice_states`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.voice_states "discord.Intents.voice_states").
slate swan
#

im guessing ctx.voice_client is deprecated now

boreal ravine
#

no, it's still there

vast gale
#

why? @slate swan

slate swan
#

why jets are flying above my home

boreal ravine
slate swan
#

oh no

#

probably not

boreal ravine
#

just curious

slate swan
slate swan
boreal ravine
#

o

#

!d discord.VoiceClient.play

unkempt canyonBOT
#

play(source, *, after=None)```
Plays an [`AudioSource`](https://discordpy.readthedocs.io/en/master/api.html#discord.AudioSource "discord.AudioSource").

The finalizer, `after` is called after the source has been exhausted
or an error occurred.

If an error happens while the audio player is running, the exception is
caught and the audio player is then stopped. If no after callback is
passed, any caught exception will be displayed as if it were raised.
boreal ravine
#

still there lol

slate swan
#

ded chat

dull terrace
#

poster/banner for my discord bot froggy_chill

boreal ravine
#

that looks awesome

slate swan
#

TypeError: 'ReactionIterator' object is not iterable

dull terrace
#

Thanks sifte doge_kek

maiden fable
slate swan
#
dsd = [users.id for reaction in msg.reactions if reaction.emoji == '\U0001f389' for users in reaction.users() if option == 1 for i in await msg.guild.invites() if i.inviter == users and i.uses < number]
maiden fable
#

ah

slate swan
#

@maiden fable

#

..

maiden fable
#

Uh

oak oar
#

uhhh

maiden fable
#

Sparky?

dull terrace
slate swan
#

disnake*

oak oar
slate swan
maiden fable
#

@slate swan can u use a simple for loop and see which line is erroring out?

#

@vast gale not documented?

slate swan
vast gale
slate swan
#

async for users in await reaction.users()

vast gale
#

async for *

slate swan
#
Unhandled exception in internal background task 'timer'.
Traceback (most recent call last):
  File "C:\Users\hp\AppData\Local\Programs\Python\Python38\lib\site-packages\disnake\ext\tasks\__init__.py", line 157, in _loop
    await self.coro(*args, **kwargs)
  File "c:\Users\hp\Desktop\bot\giveaway.py", line 46, in timer
    await self.endgiv(keys,a[1],a[2],a[3],a[4])
  File "c:\Users\hp\Desktop\bot\giveaway.py", line 18, in endgiv
    dsd = [users.id for reaction in msg.reactions if reaction.emoji == '\U0001f389' for users in reaction.users() if
option == 1 for i in await msg.guild.invites() if i.inviter == users and i.uses < number]
  File "c:\Users\hp\Desktop\bot\giveaway.py", line 18, in <listcomp>
    dsd = [users.id for reaction in msg.reactions if reaction.emoji == '\U0001f389' for users in reaction.users() if
option == 1 for i in await msg.guild.invites() if i.inviter == users and i.uses < number]
TypeError: 'ReactionIterator' object is not iterable
#

Isn't it the same as the AsyncIterator that is documented?

stuck lily
#

How to make this output shows in single line only?

            if i["address"] in self.currently_down:
                downtime = str(timedelta(seconds=self.currently_down[i["address"]]))
                embed.add_field(
                    name=f"{i['name']} ({i['type']})",
                    value=f":red_circle: {i['address']} ({downtime})",
                    inline=False,
                )
            else:
                embed.add_field(
                    name=f"{i['name']} ({i['type']})",
                    value=f":green_circle: {i['address']}",
                    inline=False,
                )

        await ctx.send(embed=embed) ```
vast gale
#

pretty sure no iterators are documented except for AsyncIterator

slate swan
#

Yeah that's the only one

dull terrace
#

And have them inline

slate swan
stuck lily
slate swan
#

you cant do that

#

use the embed description

#

oh yeah do that

dull terrace
#

Or two fields inline...

slate swan
#

and use the bold styling

stuck lily
#

erk... thats gonna make me sad... lemon_sentimental

slate swan
dull terrace
#

Fields appear on the same line so you put half on the first and half on the second

#

Then make the value an empty string

slate swan
stuck lily
silver agate
#
@bot.slash_command(guild_ids=[961585785226821703])
async def joined(ctx, member: discord.Member = None):
    user = member or ctx.author
    await ctx.respond(f"{user.name} ist beigetreten am / um : {discord.utils.format_dt(user.joined_at)}\r\n"
    f"Account erstellt am : {discord.utils.format_dt(user.created_at)}")

pycord before anyone is asking...
Whats wrong

#

no errors but its not working

#

πŸ™‚

ashen perch
#

hey can someone help me with this, for some reason im only able to get the output from the reaction by the person who sent the message below is my code
`usernames = []
@bot.command()
async def e(ctx, user, reaction):
tick = 'βœ…'
user.author.id
i = len(users)

message = await ctx.send("input field")
await message.add_reaction(tick)

def check(reaction, user):
    return user == ctx.author and str(
        reaction.emoji) in [tick]

while True:
    reaction, user = await bot.wait_for("reaction_add", check=check)
    if (str(reaction.emoji) == tick):
        user_data = ctx.author.id
        await ctx.send(f"add user id {user_data}")
        if user_data not in usernames:
            usernames.append(user_data)
        await ctx.send(usernames)
        print(usernames)`
maiden fable
#

error?

slate swan
#

back

#

How to make sure that the author's message is not deleted and he reply

#

example:

#

idt it's possible

#

with purge

#

I don't understand a little

#

can you edit my code?

#
@bot.command(aliases=["ΠΎΡ‡ΠΈΡΡ‚ΠΈΡ‚ΡŒ"])
@commands.has_permissions( administrator = True, manage_messages = True )
async def clear(ctx, amount: int=None):
    emb = discord.Embed( title = 'Clear', colour = discord.Color.light_grey() )
    await ctx.channel.purge(limit=int(amount))

    emb.add_field( name = 'Cleared messages :', value = amount )
    emb.set_footer( text = 'Channel was cleared administrator {}'.format( ctx.author.name ), icon_url = ctx.author.avatar_url )

    await ctx.send( embed = emb )
#

No need to use int(amount) just use amount

#

And we don't edit code for you, what do you want to get and what do you have right now?

#

I have a working cleanup code

#

but i want it not to delete the author's post

#

and answered it

tall remnant
#

Hey im having an issue with my bot not responding to messages, but everything looks fine on the code end and the dev portal end, would I ask here?

slate swan
#

See the documentation for an example for a check

#

!d disnake.TextChannel.purge

unkempt canyonBOT
#

await purge(*, limit=100, check=..., before=None, after=None, around=None, oldest_first=False, bulk=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Purges a list of messages that meet the criteria given by the predicate `check`. If a `check` is not provided then all messages are deleted without discrimination.

You must have [`manage_messages`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.manage_messages "disnake.Permissions.manage_messages") permission to delete messages even if they are your own. [`read_message_history`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.read_message_history "disnake.Permissions.read_message_history") permission is also needed to retrieve message history.

Examples

Deleting bot’s messages...
slate swan
#

thx

slate swan
#

check=......

#

needs to be a function which takes message as an argument

#
def check(msg: discord.Message):
  return <condition>``` or simply a lambda function ```py
check = lambda msg: <condition>
tall remnant
#

Ok so basically I've been having this weird issue where my bot wont work with commands anymore, just client events. Not only that but I've also reset the token (changed it in code as well) and un-invited and re-invited the bot to the server, no luck. I've checked for residual python processes on my computer and nothing popped out that was suspicious. I also restarted PC and IDE. Do note: The bot stopped working after a 24 hour active time total and 1 PC shutdown.

slate swan
tall remnant
#

I fixed it, a command was having issues and console didnt tell me

vast gale
#

& did you recently update

tall remnant
#

I fixed it, one of the commands was having an issue and the debugger didnt tell me

crimson compass
#
excercise1='a'
excercise2='b'
excercise3='c'
Use_for = excercise1 or excercise2 or excercise3
excercise="".join(random.sample(Use_for))

@client.event
async def on_message(message):
    embed = discord.Embed(
        title="**__Random Excercise:__**",
        description=(excercise),
        color=0x260af3)
    embed.set_thumbnail(
        url="https://cdn.discordapp.com/attachments/968378382595272714/968754973217263646/unknown.png")
    if message.content.startswith('.excercise'):
        await message.channel.send(embed=embed)
#

Error:
ine 62, in <module>
excercise="".join(random.sample(Use_for))
TypeError: Random.sample() missing 1 required positional argument: 'k'

slate swan
#

what to do?

vale wing
#

I have seen same dumb code yesterday

vale wing
slate swan
vale wing
slate swan
#

and it work

vale wing
#

Even the code style is bad

crimson compass
slate swan
#

second

vale wing
unkempt canyonBOT
#

random.choice(seq)```
Return a random element from the non-empty sequence *seq*. If *seq* is empty, raises [`IndexError`](https://docs.python.org/3/library/exceptions.html#IndexError "IndexError").
vale wing
#

!e

import random
a = ["yes", "no", "hohoho"]
print(random.choice(a))```
unkempt canyonBOT
#

@vale wing :white_check_mark: Your eval job has completed with return code 0.

hohoho
crimson compass
vale wing
crimson compass
#

a ok

crimson compass
# vale wing `choice` can be used with any sequence

made a few changes, code looks like this:

excercise1='a'
excercise2='b'
excercise3='c'
Use_for = [excercise1,excercise2,excercise3]
excercise=(random.choice(Use_for))

@client.event
async def on_message(message):
    embed = discord.Embed(
        title="**__Random Excercise:__**",
        description=(excercise),
        color=0x260af3)
    embed.set_thumbnail(
        url="https://cdn.discordapp.com/attachments/968378382595272714/968754973217263646/unknown.png")
    if message.content.startswith('.excercise'):
        await message.channel.send(embed=embed)
#

no errors

vale wing
#
use_for = ["a", "b", "c"]```
crimson compass
vale wing
#

And yeah you should probably learn other way of making commands

#

Idek what tutorial to recommend

crimson compass
#

the only problem is that it replies with alphabetical order

#

only with a

vale wing
#

It can't always reply with a

crimson compass
#

always

vale wing
#

Oh hold up

#

@crimson compass you need to call random.choice every time you want a new value

#

In your code you call it only once

crimson compass
#

oh

crimson compass
slate swan
#

In your event that gets executed every time

vale wing
#

In your on_message ofc but for god's sake don't make commands like this

crimson compass
#

ok

#

any tutorials

#

you recommend

vale wing
#
bot = commands.Bot(command_prefix=".")

@bot.command()
async def exercise(ctx):
    ...```
slate swan
#

They have a good guide

#

Which explains different things in more details than copying

vale wing
slate swan
#

Hi, I have the following code in my on_ready event, but the bot still doesn't change presence when I start it, why? ```py
await client.change_presence(
activity = discord.Activity(name = "this is the name",
url = "https://replit.com",
type = discord.ActivityType.custom,
state = "this is the state",
details = "this is the details",
timestamps = {"start": 1650430240, "end": 1681966240},),
status = discord.Status.idle
)

#

It change to idle mode, but not the activity.

stray carbon
#
import discord
from discord import app_commands
from discord.ext import commands

class Test(commands.Cog):
    def __init__(self, bot: commands.Bot) -> None:
        self.bot = bot
        super().__init__()
    
        @app_commands.command(name="nab")
        async def nab(self, interaction: discord.Interaction) -> None:
            await interaction.response.send_message("Hello", ephemeral=True)
    
async def setup(bot: commands.Bot) -> None:
    await bot.add_cog(Test(bot))

How to sync this bruh

stray carbon
placid skiff
#

doc is not updated

stray carbon
# placid skiff in discord.py
import discord
from discord import app_commands
from discord.ext import commands

class Test(commands.Cog):
    def __init__(self, bot: commands.Bot) -> None:
        self.bot = bot
        super().__init__()
    
        @app_commands.command(name="nab")
        async def nab(self, interaction: discord.Interaction) -> None:
            await interaction.response.send_message("Hello", ephemeral=True)

        @commands.command()
        @commands.is_owner()
        async def sync(self, ctx):
            await self.bot.tree.sync(guild=927234027277135923)
            await ctx.reply("Done")
    
async def setup(bot: commands.Bot) -> None:
    await bot.add_cog(Test(bot))

this works?

paper sluice
#

the guild should be a discord.Object

#

guild=discord.Object(id=...)

placid skiff
slate swan
#

Hi, why doesn't this come up as a game on my bot when I run it? ```py
await client.change_presence(
activity = discord.Activity(name = "this is the name",
url = "https://replit.com",
type = discord.ActivityType.watching,
state = "this is the state",
details = "this is the details",
),
status = discord.Status.idle
)

placid skiff
#

!d discord.Object

unkempt canyonBOT
#

class discord.Object(id)```
Represents a generic Discord object.

The purpose of this class is to allow you to create β€˜miniature’
versions of data classes if you want to pass in just an ID. Most functions
that take in a specific data class with an ID can also take in this class
as a substitute instead. Note that even though this is the case, not all
objects (if any) actually inherit from this class...
stray carbon
#

oh

#

raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: Forbidden: 403 Forbidden (error code: 50001): Missing Access

#

uh

stray carbon
slate swan
#

It is missing access to the resource

#

I assume the bot can't create slash commands in that guild ID or it simply is not in the guild you're trying to create commands in.

stray carbon
slate swan
#

Hello, my discord bot has some problems setting a custom status.
Here is the code:```py
client = commands.Bot(intents = discord.Intents().all(),
activity = discord.Activity(name = "this is the name",
url = "https://replit.com",
type = discord.ActivityType.watching,
state = "this is the state",
details = "this is the details"),
status = discord.Status.idle)

and here is the result:
#

Shouldn't it say something about "this is the state", "this is the details" and "https://replit.com". Also, why isn't it in IDLE?

stray carbon
slate swan
#

^

#

So what can a bot have in it's status? Just a name and a type?

slate swan
feral lichen
#

nah ive seen it before with a game somehow

slate swan
#

and url

feral lichen
#

coded in python

slate swan
feral lichen
#

yes.

slate swan
#

it aint even possible yet

#

discord doesnt allow that

#

It's not possible

slate swan
#

The API blocks you

slate swan
feral lichen
#

ehhh anythings possible but i couldnt tell you it somehow was

slate swan
#

No it's not, the API blocks you from doing it

feral lichen
#

damn that sucks i saw it πŸ’€

slate swan
#

Can the bot have buttons in it's status?

#

No

vale wing
#

Imagine that guy hacked API 😳

feral lichen
#

unless its add to server no

feral lichen
vale wing
#

Very

slate swan
# slate swan So what can a bot have in it's status? Just a name and a type?

From https://stackoverflow.com/questions/59126137/how-to-change-discord-py-bot-activity

# Setting `Playing ` status
await bot.change_presence(activity=discord.Game(name="a game"))

# Setting `Streaming ` status
await bot.change_presence(activity=discord.Streaming(name="My Stream", url="my_twitch_url"))

# Setting `Listening ` status
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name="a song"))

# Setting `Watching ` status
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="a movie"))
feral lichen
#

just make sure to define "my_twich_url"

slate swan
#

So only streaming have url?

#

Yes, and only valid streaming URLs

feral lichen
#

that i dont know but, you also have to experiment for urself lol

slate swan
#

Can normal users have buttons in their status?

vale wing
#

Yes

slate swan
#

Yes

#

how

#

Not related to Discord bots, however you can use libraries such as pypresence etc.

#

rich presence

vale wing
#

!pypi pypresence

unkempt canyonBOT
feral lichen
slate swan
slate swan
vale wing
#

Use logic

slate swan
slate swan
vale wing
#

Bots can't have buttons

#

So consequently for users

feral lichen
#

imports

vale wing
feral lichen
vale wing
#

🀝

feral lichen
#

but im pretty new to discord.py but picking up on it quickly

jaunty marten
#

why do i get this error?

slate swan
#

If you know Python, you know how to read a documentation and errors, discord.py is not rocket science

slate swan
feral lichen
#

lotta lines man

slate swan
feral lichen
#

nah really?

slate swan
feral lichen
#

dang i knew that lol

slate swan
#

...

supple thorn
placid skiff
vale wing
maiden fable
maiden fable
#

Both in docs and functionality

vale wing
#

I still can't figure out wth is django for but this is not bot related so yes

slate swan
#

Websites

slate swan
slate swan
#

YouTube is made with Django

#

the fact i never used fastapi

maiden fable
#

Flask and FastAPI are nowhere close

slate swan
vale wing
slate swan
#

There are lots, Instagram and Spotify are also with Django

vale wing
#

It's supposed to be something deeper

placid skiff
#

facebook is a mix of languages

slate swan
maiden fable
placid skiff
#

they've even made a compiler for PHP to run it faster

maiden fable
#

Let's stop this before we get warned

feral lichen
#

lets go finally got my anti spam to work

supple thorn
dusky pine
#

checking for consequent message, i'd guess

supple thorn
#

I just like seeing how people fixed their problems

vale wing
#

Sadly I'll have to shutdown it soon because no hosting service

livid elk
#

im on replit

#

can somebody help me

vale wing
livid elk
#

pip install discord

slate swan
livid elk
#

yeah i tried but same