#discord-bots

1 messages Β· Page 51 of 1

sick birch
#

Pretty sure id has to be an int

glass sapphire
#

im not good at programming

sick birch
#

You pass in your ID as an integer rather than a string

glass sapphire
#

πŸ˜„

glass sapphire
primal token
#

the heck

#

my client didnt reply to the messageducky_drawing

sick birch
sick birch
primal token
#

intents is now a required kwarg in defining a Client or a Bot.
Better wording: "intents are now a required keyword argument when initiating a Client or Bot."
You should specify to enable intents before the example so you dont cause further confusion. You shouldnt really make a gist about many topics either for quality, Its poorly explained/explained and you always redirect the user for more info, maybe just make several gists that accompany the libraries documentation, the gist is quite large and its mostly resuming the official documentation over helping users understand it. You shouldnt criticize discord.py's server for not being beginner friendly as its stated, the library is advanced and its said in the server rules to first learn python over getting spoofed.

primal token
sick birch
# primal token > intents is now a required kwarg in defining a Client or a Bot. Better wording:...

This is sort of within my domain as I'm the project lead for this stuff - I agree with most of your points, but I think we still need some quick way of pointing users in the right direction for the intents being required. Now that discord.py 2.0 is out, we get a lot of people with that question, because they're accustomed to 1.7.3 and as this is a basic error, their bot won't even start up. So instead of a guide like you mentioned, perhaps a !tag or similar?

primal token
sick birch
#

Though doesn't discord.py have a migration guide? Usually they do, I'm not sure if they have one for this update yet since it's only been about a week

primal token
#

Maybe im confusing myself with some other memory, but i do remember a guide being available

sick birch
#

If there is, there's no point in reinventing the wheel, we can just sort of summarize the important bits as a tag, and link the main part to the official docs

primal token
#

Yeah, i'm correct

slate swan
#

How can i use this intents. I couldn't understand why my project doesn't run

sick birch
junior verge
#

in dpy 2.0 you need to use a setup_hook instead of on_ready right?

sick birch
#

So one does not necessarily replace another

junior verge
#

Hm okay

slate swan
sick birch
junior verge
slate swan
sick birch
#

Well you previously shouldn't have been doing anything in on_ready except maybe printing, so if you were doing what you were supposed to be doing, it shouldn't be that big of a switch in terms of using setup_hook

sick birch
junior verge
#

That was just a question

#

Just figuring out what's the easiest way as we need slash commands like very soon :0

slate swan
sick birch
#

I think fundamentally a lot of things are going to change and we as developers just need to get used to that. This is sort of a "revolutionary" period for discord developers since we've been practically neglected for the longest time. These are some of the biggest changes we've seen in a while, so there's going to be a lot of changes

sick birch
slate swan
sick birch
#

It's plausible

junior verge
limber bison
#

List = [a,b,c]
If x in list VS , if x ==a or x == b or x == c

#

Which one i prefer

primal token
#

all fun and games until your list has 1k+ elements

limber bison
#

Like what happens at 1k

#

Or condition will be larger uf

primal token
#

literally nothing, you would just have allot of conditions

#

the usage of in is more appropriate

pliant gulch
#

I would suggest instead of constructing a list, you instead construct a set (if everything doesn't need to be ordered) Since a sets __contains__ (in) is O(1)

primal token
pliant gulch
#

That will be very rare if you don't do anything weird to your elements

#

O(n) is only possible with hash clashing

primal token
#

Mhm

sick birch
#

clash of hash

glass sapphire
dry kelp
#

i restarted vsc ofc

austere vale
#

could someone help me please? im using easy_pil

  async def rank(self, ctx, member:nextcord.Member=None):
    if member is None:
      member=ctx.author
    async with self.bot.db.cursor() as cursor:
      await cursor.execute('SELECT level FROM levels WHERE user = ? AND guild = ?',(member.id,ctx.guild.id))
      level=await cursor.fetchone()
      await cursor.execute('SELECT xp FROM levels WHERE user = ? AND guild = ?',(member.id,ctx.guild.id))
      xp=await cursor.fetchone()
      await cursor.execute('SELECT ssc FROM levels WHERE user = ? AND guild = ?',(member.id,ctx.guild.id))
      ssc=await cursor.fetchone()
      if not xp or not level or not ssc:
        await cursor.execute('INSERT INTO levels (level, xp, ssc, user, guild) VALUES (?,?,?,?,?)',(0,0,0,member.id,ctx.guild.id))
        await self.bot.commit()
      try:
        xp=xp[0]
        level=level[0]
        ssc=ssc[0]
      except TypeError:
        xp=0
        level=0
        ssc=0
      user_data ={
        'xp':xp,
        'level':level,
        'next_level_xp':100,
        'percentage':xp,
        'ssc':ssc,
      }
      background=Editor(Canvas((900,300),color='#ff6365'))
      profile_picture=await load_image_async(str(member.avatar.url))
      profile=Editor(profile_picture).resize(150,150).circle_image()
      poppins=Font.poppins(size=40)
      poppins_small=Font.poppins(size=30)
      card_right_shape=[(600,0),(750,300),(900,300),(900,0)]
      background.polygon(card_right_shape, color='#fd9fa1')
      background.paste(profile,(30,30))
      background.rectangle((30,220),width=650, height=40,color='#fd9fa1')
      background.bar((30,220),max_width=650, height=40, color='#ffb4e7',percentage=user_data['percentage'],radius=20)
      background.text((200,40),user_data['name'],font=poppins, color='#fd9fa1')
      background.rectangle((200,100),width=350,height=2, fill='#fd9fa1')
      background.text((200,130),f"Level - {user_data['level']} | XP - {user_data['xp']}/{user_data['next_level_xp']} | SSC - {user_data['ssc']}", font=poppins_small, color='#ff6365')
      file=nextcord.File(fp=background.image_bytes,filename= 'levelcard.png')
      await ctx.send(file=file)
cold sonnet
#

the last 3 issues are not related to the channel

dry kelp
cold sonnet
#

still not related

#

pip install loguru

#

but what's loguru

dry kelp
#

huh

primal token
cold sonnet
#

is it on pypi?

primal token
#

!pypi loguru

unkempt canyonBOT
dry kelp
#

its a package

#

yeh for some reasons i have it but it just wont let me start my bot saying that the package is not found lol

cold sonnet
#

how did you install it

dry kelp
#

the command they have on pypi

#

pip install loguru lol

cold sonnet
#

try running just
python Bot/main.py

dry kelp
#

yeh in fact there are some commands that i did not change to / commands yet that's why it has a few errors

#

@cold sonnet oh im kinda new to poetry... maybe because i did not add the package to poetry.lock?

slate swan
#
2022-08-22 21:52:55 INFO     discord.client logging in using static token
2022-08-22 21:52:56 INFO     discord.gateway Shard ID None has connected to Gateway (Session ID: 684d53e61f0910eca898f9d68ca27923).```
lone lichen
#

Whats server_welcoming.colours

dry kelp
#

its a irrelevant error nothing special

cold sonnet
lone lichen
#

Enable intents

slate swan
dry kelp
cold sonnet
slate swan
lone lichen
#

Is something not working?

slate swan
sick birch
# slate swan what to do ?

Enable message contents in the developer portal, then add this to your code:

intents = discord.Intents.default()
intents.message_content = True
# pass intents into your bot/client constructor
cold sonnet
#

do all

lone lichen
slate swan
primal token
cold sonnet
#

cuz he enabled it all

#

I dunno

dry kelp
#

@sick birch do u know anything about poetry? how can i add a package to poetry.lock

lone lichen
#

πŸ˜‚ ofc u gonna do all if u enabled all

primal token
#

seems redundant to me especially having the presence intent on lmao

dry kelp
#

thanks

sick birch
dry kelp
#

ah shit

#

well idk why that error shows up then

dry kelp
#

if i try running it via poetry

slate swan
#

hi chat

#

how to get roles of a user

primal token
#

!d discord.Member.roles

unkempt canyonBOT
#

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

These roles are sorted by their position in the role hierarchy.
cold sonnet
#

member.roles

slate swan
#

oh i was right then

primal token
#

and its a Member not a user lol

#

a member is a user but a user cannot have roles

lone lichen
#

We all know what they meant

primal token
#

theyre still incorrect

lone lichen
#

Lmao

slate swan
#

when will non slash command bots get executed

primal token
#

never

slate swan
#

what

#

wasn't discord enforcing slash commands???

sick birch
#

Oh, enforced?

slate swan
#

yeyey

#

i just used the word executed because like removed bla bla

sick birch
#

For bots above 70 guilds, Aug 31st. I believe, correct me if I'm wrong

slate swan
#

oh ok

#

imo slash commands look nice

primal token
#

unverified bots can still use the message content since it will be an unprivileged intent, while verified bots need to ask for the intent

slate swan
#

ok ez

#

i will still add slash commands cause they look nice

primal token
#

but its recommended you use slash commands to avoid problems

slate swan
primal token
primal token
slate swan
#

oh

#

makes sense

#

i need to download discord.py from the main branch 4 slash commands?

primal token
#

no

sick birch
#

It's on pypi

primal token
unkempt canyonBOT
sick birch
#

You should be able to just install from pip

slate swan
#

oke

limber bison
#

value = data from db

fun():
using value
fun2()
using value

like for each time for value in fun1 and fun2 python intract with db or only once

#

????????????????????????????????????????????????????//

limber bison
sick birch
#

Well it depends on how you implement it

#

The way it should be done is you need to have a global pool from which you acquire connections

dry kelp
#

robin do u know why when i run my bot using poetry it will just say module not found?

#

can't tell wtf going on lol

sick birch
#

I'm not nearly good enough with poetry to be able to answer that question, sorry

primal token
#

i really doubt thats related to poetry

dry kelp
#

it is lol

#

if i run my bot using python it will work lol

limber bison
dry kelp
#

@primal token

limber bison
#

btw i have a globle connection

dry kelp
#

doing this the only thing i can think about is a poetry issue lol

primal token
#

thats odd, you used the add command right?

sick birch
primal token
dry kelp
#

Oh yeah

#

but idk if its added into poetry.lock πŸ€”

#

nvm it is

primal token
#

it should be in poetry.lock and pyproject.toml

dry kelp
#

yep it's in both

dry kelp
#

and this is pyproject

primal token
#

have you checked the dependencies with poetry show package_name?

dry kelp
primal token
#

no no, your bots env

slate swan
#

is it respond to reply with slash commands?

dry kelp
#

?

slate swan
#

#bot-commands

primal token
dry kelp
#

oh god πŸ˜‚

primal token
#

what

dry kelp
#

its just a pain

#

dont even know exactly why this happens

slate swan
#

hey guys, how do i get the guild's image?

dry kelp
#

icon?

#

guild.icon guild.icon.url

primal token
#

@dry kelp i know your issue

dry kelp
primal token
#

you forgot to run poetry install lol

dry kelp
#

oh my

#

fucking god

primal token
#

😭

dry kelp
#

give me 1 sec πŸ˜‚

#

worked

#

LMFAO

primal token
#

haha😭

dry kelp
#

thanks a lot πŸ˜‚

primal token
#

youre welcome lolducky_party

dry kelp
#

nah it's just that i was away to my grandma and i added poetry there.. nothing was updated on my pc haha

#

i just tried getting the code from github to keep working

#

thanks a lot bro istg

primal token
#

npducky_beer

slate swan
#

hi chat

sick birch
#

Hi

slate swan
#

how do i use cooldowns?

#

i've used like afew yrs ago ```py
@commands.cooldown(1, 5, commands.BucketType.user)

sick birch
#

There’s should be a few examples on the GitHub page

slate swan
#

a ok

limber bison
#

how can i konw exituction time for a command ?

slate swan
#

ah okay, i figured it out

#

i read the type hinting

primal token
#

You mean the docstrings?

quaint epoch
cursive barn
quaint epoch
unkempt canyonBOT
quaint epoch
#

you would need to compare to datetime.datetime.utc_now()

cursive barn
slate swan
#

how can i get members roles?

full lily
slate swan
#

uh wait

#

i have to test my code first before i ask bcz this may work

#

ok my code works , but how can i get the guild's icon url?

unkempt canyonBOT
gusty shard
#
@bot.command(aliases=["f"], description='asd')
@commands.cooldown(1,1,commands.BucketType.user)
async def food(message):
    id = str(message.author.id)
    if id in data:
        num = random.randint(1,3)
        data[id]['inv']['food'] += num
        await message.reply(f"You got {num} ![food](https://cdn.discordapp.com/emojis/1011429264299675689.webp?size=128 "food") from the bush.")
    else:
        await message.reply("You don't have a MooMoo account yet.")
@food.error
async def calis_error(ctx, error):
    if isinstance(error, commands.CommandOnCooldown):
        await ctx.reply("You are on cooldown, wait {e:.1f} seconds".format(e = error.retry_after))```

what does description on  `@bot.command()` do?
cursive barn
#

pretty sure it just sets the help command description

gusty shard
#

does it have something that triggers it

#

or..?

cursive barn
#

its used in the default help command automatically

gusty shard
#

oh

#

thanks

quaint epoch
unkempt canyonBOT
#

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

These roles are sorted by their position in the role hierarchy.
slate swan
#

hi chat

#

how can i read users content in their status?

quaint epoch
#

lemme read my bots code

slate swan
#

because the .status propery of author returns dnd, online, idle

quaint epoch
#

!d discord.Member.activity

unkempt canyonBOT
#

property activity```
Returns the primary activity the user is currently doing. Could be `None` if no activity is being done.

Note

Due to a Discord API limitation, this may be `None` if the user is listening to a song on Spotify with a title longer than 128 characters. See [GH-1738](https://github.com/Rapptz/discord.py/issues/1738) for more information.

Note

A user may have multiple activities, these can be accessed under [`activities`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member.activities "discord.Member.activities").
quaint epoch
#

my activity for example would return

#

HlpMySpacKyAndKyLftToRKyIsStuck

slate swan
#

ok sweet

limber bison
#

link = links.find_one({})["link1"] ,, i want this a gobal veriable but facing error asyncio.Future' object is not subscriptable

#

should i insert it in a async funtion ?

#

with await

unkempt canyonBOT
#

Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.

A full traceback could look like:

Traceback (most recent call last):
  File "my_file.py", line 5, in <module>
    add_three("6")
  File "my_file.py", line 2, in add_three
    a = num + 3
TypeError: can only concatenate str (not "int") to str

If the traceback is long, use our pastebin.

quaint epoch
#

show code as well

#

you prolly wanna do

#
async def links():...``` and do `await link()...`
limber bison
quaint epoch
#

what's the links func?

limber bison
#

links = PAODdb['links']

#

PAODdb = get_database('discordPAOD')

quaint epoch
#

you're awaiting it?

#

do url = ok['link1']

limber bison
pliant gulch
#

link = links.find_one({})["link1"] find_one(...) returns a coroutine object which is NOT subscriptable, e.g you cannot do []

#

You have to use parenthesis to use subscript on the RETURN of the coroutine after awaiting

#

E.g ```py
(await some_coroutine(...))[...]

limber bison
#

just like color

#

in my code

#

so if change color , it will affect each and every command

pliant gulch
#

Without using the parenthesis as a way to mark precedence it'll end up subscripting the coroutine then erroring

pliant gulch
#

No

limber bison
#

now link have a data ?

pliant gulch
#

You need to use the parenthesis like I showed

#

Otherwise there is no precedence for the return to be produced first

#

Then it'll error because the coroutine object isn't subscriptable

limber bison
#

async def link():
return (await links.find_one({}))["link1"]

thissssssss

sick birch
#

yes but probably better to extract it into it's own variable, couldn't hurt and only improves readability

inner epoch
#

Is there some gradient generator from hex colors?

Lets say a person runs command -gen #fff #222 the bot gives him a gradient

Maybe using pillow

primal token
#

Its understandable to a certain level not to make a variable i would say

pliant gulch
#

There is no noticeable difference using a redundant variable or not

#

I also inspected the garabage collector and it seems fine, there is really no incentive to use a variable or not

#

I would say if you are using coroutines though I'm gonna assume you know the very basics of python, which include using parenthesis for precedence

primal token
pliant gulch
#

Strictly speaking that wouldn't be a pointer, rather a reference

primal token
pliant gulch
#

A pointer would point to a memory address where the memory for that object was allocated

#

A reference as the name suggests makes a reference to that object

#

A variable is just saying, I'm gonna be referencing to this other object that I was assigned too

#

If you wanted a "pointer" in python you'd use id for the address where the memory was allocated

#

!e ```py
print(id("foo"))

unkempt canyonBOT
#

@pliant gulch :white_check_mark: Your 3.11 eval job has completed with return code 0.

139678938100400
pliant gulch
#

And the thing which you are referencing too is different from what I was talking about

#

Reference count is a different thing, but related to garbage collection in python

primal token
#

Yeah

pliant gulch
#

Used to decide whether or not an object should be collected

primal token
#

Sorry for the awful wording that was my fault

pliant gulch
silk fulcrum
#

hi

pliant gulch
#

!e ```py
from ctypes import *

class Foo:
def foo(self) -> None:
print("bar")

py_object.from_address(id(int) + int.basicsize).value = Foo
print(type(123))

unkempt canyonBOT
#

@pliant gulch :white_check_mark: Your 3.11 eval job has completed with return code 0.

<class ''>
primal token
pliant gulch
#

That too

#

Whenever I do some cursed stuff with ctypes I usually segfault

primal token
#

kek

#

ive actually never segfaulted kek

pliant gulch
#

!e ```py
import("ctypes").py_object.from_address(0).value = 0

unkempt canyonBOT
#

@pliant gulch :warning: Your 3.11 eval job has completed with return code 139 (SIGSEGV).

[No output]
primal token
#

one line segfault kek

pliant gulch
#

Can be shorter, all you gotta do is make a pointer to un-allocated memory

primal token
#

thats literally a segfault, the accessing of an invalid/unallocated/restricted piece of memory and crashing the process

limber bison
#

how can i make a reaction check expire after a valid reaction

zealous jay
#

Could this get me rate limited?

#

it stops at 42

primal token
pliant gulch
#

To further say It can be shorten

primal token
#

thats fineducky_beer

upbeat gust
#

You'll know if you're being ratelimited

zealous jay
#

I don't see anything

#

and it stopped again

upbeat gust
zealous jay
#

yes

#

logs used to show ratelimited

#

just tried it with 0.5 seconds between bans and it doesn't pop up but still stopts at 42

cerulean shale
#

How can I check the extension of a data i am getting from an API?

#

Like only the files with jpg, jpeg, png or gif should be visible, all the other stuff shouldnt come

silk fulcrum
#

and why not from PyPI?

cold sonnet
#

dpy2 isn't on pypi

paper sluice
#

it is

cold sonnet
#

is it

zealous jay
#

Oh

paper sluice
slate swan
#

was okimii online today

zealous jay
#

Anyways, for some reason if limit was 1 it would stop at 42

cold sonnet
#

well when did that happen

zealous jay
#

I tried with like 1000 and it seems to work

cold sonnet
#

is it not beta anymore

paper sluice
cold sonnet
#

damn I'm always late to know stuff

slate swan
sick birch
slate swan
#

okimii hasn't been online in 6 days 😭

sick birch
slate swan
#

Wtf happened

cold sonnet
#

could've guessed it when I ran 2.0 on repl

paper sluice
slate swan
zealous jay
slate swan
paper sluice
cold sonnet
#

yeah it's audit logs...

slate swan
zealous jay
#

oh right lol

slate swan
#

😳

cold sonnet
#

await guild.bans()
returns you the bans

zealous jay
#

Is there a parameter to not get expired bans?

#

ah

cold sonnet
#

!d discord.Guild.bans

unkempt canyonBOT
#

async for ... in bans(*, limit=1000, before=..., after=...)```
Retrieves an [asynchronous iterator](https://docs.python.org/3/glossary.html#term-asynchronous-iterator "(in Python v3.10)") of the users that are banned from the guild as a [`BanEntry`](https://discordpy.readthedocs.io/en/latest/api.html#discord.BanEntry "discord.BanEntry").

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

Changed in version 2.0: Due to a breaking change in Discord’s API, this now returns a paginated iterator instead of a list.

Examples

Usage...
cold sonnet
#

ok I had to make sure

zealous jay
#

Its old code but i think i didn't usr bans() because id didn't return things like author

slate swan
#

@paper sluice since okimii is offline can I dm you?

cold sonnet
#

I'm still not sure about it

slate swan
#

I just need someone to look over my bad code

#

it's not dpy

sick birch
#

Sounds like a job for the help channels

slate swan
sick birch
#

I think you can do code reviews in the help channels

cold sonnet
#

changed in version 2

paper sluice
sick birch
cold sonnet
#

well it works but it returns an AsyncIterator

zealous jay
#

Idk but I had a reason to use audit logs instead of bans

slate swan
zealous jay
#

i will come back tomorrow i guess its 2 am πŸ›Œ

paper sluice
maiden fable
sick birch
slate swan
sick birch
#

source??

slate swan
#

are you lying bro

maiden fable
#

He DMed me, gonna DM u both the screenshot

slate swan
cold sonnet
#

I don't understand the correlation of personal issues and leaving discord

maiden fable
#

He just.... left, didn't even talk so yea, I wasn't able to do anything

slate swan
#

this channel is dedicated to okimii now πŸ™

zealous jay
#

oh, a ban entry only has reason and user

sick birch
#

tfw sad

slate swan
#

Man rip okimiii

zealous jay
#

bad moment

paper sluice
zealous jay
#

to be asking

maiden fable
#

Oh rip, Robin yr DMs are closed

sick birch
#

yeah i sent you an f req

paper sluice
#

gool ol robin

slate swan
#

check dms ryuga

#

Okimii was teaching me oop

#

I need to finish strong πŸ™

clever scaffold
#

πŸ˜„

sick birch
#

well that kinda killed the mood lol

#

anyways i'm off to bed, catch yall tomorrow

maiden fable
#

Cya

slate swan
cerulean shale
#

Its giving all files,.even MP4 which aren't loading in the embed

silk fulcrum
#

How do I insert like, a custom ID for a button? I was doing this ```py
def init(self):
...
n = 0
for emoji, obj in objs.items():
object_button = Button(label=obj, style=ButtonStyle.primary, emoji=emoji, custom_id=str(n))
object_button.callback = self.object_button_callback
self.add_item(object_button)
n += 1

...

async def object_button_callback(self, interaction: Interaction, _button: Button):
# use _button.custom_id
...``` but _button became an unexpected argument, so I as I see I can only have interaction. Or is the only way to make a callback for each button?

limber bison
#

async def check(reaction, user):
bal2 = await economy.find_one({"id" : user.id})
return reaction.message.id == msg.id and bal2['cash'] >=amount and str(reaction.emoji) == 'βœ…'

will async check work ?

#

any ristrection ?

silk fulcrum
silk fulcrum
limber bison
silk fulcrum
#

oh, your db is async?

limber bison
silk fulcrum
#

welp you can use asyncio.run or asyncio.get_event_loop().run_until_coplete anyways

cerulean shale
vale wing
silk fulcrum
#
async def async_check(r, u):
    ...

def check(r, u):
    return asyncio.get_event_loop().run_until_complete(async_check(r, u))```
crimson frigate
silk fulcrum
vale wing
silk fulcrum
#

so self represents View

vale wing
#

I am pretty sure the callback needs to be overridden in Button subclass, not in View

silk fulcrum
#

hm. maybe I need to subclass button...

vale wing
#

Does View even have callback

torn sail
#

Nope

vale wing
#

!d discord.ui.Button.callback

unkempt canyonBOT
#

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

The callback associated with this UI item.

This can be overridden by subclasses.
vale wing
#

See, you need to subclass Button

silk fulcrum
torn sail
#

You can use a button decorator

#

Within the view

silk fulcrum
silk fulcrum
#

that's why I was using for to add these buttons

torn sail
#

Oh well now I see how ur using them

#

Yeah subclassing is the best way

austere vale
#

whats the format for setting a command aliases in a Cog?

#

when i do @slvl.command((aliases["e","en"])) it says aliases is undefined

austere vale
#

oh nevermind i figured it out, thank you thoughh

crimson frigate
#
@commands.command(aliases = ["e","en"])
limber bison
silk fulcrum
#

beep boop baap

#

is it actually depricated

limber bison
silk fulcrum
#

well then just replace get_event_loop with new_event loop

#

oh wait no dont do that

#

new event loop for each reaction bruh

limber bison
#

not possible ?

torn sail
silk fulcrum
#

oh? didn't know about that

torn sail
#

It’s the replacement

#

get_event_loop will be an alias to it in next versions I think

limber bison
#

how can i know everything about eventloops ?

silk fulcrum
#

dude wants know everything

torn sail
unkempt canyonBOT
#
Certainly not.

No documentation found for the requested symbol.

slate swan
#

hi

torn sail
#

!d asyncio

unkempt canyonBOT
#

Hello World!

import asyncio

async def main():
    print('Hello ...')
    await asyncio.sleep(1)
    print('... World!')

asyncio.run(main())
```...
silk fulcrum
slate swan
silk fulcrum
#

I hope not mine

slate swan
#

What?

#

oh no

silk fulcrum
#

congrats

limber bison
silk fulcrum
#

cats are cute

silk fulcrum
#

dont ignore TheMaster

#

he's better than me

torn sail
torn sail
silk fulcrum
#

welp, ok)

slate swan
#

I am python not master

silk fulcrum
#

you are python?

slate swan
#

I am corn snake

torn sail
#

What is that

slate swan
silk fulcrum
torn sail
limber bison
#

on new_event_loop Command raised an exception: RuntimeError: Cannot run the event loop while another loop is running

torn sail
#

Oh wait

#

Um I had a solution a while ago but I forgot lemme find

limber bison
torn sail
#

Ok I didn’t find it but try replacing new_event_loop with get_running_loop

limber bison
#

ohh ok

#

my mistake

#

wait a sec

torn sail
#

I’m not confident it will work tho

limber bison
#

Command raised an exception: RuntimeError: This event loop is already running πŸ₯²

torn sail
#

Dang yeah I thought that would happen

silk fulcrum
#

maybe there's some other way than running async func in not async to do async check for wait_for..

torn sail
#

Ok I think there’s a good way but here’s a bad way

#
coro = async_func()

try:
    while True:
        coro.send(None)
except StopIteration as e:
    return e.value 
limber bison
torn sail
#

How to call async function in sync function while an event loop is already running

silk fulcrum
#

two masters struggling at async problem

limber bison
#

πŸ˜‚

torn sail
#

I would know this if it was concurrent.futures

#

But the problem with ur problem is that the check would block ur code

silk fulcrum
#

problem with the problem, ok

torn sail
#

Dpy async checks when

silk fulcrum
#

wait, I don't think anyone here plays geometry dash

torn sail
#

I played on friends phones

silk fulcrum
torn sail
#

I do not

silk fulcrum
#

and still didnt come out

#

but at least there was a sneak peak

vale wing
#

Do geometry dash discord bot I dare yall

silk fulcrum
#

on geometry dash oficial server

vale wing
#

Real

torn sail
#

Can bots stream?

vale wing
#

No

torn sail
#

Aww

silk fulcrum
vale wing
#

That's a shame indeed

torn sail
#

You can make so many games that way cause live screen

vale wing
#

Yeah AI playing some game and streaming to VC would be very popular

silk fulcrum
#

there is a pokemon fully remade in minecraft

#

do you think something is not possible in discord?

vale wing
#

In minecraft they remake literal 8-bit CPUs

limber bison
#

whats pre-invoke command check ?

torn sail
limber bison
winged dock
#
@bot.command()
async def c(ctx, arg:str):
    if ctx.channel.id!=1011497323815239770:
        cchannel=discord.Embed(title=f"``{ctx.message.content}`` has been used in a invalid channel",description="Please try again ! [#1011497323815239770](/guild/267624335836053506/channel/1011497323815239770/)",color=0xffff00)
        await ctx.send(embed=cchannel)
        return
        await ctx.reply(f"disc.gg/{arg}")
#

its not sending it at all.

silk fulcrum
#

spacessss

winged dock
#

ive checked over the code and im not sure what the issue is since it runs fine

winged dock
silk fulcrum
#

not sending what?

silk fulcrum
torn sail
#

I’m on phone so it’s hard to read

winged dock
#

its fine hol up

silk fulcrum
#

return
await ctx.reply

torn sail
#

Yeah I wasn’t sure if that was discord mobile having shitty code blocks or an indentation problem

silk fulcrum
#

unindent ctx.reply and gud

#

and now we start doing shit

torn sail
#

Add await interaction.response.defer() in the button callbacks

winged dock
#
@bot.command()
async def c(ctx, arg:str):
    if ctx.channel.id!=1011497323815239770:
        cchannel=discord.Embed(title=f"``{ctx.message.content}`` has been used in a invalid channel",description="Please try again ! [#1011497323815239770](/guild/267624335836053506/channel/1011497323815239770/)",color=0xffff00)
        await ctx.send(embed=cchannel)
        return
        await ctx.reply(f"disc.gg/{arg}")β€Š
#

Still doesnt work

slate swan
silk fulcrum
#

well there is only one big mistake

#

that reply is unreachable

torn sail
slate swan
#

yeah

winged dock
#

Yup

#

Its a vanity checker i made thats it

#

You just type !c then the vanity u wanna check

#

doesnt break terms and its obv not malicious

slate swan
#

``def runGiveTokens(amount: int):
if amount % 1 != 0:
amount += 1

tokens = get_all_tokens("tokens.txt")
all_data = []
tokens_checked = 0
actually_valid = 0
give_token = 0
for token in tokens:
    s, headers = get_headers(token)
    profile = validate_token(s, headers)
    tokens_checked += 1

    if profile != False:
        actually_valid += 1
        data_piece = [s, token, headers, profile]
        all_data.append(data_piece)
        print(f"{Fore.GREEN} > {Fore.WHITE}{profile}")
    else:
        pass
for data in all_data:
    lines = 0
    s, token, headers, profile = get_items(data)
    if give_token >= amount:
        with open('tokens.txt') as f:
            for line in f:
                lines += 1
                contents = f.readlines(amount)
                removeToken(token)
                makeUsed(token)

@bot.slash_command(guild_ids=[settings["guildID"]], name="givetoken",
description="Allows you to give tokens to an buyer.")
async def token(ctx: discord.ApplicationContext,
amount: discord.Option(int, "Number of tokens to give.", required=True)):
if not isAdmin(ctx):
return await ctx.respond("Only Bot Admins can use this command.")
if isAdmin(ctx):
await ctx.respond("Started, this could take a while.")
runGiveToken(amount)
return await ctx.edit(f"{contents}")``

I want to make an command with
/givetokens (AMOUNT) And then he send the amount of tokens from an txt file

#

But it does not work

silk fulcrum
#

!rule 5

unkempt canyonBOT
#

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

vale wing
#

It doesn't work because of your naming conventions 100%

drowsy prairie
#

How do I save my previous data when the bot is shut down and bring it back the next time the bot is turned on?

silk fulcrum
#

cache?

vale wing
#

Recommended to use a database

#

For some data json might be suitable

lone lichen
cerulean shale
#
 "ratings": [
  {
   "source": "Internet Movie Database",
   "value": "7.9/10"
  },
  {
   "source": "Rotten Tomatoes",
   "value": "94%"
  },
  {
   "source": "Metacritic",
   "value": "79/100"
  }
 ]

this is a part of an api and i want to get all three of them, ik how to get first one but have 0 idea about the next two

shrewd apex
west veldt
#

um hi i coded a Dm command thing in by bot and i wanted it to delete the message that the bot sends as a successful dm that is like Dm has beeen sent

@bot.command()
@has_permissions(administrator=True)
async def sendDm(ctx, member: discord.Member, message):
    userDm = await member.create_dm()
    await ctx.send(embed=discord.Embed(
        description=f"** :tick: DM has been sent to {member.display_name}**",
        color=0xffff00))
    await userDm.send(message)
    await asyncio.sleep(5)
    await message.delete(message)```
#

File "main.py", line 23, in sendDm
await message.delete(message)
AttributeError: 'str' object has no attribute 'delete

#

can someone help me please

deep osprey
#

I guess ctx.message.delete()

west veldt
#

o

silk fulcrum
#

or wait

#

what message do you want to delete? @west veldt

deep osprey
#

The cmd author?

west veldt
#

the message that the bot sent

silk fulcrum
#

or that one DM has been sent?

west veldt
#

in server

silk fulcrum
#

well anyways delete_after is for that

#
await ctx.send(embed=myCoolEmbed, delete_after=5)``` will delete the message after 5 seconds @west veldt
deep osprey
silk fulcrum
#

By the way, you'd better use slash commands if this bot is not going to be private @west veldt

silk fulcrum
#

because message content is becoming priveleged since august 31

west veldt
#

aah

#

hmm

#

can u send me a website or a file where i can learn that

#

please

west veldt
silk fulcrum
#

❔

west veldt
#

is it good??

silk fulcrum
#

what do you want me to rate?

west veldt
#

no no no

vocal snow
#

Doesn't follow pep8 2/10

silk fulcrum
#

then what do you want me to say

drifting arrow
#

Can you please use the proper format to send code @west veldt

west veldt
#
ret = await coro(*args, **kwargs)
  File "main.py", line 18, in sendDm
    await ctx.send(embed=discord.Embed(
TypeError: __init__() got an unexpected keyword argument 'delete_after'```
silk fulcrum
#

check closing brackets

#
await ctx.send(embed=Embed(..., delete_after=5))```
west veldt
#

i did now

#

im dumb-

silk fulcrum
#

it should be outside, to be a kwarg of send

drifting arrow
#

Another way to do delete is to send the message as a variable and do β€œmy message.delete(delay=5)”

drifting arrow
#

I’m in mobile so I have a valid excuse for my bad format

drifting arrow
silk fulcrum
#

well yes, but he doesn't want to edit it

#

if im not mistaking

drifting arrow
#

It doesn’t matter which way he uses. Both are valid

#

Your way isn’t the only way

silk fulcrum
#

πŸ—Ώ

vale wing
silk fulcrum
west veldt
#

bruh it messed up with my purge command File "main.py", line 30, in purge await ctx. channel. purge(limit=amount + 1 , delete_after = 10) TypeError: purge() got an unexpected keyword argument 'delete_after

vale wing
#

Why do something that can be done with a kwarg with additional statement

#

Kwarg already does that

drifting arrow
#

Less lines is not always easier to read. There are examples online where less does not always mean better.
And in this case an extra line does not matter much

silk fulcrum
#

it's deleting a message

#

and you are doing it in purge

west veldt
#
@bot.command()
@has_permissions(administrator=True, manage_messages=True)
async def purge(ctx, amount=5):
        await ctx. channel. purge(limit=amount + 1 , delete_after = 10)
        await ctx.send(embed=discord.Embed(description=f":tick: successfully deleted {amount} messages in {ctx.channel}", color=0x2E08CB))```
#

i didnt even used delete_after here

silk fulcrum
#

in .purge

#

which is wrong

west veldt
#

oh wait

silk fulcrum
#

if you want to delete the sent message why would you put it in purge

west veldt
#

i get it

drifting arrow
west veldt
drifting arrow
silk fulcrum
#

slashpurge 10

vale wing
drifting arrow
#

Not that much different to a regular conmand when programming

silk fulcrum
#

interaction instead of ctx

west veldt
#

yes

silk fulcrum
#

app_commands instead of ext.commands

drifting arrow
#

And @strange knoll_command instead of bot

drifting arrow
#

I know I pinged someone. His fault not my mistake

#

Lol

drifting arrow
glad cradle
drifting arrow
glad cradle
#

PEP 8 is a thing

silk fulcrum
#

a little bit of space:
play_again = Button ( label = "Play again" , style = ButtonStyle . primary , emoji = 'πŸ”' )

drifting arrow
# glad cradle PEP 8 is a thing

Pepper pig can go sit in a corner. If it makes it easier for him to read he can use it. As long as it works it is all that matters

glad cradle
#

he can read and understand it now, not in 2 weeks

drifting arrow
#

Relax. He is clearly inexperienced. He is probably not doing this professionally yet and just wants to learn the basics. He can learn about pepper pig another time

glad cradle
#

I'm relaxed lmao, it's a suggestion

drifting arrow
#

A little bit of space is not an issue if the code works and can be read

#

You attacked him

glad cradle
#

where

drifting arrow
#

A suggestion or helpful comment would be β€œhey you don’t need spaces in your variables” and perhaps provide an example

slow fog
glad cradle
#

why you're making a fuss

drifting arrow
#

You’re the one bring pepper pig into this

silk fulcrum
#

Code should also be understandable for others, that's very important in programming. And if everyone follow some guide of code looking like PEP 8
Like.. try to read thispy try: e = Embed ( title = "Cat" , color = Colors . random () , timestamp = ctx . message . created_at ) e . set_author ( name = ctx . author , icon_url = ctx . author . display_avatar . url ) e . set_image ( url = await self . bot . alex_api . cats () )

silk fulcrum
drifting arrow
#

Wait. β€œE . Set_author” works?

silk fulcrum
#

imagine

drifting arrow
#

With the spaces

slow fog
#

yes

drifting arrow
#

Awesome

glad cradle
drifting arrow
#

Today I learned

silk fulcrum
glad cradle
vale wing
#

Better to accustom yourself to follow guidelines rather than to rewrite 6k lines of code trust me, if some issues can be fixed by the formatters, like bad spaces or smth, the names can't be

silk fulcrum
#

it works!!

vale wing
#

No wayy

shrewd apex
#

?

glad cradle
drifting arrow
#

If I was home I’d be editing some code just to annoy the anti-space people

vale wing
glad cradle
drifting arrow
#

6 seems more than meaner 1.2k project 😦

#

Stupid phone

#

Fuck it autocorrects runs me life now

#

Whatever it puts is whatever I says

silk fulcrum
#

alright, I got my RPS to work, but it says application failed each time and thinks like trash, cus it says that it's a draw when I chose rock and he chose paper

vale wing
#

I remember making RPS too for bobux bot

silk fulcrum
#

lmao

vale wing
#

Hopefully I will be able to bring the bobux back to life one day

#

It was such a nice bot 😩

#

But message content intent ruined it

silk fulcrum
#

alright, i fixed interaction failed thing with deferring

#

but it still thinks that 2 +2 = 5

silk fulcrum
dull knot
#

How would I make my bot DM the user that is provided in the argument?

#

I got stumped sad

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

Sends a message to the destination with the content given.

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

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

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

member

#

my bad

#

altho u can use user as well to send

silk fulcrum
#

btw @shrewd apex do you know who's that

dull knot
#

I'm new to Python and programming generally . So I might sound dumb when I ask this:

ctx: commands.Context What does this bit do?

silk fulcrum
#

oh i guess you do not

#

i just noticed the mutual server

shrewd apex
#

now every time i open pycharm i feel so lethargic coz the part of bot left to do is embed designing it's such a chore

shrewd apex
#

it doesn't do anything

silk fulcrum
#

it does

shrewd apex
#

python doesn't enforce type checking during runtime

#

it's only helpful for linting that's it

silk fulcrum
#

well not at runtime yeah

dull knot
#
disnake.ext.commands.errors.ExtensionFailed: Extension 'Cogs.Fun' raised an error: TypeError: <class 'disnake.ext.commands.context.Context'> is not a valid parameter annotation
ξΊ§ 

I kept getting this error

silk fulcrum
#

code?

dull knot
#
    @commands.slash_command(name="dm",
                          description="DMs target user with *Message*",
                          dm_permission=True)
    @commands.has_permissions(administrator=True)
    async def dm(self, ctx: commands.Context, user: disnake.Member, message: str):
      try:
        await ctx.user.send(message)
        await message.channel(f"DM sent to {user.name}")
      except:
        await ctx.channel.send(f"It's not working. :Sad: this msg did not send: ({message}) to {user.name}")

Here it is

dull knot
silk fulcrum
#

it's an interaction in slash commands

#

you cannot get a ctx there

dull knot
#

wym?

silk fulcrum
#

slash commands give disnake.Interaction

dull knot
#

Ohhhh.. So I should replace ctx with inter?

shrewd apex
silk fulcrum
#

well you can name it anything you want but yeah inter is better, and typehint it with dinake.Interaction

dull knot
#

Alright. lemme try

#

Lemme first learn about typehint lol. That's the first I've heard of it KEKhands

unkempt canyonBOT
#

Type Hints

A type hint indicates what type a variable is expected to be.

def add(a: int, b: int) -> int:
    return a + b

The type hints indicate that for our add function the parameters a and b should be integers, and the function should return an integer when called.

It's important to note these are just hints and are not enforced at runtime.

add("hello ", "world")

The above code won't error even though it doesn't follow the function's type hints; the two strings will be concatenated as normal.

Third party tools like mypy can validate your code to ensure it is type hinted correctly. This can help you identify potentially buggy code, for example it would error on the second example as our add function is not intended to concatenate strings.

mypy's documentation contains useful information on type hinting, and for more information check out this documentation page.

shrewd apex
#

how is str gonna have a channel attribute

#

typehint it discord.TextChannel

silk fulcrum
#

bruh no

shrewd apex
#

then do channel.send

silk fulcrum
#

just use inter.channel

#

he did message for something

#

yeah, to send it

shrewd apex
#

that works too i though he was using a custom channel or something

silk fulcrum
#

no

shrewd apex
#

idk my head not working today i was awake all night studying maths πŸ’€

silk fulcrum
#

burh

#

i just dont care about school

#

i have all fives and im good with it

shrewd apex
#

my parents care ;-;

silk fulcrum
#

mine too

dull knot
#

I'll keep all these in mind guys. Thx YesSir

shrewd apex
#

kek well anyway i did good in test hopefully full i think i did get it all right

slate swan
#

πŸ₯‚asher is a genius

shrewd apex
#

i wish u more genius than me

silk fulcrum
shrewd apex
#

everyone here is a genius

silk fulcrum
#

or what's his nick

shrewd apex
silk fulcrum
#

by the way, @slate swan do you know what happened to okimii?

shrewd apex
#

he gonna know for sure

slate swan
silk fulcrum
silk fulcrum
shrewd apex
#

πŸ‘€

shrewd apex
#

sarth keeping us in suspense pithink

silk fulcrum
#

burh

#

I want to know what happened to oki

#

if someone did something with him im gonna get the revengest revenge on that guy

shrewd apex
#

u think too much drama πŸ’€

#

prolly in real life stuff

silk fulcrum
shrewd apex
#

...

vocal snow
#

@slate swan @slate swan

silk fulcrum
#

how to make my bot count propetly

#

why is he thinling rock vs scissors is a loss

#

he Dumbass

shrewd apex
#

send the bot to schoolducky_drawing

silk fulcrum
#

ok

shrewd apex
#

kek pack it away and send it to school it wasn't even a question

#

no opinion required ducky_drawing

shrewd apex
#

...

silk fulcrum
#

i think he's too stupid to understand

shrewd apex
#

tru

#

tell him if he doesn't go to school u will rewrite him in js

silk fulcrum
#

bruh...

#

I don't wanna learn JS just to rewrite this dumbass

#

await guild.me.edit(nick="Always Stopping Take Me Down")

loud junco
silk fulcrum
#

idk, put it wherever you want, that's just how you change nickname

loud junco
#

even bot protests for our education measurements

silk fulcrum
#

lmao

loud junco
#

use it like how u use await ctx.send

#

anywhere inside an async func

drowsy prairie
#

ModuleNotFoundError: No module named 'google'
what is that how to fix it?

silk fulcrum
#

!pypi google

unkempt canyonBOT
silk fulcrum
#

you need to install it

drowsy prairie
#

ye i do but still have error

  File "c:\Users\asdro\OneDrive\Desktop\rustJun\rustplus-master\main.py", line 8, in <module>
    from rustplus import RustSocket
  File "c:\Users\asdro\OneDrive\Desktop\rustJun\rustplus-master\rustplus\__init__.py", line 7, in <module>
    from .api.remote.fcm_listener import FCMListener
  File "c:\Users\asdro\OneDrive\Desktop\rustJun\rustplus-master\rustplus\api\remote\fcm_listener.py", line 1, in <module>
    from push_receiver import PushReceiver
  File "C:\Users\asdro\AppData\Roaming\Python\Python38\site-packages\push_receiver\__init__.py", line 1, in <module>
    from .push_receiver import *
  File "C:\Users\asdro\AppData\Roaming\Python\Python38\site-packages\push_receiver\push_receiver.py", line 11, in <module>
    from .mcs_pb2 import *
  File "C:\Users\asdro\AppData\Roaming\Python\Python38\site-packages\push_receiver\mcs_pb2.py", line 33, in <module>
    _descriptor.EnumValueDescriptor(
  File "C:\Users\asdro\AppData\Roaming\Python\Python38\site-packages\google\protobuf\descriptor.py", line 755, in __new__
    _message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:
 1. Downgrade the protobuf package to 3.20.x or lower.
 2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).

More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates```
paper sluice
#

did you check the link?

zealous jay
#

Using guild.audit_logs() to get bans, how could I know if the ban is still active?

#

Trying to avoid using bans() because it gives too little info

#

Oh I could check if the ban from audit logs is in bans()

silk fulcrum
#

hm, I thought you can check if the user of AuditLogEntry is banned

#

but I can't find anything to check if the member is banned or not

zealous jay
silk fulcrum
#

and ban entry also doesn't provide any .extra stuff

junior verge
#

Does anyone have expierence with vps that could help me? its about my bot so its dpy related

silk fulcrum
junior verge
#

Yeah I know

slate swan
red blade
#

does anybody know a bot that can create a one time use invite rather than having to do it manually

slate swan
grim oar
#

Where is okmi

silk fulcrum
paper sluice
silk fulcrum
#

Google must have an answer on your question :lmao:

silk fulcrum
#

sarth and noid say they know, but don't tell me(

paper sluice
#

no, hunter probably does, you can ask him

silk fulcrum
#

@maiden fable why okimii left?

vocal snow
#

Not related to discord bot development though

slate swan
#

This is the python discord server sir

winged dock
#
from colorama import Fore, Style
import time
import time
tokem="ok"
bot = commands.Bot(command_prefix='!',
intents=discord.Intents.all())
@bot.command()
async def clear(ctx):
    await ctx.send("Clearing all channels...")
    time.sleep(0.9)
    guild = ctx.guild
    for channel in guild.channels:
        try:
            await channel.delete()
bot.run(token)
#

someone tell me why the last line shows errors?

silk fulcrum
#

tokem

#

but you use token

winged dock
#

ik its not that

silk fulcrum
#

so spotable

winged dock
#

dw

#

its not that its just were ive cut out the token @silk fulcrum

silk fulcrum
#

you are having a variable named tokem

#

and you use token

winged dock
#

no...

#

you dont get it...

silk fulcrum
#

then what is the error?

winged dock
#

Its spelt right omg 😭 just spelt tokem bc ive cut out the token

#

the last line.

silk fulcrum
#

what's the error

winged dock
#

bot.run(token)

silk fulcrum
#

!traceback

unkempt canyonBOT
#

Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.

A full traceback could look like:

Traceback (most recent call last):
  File "my_file.py", line 5, in <module>
    add_three("6")
  File "my_file.py", line 2, in add_three
    a = num + 3
TypeError: can only concatenate str (not "int") to str

If the traceback is long, use our pastebin.

winged dock
#

unident

#

Error

silk fulcrum
#

Please provide the full traceback for your exception in order to help us identify your issue.

uncut jacinth
#

Hello, I want to do a button within a command, but how should i do it because i dont want to make an extra class for it.

winged dock
#

@silk fulcrum

silk fulcrum
#

can you send full traceback? @winged dock

winged dock
#

Im testing stuff out whilist im away from my pc if you wonder why im on a android

silk fulcrum
#

cus error says 18

winged dock
#

Yes.

#

oh mb line 18

#

its just the last line idk why

hazy oxide
#

Unexpected space/tab

winged dock
#

bot.run shouldnt be indented

silk fulcrum
#

have you ever seen that before?

winged dock
#

I havent.

#

Ever.

hazy oxide
#

what's your code?

winged dock
#
from colorama import Fore, Style
import time
token="here"
bot = commands.Bot(command_prefix='!',
intents=discord.Intents.all())
@bot.command()
async def clear(ctx):
    await ctx.send("Clearing all channels...")
    time.sleep(0.9)
    guild = ctx.guild
    for channel in guild.channels:
        try:
            await channel.delete()
bot.run(token)
silk fulcrum
#

what the heck, it just changed

winged dock
#

Not really

#

thats the newest one

silk fulcrum
#

your old imported time twice

#

and this only once

winged dock
#

Ik

silk fulcrum
#

ohhh right

pliant gulch
#

You need a try combined with an except or a finally

silk fulcrum
#

and please consider following PEP 8

winged dock
#

alr

silk fulcrum
#

and also use asyncio.sleep instead of time.sleep

winged dock
#

Ive fixed it

maiden fable
silk fulcrum
pliant gulch
#

πŸ€”

paper sluice
slate swan
#

!intents

unkempt canyonBOT
#

Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default discord.py has all intents enabled except for Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, and to get members' statuses.

To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.

Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

intents = Intents.default()
intents.members = True

bot = commands.Bot(command_prefix="!", intents=intents)

For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.

grim oar
#

πŸ˜”

silk fulcrum
#

Hunter being overloaded

slate swan
#

!intents.message_content

#

try #bot-commands

slate swan
#
  File "main.py", line 63, in <module>
    WinterFeedback.run ("----")
  File "/home/runner/FeedBacksBot/venv/lib/python3.8/site-packages/discord/client.py", line 723, in run
    return future.result()
  File "/home/runner/FeedBacksBot/venv/lib/python3.8/site-packages/discord/client.py", line 702, in runner
    await self.start(*args, **kwargs)
  File "/home/runner/FeedBacksBot/venv/lib/python3.8/site-packages/discord/client.py", line 666, in start
    await self.connect(reconnect=reconnect)
  File "/home/runner/FeedBacksBot/venv/lib/python3.8/site-packages/discord/client.py", line 601, in connect
    raise PrivilegedIntentsRequired(exc.shard_id) from None
discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead.```
heady citrus
#
[2022-08-23 14:00:06] [ERROR   ] discord.client: Ignoring exception in on_guild_channel_create
2022-08-23T14:00:06.289457+00:00 app[worker.1]: Traceback (most recent call last):
2022-08-23T14:00:06.289464+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.10/site-packages/discord/client.py", line 409, in _run_event
2022-08-23T14:00:06.289465+00:00 app[worker.1]:     await coro(*args, **kwargs)
2022-08-23T14:00:06.289466+00:00 app[worker.1]:   File "/app/cogs/antievents.py", line 73, in on_guild_channel_create
2022-08-23T14:00:06.289466+00:00 app[worker.1]:     await channel.send(embed=embed)
2022-08-23T14:00:06.289467+00:00 app[worker.1]: AttributeError: 'Int64' object has no attribute 'send'

what does this mean?

slate swan
heady citrus
# slate swan no code no help, channel is probably a number here
            channel = db.find_one({ "guild_id": channel.guild.id })['anti-log-channel']
            
            if punishment == 'ban':
               punishment == "Banned"

            if punishment == 'kick':
               punishment == "Kicked"

            if channel == None:
                pass
            else:
                log_channel = self.bot.get_channel(channel)
                embed = discord.Embed(color=col)
                embed.description = 'Stylus Anti-Nuke Protection Logging'
                embed.add_field(name='Banned User', value=f'{i.user.mention} - **{i.user.id}**', inline=False)
                embed.add_field(name='Reason Why', value=f'Creating Channels Without Whitelist', inline=False)
                embed.add_field(name='Action Taken', value="The User Was {punishment} Immediately", inline=False)
                await channel.send(embed=embed)
[2022-08-23 14:00:06] [ERROR   ] discord.client: Ignoring exception in on_guild_channel_create
2022-08-23T14:00:06.289457+00:00 app[worker.1]: Traceback (most recent call last):
2022-08-23T14:00:06.289464+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.10/site-packages/discord/client.py", line 409, in _run_event
2022-08-23T14:00:06.289465+00:00 app[worker.1]:     await coro(*args, **kwargs)
2022-08-23T14:00:06.289466+00:00 app[worker.1]:   File "/app/cogs/antievents.py", line 73, in on_guild_channel_create
2022-08-23T14:00:06.289466+00:00 app[worker.1]:     await channel.send(embed=embed)
2022-08-23T14:00:06.289467+00:00 app[worker.1]: AttributeError: 'Int64' object has no attribute 'send'

what does this mean?

glad cradle
#

probably db.find_one(...) is returning an object, try to print channel

#

also you should use an asynchronous library for your database

final walrus
#

Is there a way to disable invites/ remove the invite link for my bot?

silk fulcrum
#

you can make your bot private

final walrus
#

will it still remain on the servers that it's on?

silk fulcrum
#

public param

final walrus
#

i see

#

ty

#

"Cannot have install fields on a private application"

#

F

silk fulcrum
#

what

final walrus
#

no clue

silk fulcrum
#

when does that appear?

final walrus
#

when I

#

toggle that

#
When trying to turn off the 'Public Bot' toggle in the developer portal for a bot, this error message is displayed:

"Cannot have install fields on a private application."

The actual error is that the bot cannot be private unless the OAuth2 Default Authorization Link is set to 'None'. The current error message is not sufficiently clear enough to diagnose the problem and I was forced to find the solution through a Reddit post.

Please consider revising the error message to "Bot cannot be set to private with current Default Authorisation Link settings." or something similar.

Please also consider revising the location of the error message and move the error message to appear near the associated toggle the error is for in accordance with relevant UX design heuristics.
#

ah

silk fulcrum
#

uhm... isn't everything explained?

final walrus
#

That wasn't the error

#

That explanation is clear, yes

zealous jay
#

How do I calculate how much ram my bot needs?

final walrus
#

If you're storing all your data in a database it shouldn't need much

zealous jay
#

And what about server count?

#

It has some events

#

And its in 230 servers rn

silk fulcrum
#

len(bot.guilds)

zealous jay
#

no I meant, its in 230 servers

final walrus
zealous jay
#

does it makes a difference?

final walrus
zealous jay
#

Oh, ok

#

I have never never used it but I'll try

#

Thanks

maiden fable
#

!d discord.Client.guilds

unkempt canyonBOT
slate swan
#

you need to fetch/get the channel object and use send on it

slate swan
#

He fetches the channel, just calls .send to the wrong variable

#

log_channel is the variable with the channel

#

log_channel.send() is right

tight dagger
#

yoo

#

does anyone have the code for how to change time zone?
the bot shows in UTC

#

but i want to change the time zone

#

@glad cradle or @silk fulcrum

#

u guys know?

silk fulcrum
#

wow, pinging concrete people

slate swan
#

😭

silk fulcrum
tight dagger
#

like the bot displays utc time only

slate swan
#

Doesn’t discord change the time zone anyway with the special time thing

tight dagger
silk fulcrum
#

<t:456789456>

#

is that 01:57 for you?

tight dagger
#
embed.add_field(name="Created Account On:", value=member.created_at.strftime("%a, %#d %B %Y, %I:%M %p UTC"))
    embed.add_field(name="Joined Server On:", value=member.joined_at.strftime("%a, %#d %B %Y, %I:%M %p UTC"))
#

code

tight dagger
silk fulcrum
#

not using time tags πŸ’€