#discord-bots

1 messages ยท Page 53 of 1

silk fulcrum
#

bruh what am I talking about it's just trash that's it

lone lichen
#

Very good one I must say

#

It keeps code red underlined after the syntax is fixed

slate swan
#

whats it not bad for then?

lone lichen
slate swan
#

meh

#

i mean it can actually be nice for multiplayers

silk fulcrum
slate swan
#

the only issue is the python version, which can be configured too

robust fulcrum
#

Btw do you know any good way for making help comand?

slate swan
#

!custom-help

unkempt canyonBOT
#

Custom help commands in discord.py

To learn more about how to create custom help commands in discord.py by subclassing the help command, please see this tutorial by Stella#2000

silk fulcrum
robust fulcrum
#

Finally i made my first python package

lone lichen
#

What is it?

#

That aint a package ๐Ÿ˜‚

robust fulcrum
slate swan
#

would be a module

silk fulcrum
#

and where is a package

robust fulcrum
#

What?

silk fulcrum
#

perspective_api_wrapper?

robust fulcrum
#

Ye

silk fulcrum
#

burh ok

robust fulcrum
#

Took me so much time

#

For just uploading

slow fog
silk fulcrum
#

morning

slate swan
#

you need to create a setup.py for it to be installable

robust fulcrum
#

And i tested my module by downloading

slate swan
#

well whatever

#

noone downloads a module to use it, pip installing is the preferred way

#

and poetry wraps pip

robust fulcrum
#

Guys how can I make a button that purges messages on click?

slate swan
#

try it and see, can you import it after installing

silk fulcrum
#

I'm participating in PyWeek with Asher and... I don't know almost anything about working in team... I only worked with complete noobs those didnt do anything when was in programming school, we didn't even get familiar with branches...

lone lichen
unkempt canyonBOT
#

await purge(*, limit=100, check=..., before=None, after=None, around=None, oldest_first=None, bulk=True, reason=None)```
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 the [`manage_messages`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission to delete messages even if they are your own. The [`read_message_history`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission is also needed to retrieve message history.

Changed in version 2.0: The `reason` keyword-only parameter was added.

Examples

Deleting botโ€™s messages...
robust fulcrum
robust fulcrum
slate swan
lone lichen
robust fulcrum
slate swan
#

did you upload the package to pypi?

tight dagger
#

how do i make this work?

slate swan
unkempt canyonBOT
tight dagger
slate swan
#
role # is a discord.Role
list_of_members = role.members
robust fulcrum
slate swan
robust fulcrum
silk fulcrum
#

!pypi perspective_api_wrapper_python

unkempt canyonBOT
robust fulcrum
robust fulcrum
slate swan
#

don't really need to use such a long namespace lol

#

could have used py-perspective or something

robust fulcrum
#

Should I change now?

slate swan
#

you can if you wish to

robust fulcrum
#

But long for me
I need to change on GitHub too

#

Lazy ๐Ÿฆฅ

#

How can I send message message on button click in dpy V2?

slate swan
#

๐Ÿ—ฟi haven't published my library yet cause its its nothing close to complete

slate swan
slate swan
robust fulcrum
lone lichen
robust fulcrum
lone lichen
silk fulcrum
#

5

lone lichen
unkempt canyonBOT
silk fulcrum
unkempt canyonBOT
#

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

Deletes the original interaction response message.

This is a lower level interface to [`InteractionMessage.delete()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.InteractionMessage.delete "discord.InteractionMessage.delete") in case you do not want to fetch the message and save an HTTP request.
lone lichen
silk fulcrum
slate swan
lone lichen
slate swan
#

nextcord isnt planning to stay as a fork either, they are doing a complete rewrite

lone lichen
slate swan
#

yea, ty

lone lichen
silk fulcrum
#

no

slate swan
#

nope, im making it from scratch

lone lichen
#

Thats dope

spring flax
dull knot
#

Why does this happen?
(sending command) part
After a few seconds, it says application failed to respond. But it responds appropriately

silk fulcrum
#

code?

dull knot
#
    @commands.slash_command(name="8ball", description="Answers random questions")
    async def ping(self, inter, question):
     responses = ["As I see it, yes.", "Ask again later.", "Better not tell you now.", "Cannot predict now.", "Concentrate and ask again.",
             "Donโ€™t count on it.", "It is certain.", "It is decidedly so.", "Most likely.", "My reply is no.", "My sources say no.",
             "Outlook not so good.", "Outlook good.", "Reply hazy, try again.", "Signs point to yes.", "Very doubtful.", "Without a doubt.",
             "Yes.", "Yes โ€“ definitely.", "You may rely on it."]
      
     embed = disnake.Embed(title="", description="", colour = disnake.Colour.random())
     embed.add_field(name=f"![Nani](https://cdn.discordapp.com/emojis/1011925182551707699.webp?size=128 "Nani") Question: *{question}*",
                     value=f"![MBE](https://cdn.discordapp.com/emojis/1011925745070780456.webp?size=128 "MBE") Answer: *{random.choice(responses)}*")
     await inter.channel.send(embed=embed)
#

Ahh, wait..

silk fulcrum
#

8ball async def ping

dull knot
#

LOL I just noticed

#

I just need to put _8ball right? And make an alias

slate swan
silk fulcrum
#

inter.channel.send bruh

#

you need to respond an interaction

#

not send a message

dull knot
#

my bad MyBad_ Well, I'm starting out so I'm not very familiar with how things work just yet. I'll try that

worn onyx
#

@silk fulcrum how to solve this?

#

@silk fulcrum

rocky trench
#

@worn onyx you need to use await: await client.load_extension

rocky trench
#

Replace client.load_extension('jishaku') with await client.load_extension('jishaku')

#

Basically just add await

rocky trench
#

Haha LUC, that's weird

limber bison
rocky trench
limber bison
worn onyx
rocky trench
dull knot
#
    @commands.slash_command(name="purge", description="Purges 'X' amount of messages in a Text Channel")
    @commands.has_any_role("Shuma")
    async def purge(self, inter, purge: int):
      try:
          await inter.channel.purge(limit=1 + purge)
          await inter.send(f"{purge} messages, succesfully purged!", delete_after=5)
      except: 
          await inter.send(f"Failed to delete {purge} messages. You are not eligible to use this command!")

I want to make the bot send a custom response when the sender doesn't have the "specified" role cited in the @commands.has_any_role() decorator. How do I do that?
I tried using error handlers but it just sent interaction failed when I tried it on one of my test servers without the "Shuma" role.

Do I have to use if/elif statements for that? If it's overly complicated, I'd probably just hold it off MyBad_ If it's not that hard to do, pls tell me what to do. I'm still starting out.

worn onyx
#

@rocky trench

rocky trench
#

What is jsk? I never told you to install that

slate swan
#

what library do you use?

dull knot
#

Disnake

slate swan
#

gimme a moment ill look up for the event in docs

dull knot
#

Sure. Thx

slate swan
#

!pip jishaku

rocky trench
#

Alright

#

@worn onyx it's impossible for me to tell you what is causing the issue at the moment, I haven't seen the code for the command

slate swan
unkempt canyonBOT
#

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

The default slash command error handler provided by the bot.

By default this prints to [`sys.stderr`](https://docs.python.org/3/library/sys.html#sys.stderr "(in Python v3.10)") however it could be overridden to have a different implementation.

This only fires if you do not specify any listeners for slash command error.
slate swan
#

you need to use this event

dull knot
unkempt canyonBOT
slate swan
slate swan
worn onyx
shrewd apex
vale wing
shrewd apex
#

it's == but just doing pip install installs the latest version

shrewd apex
worn onyx
#

@shrewd apex u know how to make nsfw cmds?

shrewd apex
#

huh ๐Ÿ˜ณ

#

yeah i can altho never made em before

paper sluice
#

lol

shrewd apex
#

but question is why would I go to discord for NSFW pithink

worn onyx
shrewd apex
#

i don't think this even the right channel we need like a NSFW channel ig but u can use some NSFW lib or api wrapper or the api it's self i think ||nhentai has one||

#

i hope i don't get warned or something ๐Ÿ’€

slate swan
shrewd apex
#

for interested ppl

slate swan
#

there's many other APIs you can google for

#

the nh API has been deprecated iirc

shrewd apex
#

there are like hundreds of waifu libs

#

but they're sfw i think

vocal snow
#

Why do you know about this asher

paper sluice
shrewd apex
#

ryuga zeffo are u two taking part in pyweek ๐Ÿ‘€

vale wing
shrewd apex
#

oh ic pithink

paper sluice
shrewd apex
#

i am looking for some team members PPL i asked are all offline or busy ;-;

#

okie

supple thorn
#

๐Ÿฃ

shrewd apex
#

yep

supple thorn
#

Might be a good time to have motivation to do coding again

#

But no clue how to make a game

shrewd apex
#

well it's making a game so it's gonna be interesting

supple thorn
shrewd apex
#

i never did either

#

this is gonna be like my second try at making a game with python first was codejam

supple thorn
shrewd apex
#

yep we made a chess game

supple thorn
#

What library did you guys use

shrewd apex
#

i did the game logic and db and bit of the gaming part

#

pygame

vale wing
#

Oh heck if it's a game jam I'm definitely not participating

shrewd apex
#

๐Ÿ’€

zealous jay
#

Does this decorator work with slash commands?
@commands.has_guild_permissions(ban_members=True)

#

I think it doesn't

zealous jay
#

or do i need to use app_commands

vale wing
#

At least in disnake

#

Idk about dpy

zealous jay
zealous jay
#

oh yeah it didn't work for me but maybe I was doing something wrong

zealous jay
#

(I was)

worn onyx
#

@zealous jay

#

@shrewd apex

dull terrace
glossy ruin
#

how to put this in timestamp

slate swan
#

!d discord.utils.format_dt

unkempt canyonBOT
#

discord.utils.format_dt(dt, /, style=None)```
A helper function to format a [`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "(in Python v3.10)") for presentation within Discord.

This allows for a locale-independent way of presenting data using Discord specific Markdown...
white rain
#

Does someone know when i'm running this script, it is written the name of my guild but 2 times like :

guild
guild

   ```for guild in self.bot.guilds:
        print(guild)```
slate swan
#

how to send avatar people who join?

#
@bot.event
async def on_member_join(member):
    channel = bot.get_channel(1007988538312241173)
    embed = disnake.Embed(title="NOWY UลปYTKOWNIK", description=f"Witamy {member.mention} na serwerze **{channel.guild.name}**", colour=0xF0C43F)```
silk fulcrum
#

member.display_avatar.url @slate swan

unkempt canyonBOT
#

property display_avatar```
Returns the memberโ€™s display avatar.

For regular members this is just their avatar, but if they have a guild specific avatar then that is returned instead.

New in version 2.0.
slate swan
silk fulcrum
#

dossiers? who is that?

slate swan
silk fulcrum
# slate swan documentation

there are enough examples there. If you understand how they work everything else is pretty easy to understand

slate swan
#

i didnt see

robust fulcrum
#

Guys if i disable a button . Is it possible to enable it?

silk fulcrum
#

button.disabled = True disables it
button.disabled = False enables it

slate swan
silk fulcrum
slate swan
silk fulcrum
#

I can, but I won't

#

no spoonfeeding

robust fulcrum
# silk fulcrum yes

Like i want that when i click the button it disables the last button and does not disable all buttons
How can I do it?

robust fulcrum
slate swan
#

so can u send me HELPFUL link beacude i don't see any help in this documentation zero examples

silk fulcrum
silk fulcrum
#

its event

robust fulcrum
silk fulcrum
#

and also .display_avatar.url

robust fulcrum
loud junco
#

hi navi mann
where is ashley

silk fulcrum
silk fulcrum
#

if your button is the last element of the view, you can do view.children[-1]

slate swan
#

Why are there so many anime pfps and why do they all know each other

loud junco
slate swan
shrewd apex
silk fulcrum
loud junco
silk fulcrum
shrewd apex
slate swan
loud junco
#

some random dude out there :someone help me

await ctx.send('hello world')
```its not working
silk fulcrum
shrewd apex
#

๐Ÿคฃ

loud junco
silk fulcrum
#

send?

slate swan
silk fulcrum
shrewd apex
#

i didn't even know it existed

silk fulcrum
#

๐Ÿ˜ณ

shrewd apex
#

now it saves time for me to run code again and again to check styles

loud junco
shrewd apex
#

i need embed designs generator

#

anyone know some

loud junco
#

anyone know some pikachu???

silk fulcrum
loud junco
#

its like asking people to imagine something new
you cant imagine something you have never saw before lol

shrewd apex
#

idk too lazy as soon as I think i have embed design's to do i lose all motivation

loud junco
#

lol

silk fulcrum
silk fulcrum
#

just gotta split tasks into smaller ones

loud junco
#

for a better example
its like imagining new colour

silk fulcrum
loud junco
shrewd apex
silk fulcrum
#

combine them all

shrewd apex
#

how u imagine new

slate swan
#

sure

silk fulcrum
#

also I already deleted my gist

#

it was trash

loud junco
#

maybe there is some colour we cant see due to our cone cells

silk fulcrum
#

completely

slate swan
#

topic?

loud junco
silk fulcrum
loud junco
slate swan
#

I love python!

silk fulcrum
loud junco
#

AHEM

slate swan
loud junco
# slate swan

the people here dont like gif and pic unrelated to codes, so....

silk fulcrum
slate swan
silk fulcrum
#

or what do u expect

loud junco
loud junco
slate swan
#

Are you gonna cry because I sent SpongeBob?

#

spongebob is hot

loud junco
slate swan
silk fulcrum
# slate swan of your gist

uhm... well... like a dpy2.0 guide to create a bot or to migrate to 2.0 and also how to create bot with cogs and stuff like db, aiohttp sessions etc (like to put it into setup_hook)

slate swan
#

Whatโ€™s wrong with using emojis

silk fulcrum
loud junco
slate swan
#

time to return to the dead

slate swan
silk fulcrum
#

and grammar mistakes as noid said

slate swan
silk fulcrum
loud junco
loud junco
silk fulcrum
slate swan
#

how doesnโ€™t fit

shrewd apex
silk fulcrum
shrewd apex
#

we can even add a smol section how to not use json and make a SQL pool instead

shrewd apex
#

how is your Minecraft bot coming along

silk fulcrum
silk fulcrum
#

oh wait who asked...

shrewd apex
loud junco
#

another minecraft bot

shrewd apex
#

cool I'll make one once i get home from gym

loud junco
#

but how do u play it

shrewd apex
#

idk i only played Minecraft creative mode to battle friendz

loud junco
#

:/

#

minecraft creative PVP ๐Ÿ’€

silk fulcrum
#

but not the single player

#

i tried to beat it... but im too lazy

shrewd apex
#

i am the last person who u would ever want to play video games with except supercell and pokemon

loud junco
shrewd apex
#

idk i never played any other games

loud junco
shrewd apex
loud junco
#

what is bw brawl stars?

shrewd apex
#

yep

loud junco
#

to think that im brawl stars og kekw
but i quit like last year
its getting p2w now

silk fulcrum
#

i quit bw 2 years ago

shrewd apex
#

i used to like 2 yrs ago

#

now my games folder empty

loud junco
#

lol i played before 2019
i have star shelly

silk fulcrum
loud junco
slate swan
silk fulcrum
#

so.. when are we making the gist @shrewd apex ? If we are

shrewd apex
#

like 1-2 hrs later

slate swan
shrewd apex
#

skill issue

slate swan
#

I also got banned for speaking off topic here

slate swan
silk fulcrum
shrewd apex
#

u can start if u are free rn

#

I'll start on it in some time u can start with the explanation part and all ig

silk fulcrum
shrewd apex
#

๐Ÿ‘Œ

silk fulcrum
# shrewd apex ๐Ÿ‘Œ

are we just gonna like make it in 2 our files and combine somehow? or branches if that is even possible? not familiar with team work at all

robust fulcrum
silk fulcrum
shrewd apex
#

wait lemme check

robust fulcrum
#

Can we add a animated emoji to a button in dpy?

silk fulcrum
silk fulcrum
robust fulcrum
junior verge
robust fulcrum
junior verge
#

anyone know what this means? I never had this error before and everything used to work fine

silk fulcrum
#

MotorCollection

#

what is even that

robust fulcrum
#

Guys why i getting this error?

junior verge
#

but whenever my bot goes online it spams that in the consolke

robust fulcrum
silk fulcrum
robust fulcrum
# silk fulcrum shaw your callback
class Help(discord.ui.View):
    def __init__(self):
        super().__init__(timeout=180)
        self.page = 1

    @discord.ui.button(label=None,style=discord.ButtonStyle.gray,row=0,emoji=":left:")
    async def left(self,interaction:discord.Interaction,button:discord.ui.Button):
        if self.page == 1:
            btn = self.children[0]
            btn.disabled = True
silk fulcrum
#

label is None by default but whatever

robust fulcrum
#

I just did but idk

robust fulcrum
#

I got no error in console

silk fulcrum
#

does your button get disabled?

#

oh no it didn't

slate swan
#

It just does that

robust fulcrum
silk fulcrum
#

see: you only disable button in the view, but to update it in the message you need to edit it

slate swan
#

Ong

silk fulcrum
#

so you would need await interaction.edit_original_response(content="page 1", view=self)

whole sparrow
#

how do i ctx.reply

#

but for interaction

#

oo ok so its just .response.send_message

silk fulcrum
#

!d discord.InteractionResponse.send_message

unkempt canyonBOT
#

await send_message(content=None, *, embed=..., embeds=..., file=..., files=..., view=..., tts=False, ephemeral=False, allowed_mentions=..., suppress_embeds=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Responds to this interaction by sending a message.
silk fulcrum
whole sparrow
#

tysm

silk fulcrum
robust fulcrum
silk fulcrum
#

hummm

#

show code. ..?...

robust fulcrum
slate swan
#

Unknown webhook ๐Ÿคฏ

silk fulcrum
#

looks like weird error

robust fulcrum
#

Ig

slate swan
#

hey

slate swan
#

where should i start

slate swan
silk fulcrum
slate swan
robust fulcrum
slate swan
slate swan
silk fulcrum
slate swan
robust fulcrum
slate swan
slate swan
silk fulcrum
silk fulcrum
slate swan
silk fulcrum
#

u r new here @slate swan

slate swan
robust fulcrum
silk fulcrum
slate swan
#

I have had multiple accounts and I have been banned a few times

silk fulcrum
robust fulcrum
slate swan
#

A message from my old account ^^

slate swan
silk fulcrum
robust fulcrum
silk fulcrum
#

lemme join ya conversation

robust fulcrum
slate swan
slate swan
primal token
#

it would depend what you're parsing

slate swan
#

The oldest message I could find of me

#

2020 ๐Ÿ˜ซ

tight dagger
#

@slate swan hey

slate swan
tight dagger
#

can u help me with the code for displaying members with a certain role

sick birch
#

good morning friends

tight dagger
#

its discord.Role.members but how do i proceed with it?

sick birch
#

hows it going over here

slate swan
tight dagger
primal token
slate swan
unkempt canyonBOT
primal token
#

Im joking good morning robin kek

tight dagger
#

can u give me a pseudocode

slate swan
tight dagger
#

hmm

slate swan
#

Idk if it returns a list of member objects or smth

sick birch
slate swan
sick birch
#

I like filter personally because js user

slate swan
#

( ๐Ÿคฎ )

primal token
slate swan
#

How do I mute pings on servers

#

Cause I hate getting pings from servers which Iโ€™m only in for the emotes

#

Because the obviously have to ping everyone all the time

#

In a Server of over 500k people

full lily
#

right click > mute server

slate swan
#

Iโ€™m on mobile

full lily
#

click and hold?

slate swan
#

Itโ€™s muted finally

#

I get happy thinking someone want to talk to me but then itโ€™s just some useless ping

primal token
slate swan
#

Playing with my feelings ๐Ÿ’ฏ

primal token
#

๐Ÿ˜ณ

slate swan
#

Damn imagine having to contact staff to get your message whitelisted

tight dagger
primal token
robust fulcrum
primal token
slate swan
#

Why is c++ so bad

#

Itโ€™s a 3 liner to print to the console

#

Why is it 3 lines

primal token
#

thats doesnt mean its bad

slate swan
#

C# >> c++

primal token
#

Thats called a low level language, a language that doesnt have much abstractions

slate swan
#

Why make high level language

#

hi! i tried to delete messages but i wont wrok
my code:

    async def clear(message):
        if message.content.startswith('!delete'):
            await message.purge()```
slate swan
#

๐Ÿ˜ญ

#

ok ill try

#

If you wanna purge messages there are arguments you need

primal token
# slate swan Why make high level language

because some programs use languages like that and they give better concepts when programming e.g segfaults, memory leaks and memory allocation and cant forget about their speed either

slate swan
#

what

#

what did i do?

#

That is the most abstract way to make a command I have seen in a while

#

ok

#

message.delete doesnt work

drowsy prairie
#

How can I call an asynchronous function indefinitely?

primal token
whole sparrow
#

How do I implement a custom cooldown depending on what the user does within the command? is that even possible

#

eg. random example: he clicks a button saying he wants a cooldown of 5mins then the command will be in cooldown in 5

slate swan
#

World Wide Web

#

๐Ÿ˜ญ

primal token
silk fulcrum
#

bruh I literally was typing that I saw that noid was here

primal token
shrewd apex
silk fulcrum
primal token
#

what about me being here?

silk fulcrum
robust fulcrum
# shrewd apex the callback what's in the callback if a callback takes more than 3secs u have t...

Whats defer?

class Help(discord.ui.View):
    def __init__(self):
        super().__init__(timeout=180)
        self.page = 1

    @discord.ui.button(label=None,style=discord.ButtonStyle.gray,row=0,emoji=":left:")
    async def left(self,interaction:discord.Interaction,button:discord.ui.Button):
        if self.page == 1:
            btn = self.children[0]
            btn.disabled = True
            await interaction.response.edit_message(content="page 1", view=self)

Here is my code

silk fulcrum
primal token
#

kek funniest joke ive seen today

silk fulcrum
primal token
#

i wonder if dpys webhook interaction abstraction can get you limited from the api

robust fulcrum
#

Whats meaning of defer?

primal token
shrewd apex
silk fulcrum
shrewd apex
#

imagine waiting 15 mins

robust fulcrum
#

It's better that i should close my coding ide and play games

silk fulcrum
#

yes close your phone and get on PC

cerulean shale
#

yo i have been using replit but i decided to move on to vsc. I wrote the basics first to see whether it will work or not and it aint working, i watched few yt videos and yeah it aint working ;-;

cold sonnet
#

show code

#

stop youtube videos

unkempt canyonBOT
#

Hey @cerulean shale! I noticed you posted a seemingly valid Discord API token in your message and have removed your message. This means that your token has been compromised. Please change your token immediately at: https://discordapp.com/developers/applications/me

Feel free to re-post it with the token removed. If you believe this was a mistake, please let us know!

cerulean shale
#

bruh

whole sparrow
#

How do I have custom cooldown for different users? e.g a user has a differnet job than another user

cerulean shale
# cold sonnet show code
import discord

from discord.ext import commands

bot = commands.Bot(command_prefix="/")

@bot.event
async def on_ready():
    await bot.change_presence(activity=discord.Game("Hi senpai!"))
    print("I am ready to rock!!!")


@bot.command()
async def ping(ctx):
    await ctx.send(f"My current latency is {round(bot.latency * 1000, 1)} ms.")


bot.run("test bot token -_-")
cold sonnet
#

this isn't bad

#

just the change_presence on_ready

#

but it shouldn't stop the code

primal token
cerulean shale
primal token
cold sonnet
#

yeah that too

#

how did you run the code

cerulean shale
#

I changed the prefix now, and yet it shows the same thing

#

ctrl+alt+N

primal token
cerulean shale
primal token
#

and how can you confirm that?

cerulean shale
#

um, shouldnt we like go to his git and install it from the link?

lone lichen
brazen raft
#

py -m pip install -U discord.py

#

Version 2.0 is now on PyPi

silk fulcrum
#

py -m

primal token
#

my point was, what evidence does he have to know that his version isnt 2.0 when it was recently released on pypi

silk fulcrum
#

will that work?

#

isn't it python?

primal token
#

it depends

tidal hawk
#

How to I make it so the bot deafens it self when it joins the channel

brazen raft
#

Maybe not because they're using python which might be using Microsoft's alias

primal token
#

py and python are for windows

brazen raft
#

!py

#

Uh hold on

cold sonnet
#

huh

silk fulcrum
primal token
#

The question still isnt pointed at you kek

cold sonnet
#

print(discord.__version__)

lone lichen
#

Lmao Iโ€™ m just messing, ik what u meant

primal token
#

I think you guys are missing my point by a long run, he said "not 2.0" but never provided approval on which method he used.

cold sonnet
#

the code works both on 2.0 and 1.7

cerulean shale
lone lichen
cold sonnet
#

members

#

intents.members

lone lichen
#

!d discord.Intents.members

unkempt canyonBOT
#

Whether guild member related events are enabled.

This corresponds to the following events...

cold sonnet
#

yes

cerulean shale
#

i changed the prefix to ?

#

it still isnt working

lone lichen
silk fulcrum
#

?tag idw

novel apexBOT
#

This is not a Modmail thread.

primal token
unkempt canyonBOT
#

Whether message content, attachments, embeds and components will be available in messages which do not meet the following criteria:

โ€ข The message was sent by the client

โ€ข The message was sent in direct messages

โ€ข The message mentions the client

This applies to the following events...

cold sonnet
brazen raft
#

It's shorter and it does the same thing

cold sonnet
#

I saw you say "pwease ๐Ÿ‘‰๐Ÿ‘ˆ" on the dpy server Master32

#

how you gonna get out of that

lone lichen
#

Busted

cerulean shale
lone lichen
primal token
cold sonnet
#

did he

primal token
#

ask him

cerulean shale
#
import discord

from discord.ext import commands

bot = commands.Bot(command_prefix="?")

@bot.event
async def on_ready():
    print("I am ready to rock!!!")


@bot.command()
async def ping(ctx):
    await ctx.send(f"My current latency is {bot.latency * 1000:.1f} ms.")


bot.run("token")
silk fulcrum
#

not for saying pwease

primal token
#

kek

cerulean shale
#

ight ight

brazen raft
cold sonnet
#

OH

cold sonnet
#

why doesn't it show the error

silk fulcrum
lone lichen
silk fulcrum
#

i dont remember who's ping was i spamming

lone lichen
silk fulcrum
#

but for some reason i think that was RDanny or my alt

silk fulcrum
shrewd apex
#

thats a channel for spam baits

silk fulcrum
#

lol

lone lichen
cold sonnet
#

it's not a good server anyway

shrewd apex
#

lots of stuff in life has no point ๐Ÿ˜”

cold sonnet
#

me

primal token
#

life doesnt have a point lol

silk fulcrum
#

like sgtlaggy for example

#

I sometimes get helped there and dont get helped here

primal token
#

there is no point/meaning in life as everyone doesnt want the samething they just want the best for themselves giving life a meaning that can only be defined by yourself

tidal hawk
silk fulcrum
#

oh

cold sonnet
#

self_deafen

silk fulcrum
#

OH

cold sonnet
unkempt canyonBOT
#

property me```
Similar to [`Client.user`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.user "discord.Client.user") except an instance of [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member"). This is essentially used to get the member version of yourself.
cold sonnet
#

uh what's the docs for the bot user

slate swan
#

!d discord.ClientUser

unkempt canyonBOT
#

class discord.ClientUser```
Represents your Discord user.

x == y Checks if two users are equal.

x != y Checks if two users are not equal.

hash(x) Return the userโ€™s hash.

str(x) Returns the userโ€™s name with discriminator.
cold sonnet
#

in a guild

slate swan
#

in a guild, its Guild.me, and it returns a Member object

#

and editing it's state doesn't require any permissions

cerulean shale
#

YOOOOOOOOOOOO IT WORKS FINALLY AFTER USING INTENTS!!!!

cold sonnet
#

!d discord.Member.edit I'm not sure if this shows self_deafen

unkempt canyonBOT
#

await edit(*, nick=..., mute=..., deafen=..., suppress=..., roles=..., voice_channel=..., timed_out_until=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the memberโ€™s data.

Depending on the parameter passed, this requires different permissions listed below...
cerulean shale
#

I HAD THEM ENABLED BUT DIDNT THINK THEY WERE THAT NECESSARY

primal token
#

kek

cerulean shale
#

THX ALOT!!!!

#

๐Ÿ™ ๐Ÿ™ ๐Ÿ™

primal token
#

youre welcome lol

silk fulcrum
#

no need to shout

cerulean shale
#

happiness

primal token
#

wish i were happy, i wake up with severe back pain

swift pumice
#
async def bro():
    variable_list = [
        'hallo kinder',
        'https://tenor.com/view/kny-hello-chat-giyuu-tomioka-levitate-gif-23115905',
        'ihr opfer',
        'hdf',
    ]
    channel = bot.get_channel(985970666643816498)
    await channel.send({random.choice(variable_list)})

    bro.start()``` why doesnt this work? :( no error
#

it just doesnt work

primal token
#

kek

slate swan
#

you're asking a task to start itself

primal token
#

and you should also check if Bot.get_channel returns None

slate swan
#

just use the http method directly

primal token
#

bro

swift pumice
slate swan
#

bot.http.send_message(id, "whatever")

primal token
#

smh

glossy ruin
#

should i take notes for everything, like if i have a very brief python tutorial and a book that introduce python to a programmer. Should i take notes for both or only for very brief python tutorial?

slate swan
swift pumice
primal token
lone lichen
swift pumice
slate swan
slate swan
glossy ruin
#

ok, language i was learning was cpp, and i was confused should i take notes for The Tour of cpp and for learncpp.com

#

thanks

slate swan
#

same applies for any language

swift pumice
tight dagger
#

hey guys

swift pumice
tight dagger
#

it says command already exists when it doesnt

primal token
tight dagger
#

discord.ext.commands.errors.CommandRegistrationError: The command help is already an existing command or alias.
๎บง

#

thats not true

#

how do i rectify it?

#

@silk fulcrum sire come to my rescue

slate swan
glossy ruin
silk fulcrum
#

bruh I just did only mentions so this channel wont annoy me and now he pings me

primal token
#

i would honestly still go for rust over cpp tbh

glossy ruin
#

i like cpp, soo

primal token
#

thats nice

slate swan
#

rust is better in terms of low-levelled features like memory management and general programming practices. but uk, everyone has their own choice

glossy ruin
#

after becoming good in cpp, i will improve my knowledge in asm

primal token
slate swan
#

there's already a default help command that discord.py provides

#

if you want a custom help cmd check this out

#

!custom-help

unkempt canyonBOT
#

Custom help commands in discord.py

To learn more about how to create custom help commands in discord.py by subclassing the help command, please see this tutorial by Stella#2000

primal token
slate swan
#

I'll start java after 6-7 months

glossy ruin
#

sorry i was in wrong channel, ๐Ÿคฆ

slate swan
#

don't worry, its #ot3

primal token
tight dagger
slate swan
primal token
slate swan
#

thats cool, ๐Ÿ˜”im on a drop preparing for college

primal token
#

next year im going to 11th grade lol

#

currently learning about the basics of electricity

slate swan
#

we had python in our 9-12

primal token
#

thats interesting, the only pain im getting this year is physics and next year im taking chemistry

slate swan
#

chemistry is pain

primal token
#

bro what

#

physics is a pain, chemistry is mid

slate swan
#

im too lazy to learn things, so it is
whilst calculation based stuff like maths or physics is lowkey easy for me

primal token
#

thats a good way of describing that you posses something called a "skill issue".

tidal hawk
cerulean shale
#

ok so i installed flask but still its giving this error thingy

potent spear
#

this is a suggestion, not an error

#

just run it, you'll see that the problem will be gone

#

this has to do with vs code which doesn't check for new installed packages every millisecond, so you could just reopen the file and vs code will check again

cerulean shale
#

ohk, new to vsc ;-;

#

yo how can you enable and disable stuff? like i got a listener where if someone sends imagine text the bot will reply with i cant even imagine text

silk fulcrum
austere vale
#

does anyone know why Nayu's name comes up twice?

      await cursor.execute('SELECT level, xp, user FROM levels WHERE guild = ? ORDER BY level DESC, xp DESC LIMIT 10',(ctx.guild.id,))
      data=await cursor.fetchall()
      if data:
        em=nextcord.Embed(title='Server Leaderboard',color=0xfd9fa1)
        count=0
        for table in data:
          count+=1
          member=ctx.guild.get_member(table[2])
          em.add_field(name=f'{count}. {member}',value= f'Level-**{table[0]}** | XP-**{table[1]}**',inline=False)
        await ctx.send(embed=em)
silk fulcrum
#

imagine text

cerulean shale
#

understood?

sage otter
sage otter
#

To check. Just print your data variable as a debug method.

cerulean shale
#

wait nvm i got an idea

slate swan
#

How can I create a text channel with permissions?

wet crystal
#

Does somebody know how I add a option to my slash command?

Example:

sage otter
#

!d discord.Guild.create_text_channel

unkempt canyonBOT
#

await create_text_channel(name, *, reason=None, category=None, news=False, position=..., topic=..., slowmode_delay=..., nsfw=..., overwrites=..., default_auto_archive_duration=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

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

Note that you need the [`manage_channels`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to create the channel.

The `overwrites` parameter can be used to create a โ€˜secretโ€™ channel upon creation. This parameter expects a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.10)") of overwrites with the target (either a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")) as the key and a [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/latest/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite") as the value.

Note

Creating a channel of a specified position will not update the position of other channels to follow suit. A follow-up call to [`edit()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.TextChannel.edit "discord.TextChannel.edit") will be required to update the position of the channel in the channel list...
sage otter
#

@slate swan ^ overwrites kwarg

wet crystal
#

maybe u know?

sage otter
#

No, I have touched slash commands once.

cloud dawn
#

๐Ÿ‘‰ /

slate swan
#

depends on what library you use, you can just add arguments inside the command callback in discord.py

sage otter
slate swan
sage otter
#

Assign it to a variable and access it

slate swan
sage otter
#

Yea

tight dagger
slate swan
#

AttributeError: โ€˜strโ€™ object has no attribute โ€˜idโ€™

sage otter
#

That method for sure doesnโ€™t return a str

#

Show code.

tight dagger
slate swan
slate swan
# sage otter Show code.
@discord.ui.button(label='Support', style=discord.ButtonStyle.grey, custom_id='persistent_view:green')
    async def green(self, interaction: discord.Interaction, button: discord.ui.Button):
      overwrites = {
        interaction.guild.default_role: discord.PermissionOverwrite(read_messages=False, view_channel=False),
        interaction.guild.me: discord.PermissionOverwrite(read_messages=True, send_messages=True),
        client.author: discord.PermissionOverwrite(read_messages=True, send_messages=True, view_channel=True)
      }
      ticket = await interaction.guild.create_text_channel(name=client.author, reason="Ticket Creation", overwrites=overwrites)
      await interaction.response.send_message(f"Creanted a ticket <#{ticket.id}>", ephemeral=True)
      id = ticket.id
      channel = await client.fetch_channel(id)
      embed = discord.Embed(title="New ticket created by {client.author}", description=f"{interaction.author} Please wait for support staff to arrive here and help you\nTill then vote for us **[here](https://top.gg/servers/{interaction.guild.id})**", color=discord.Colour.dark_theme())
      embed.set_footer(text=interaction.guild.name)
      await channel.send(content="{interaction.user.mention}", embed=embed)
sage otter
sage otter
#

Do you mind if see the full error.

slate swan
#
Traceback (most recent call last):
  File "C:\Python310\lib\site-packages\discord\ui\view.py", line 414, in _scheduled_task
    await item.callback(interaction)
  File "c:\Users\User\Desktop\ACLib\bot.py", line 55, in green
    ticket = await interaction.guild.create_text_channel(name=client.author, reason="Ticket Creation", overwrites=overwrites)
  File "C:\Python310\lib\site-packages\discord\guild.py", line 1309, in create_text_channel
    data = await self._create_channel(
  File "C:\Python310\lib\site-packages\discord\guild.py", line 1175, in _create_channel
    payload = {'allow': allow.value, 'deny': deny.value, 'id': target.id}
AttributeError: 'str' object has no attribute 'id'
sage otter
#

This is a problem with your overwrites

#

One of your overwrite targets are a string and not a Member or Role

slate swan
#

id*

sage otter
#

The user's member object for that guild

slate swan
#

How can I get that?

#

ctx.author?

sage otter
#

If thatโ€™s the user you want to set the overwrites for

#

Yea

slate swan
#

Lemme try rq

pulsar solstice
#

I am making a sqlite database economy bot now I am want to make that it adds 5 cookies in each message event.

#

btw the currency name in cookies

#

So I have no Idea how to do that

#

here is my code done till now

#
@bot.event
async def on_ready():
    con = sqlite3.connect("jar.sqlite")
    cur = con.cursor()
    cur.execute("""CREATE TABLE IF NOT EXISTS jar (
        user_id INTERGER, cookies INTERGER)""")
    print("Bot is Now Online")

@bot.event
async def on_message(message):
    if message.author.bot:
        return
    
    author = message.author
    con = sqlite3.connect("jar.sqlite")
    cur = con.cursor()
    cur.execute(f"SELECT user_id FROM jar WHERE user_id = {author.id}")
    result = cur.fetchone()
    if result is None:
        sql = ("INSERT INTO jar(user_id, cookies) VALUES(?, ?)")
        val = (author.id, 0)
        cur.execute(sql, val)
    con.commit()
    cur.close()
    con.close()
    await bot.process_commands(message)

@bot.command()
async def jar(ctx):
    con = sqlite3.connect("jar.sqlite")
    cur = con.cursor()
    cur.execute(f"SELECT cookies FROM jar WHERE user_id = {ctx.author.id}")
    bal = cur.fetchone()
    try:
        cookies = bal(0)
    except: 
        cookies = 0

    await ctx.author.send(f"You have {cookies}")
sage otter
#

Thatโ€™s gonna be a lotta database interaction if itโ€™s for every single message a person sends.

brazen raft
#

And also you should open a database connection once and use it as a bot variable

brazen raft
#

It is not asynchronous

#

It is blocking

pulsar solstice
#

awww... I am useless

#

I use sqlite!!!

#

that's evil!!!

#

I don't deserve to live

brazen raft
#

aiosqlite is similar to sqlite3

#

One noticeable different I have noticed is that also aiosqlite.Cursor objects support using with

pulsar solstice
#

pls

silk fulcrum
pulsar solstice
#

I don't have energy to switch to a different lib now

pulsar solstice
pulsar solstice
#

or I have to again rewrite it?

silk fulcrum
slate swan
#

after looking at the code for 1 hour i still can't figure out what's the matter here

@commands.Cog.listener()
    async def on_member_join(self,member):
        print("member joined")
        guild = self.client.get_guild(guildid)
        channel = guild.get_channel(999084968766619688)
        embed = discord.Embed(title=None,description=f"someone just joined")
        now = datetime.datetime.now()
        tem = now.strftime("%Y-%m-%d %H:%M:%S %p")
        embed.set_footer(text=tem,icon_url=thumbnail)
        embed.set_thumbnail(url=member.avatar_url)
        
        await channel.send(embed=embed)```
it's printing the member joined but it's not sending the message in the channel
pulsar solstice
pulsar solstice
slate swan
silk fulcrum
#

that's just a library, sqlite is a database itself, you can view it anyway, either you use sqlite, aiosqlite or some other language

silk fulcrum
#

why people name Bot instances with client

pulsar solstice
#

time to kill all of my code

slate swan
#

it's just

#

lol idk i've been using dpy for 2 years and i never named my bot bot always client

silk fulcrum
sage otter
#

I mean itโ€™s just a variable. You can name it whatever you want.

slate swan
silk fulcrum
#

a lot of things

#

getting guild when you can do member.guild

slate swan
#

and as long as it works it doesn't matter, btw any idea why it ain't working๐Ÿ’€

kindred epoch
silk fulcrum
#

using datetime.datetime.utcnow() when discord.utils.utcnow() exists (well this is not a big deal, just less importing)

slate swan
silk fulcrum
#

and not using timestamps

#

so... are you getting any error @slate swan?

slate swan
#

nope

silk fulcrum
#

do you have an error handler?

slate swan
silk fulcrum
#

what?

slate swan
#

the error

#

but it's not raising any error

silk fulcrum
#

do you have an error handler

slate swan
#

nope

silk fulcrum
#

hm wery weird

slate swan
#

so, any idea?

silk fulcrum
#

no idea

#

i'd try debugging 'here' at different lines to see where the errror is

pulsar solstice
slate swan
#

the classic method to find the culprit

pulsar solstice
#

like features or what??

slate swan
#

lol, i'll try that

winged coral
#

And why are you not using member.guild

slate swan
#

in a variable, i want to make sure it only triggers when a member joins a specific guild, i know it won't work, but i will add that later

winged coral
#

I think thereโ€™s a lot of things wrong there and without specific exceptions iโ€™m not gonna dredge through it all with you

slate swan
silk fulcrum
#

which doesnt block event loop for your bot

cloud dawn
slate swan
silk fulcrum
pulsar solstice
#

hmmm

slate swan
silk fulcrum
#

i downloaded retro theme for youtube :kek:

slate swan
pulsar solstice
silk fulcrum
#

asyncpg

pulsar solstice
#

okay let me pip install it

silk fulcrum
silk fulcrum
#

postgres will be overkill for you

pulsar solstice
slate swan
#

finally, it was embed.set_thumbnail(url=member.avatar_url)

silk fulcrum
#

who still uses it

slate swan
pulsar solstice
#

I know I am sounding kind of stupid

sage otter
slate swan
silk fulcrum
sage otter
#

avatar_url doesnโ€™t exist in 2.0

pulsar solstice
silk fulcrum
sage otter
#

Avatars are assets in 2.0

slate swan
sage otter
slate swan
silk fulcrum
#

oh that was the error bruh

silk fulcrum
#

well im stupid

#

as always

pulsar solstice
slate swan
sage otter
#

Idrc tho. Whatever works, works I guess.

silk fulcrum
#

?tag itworks

novel apexBOT
#

This is not a Modmail thread.

silk fulcrum
#

why:(

sage otter
#

RoboDanny doesnโ€™t exist here. ๐Ÿ˜ญ

silk fulcrum
#

@lemon#0001 add RDanny ๐Ÿ˜ญ

#

bruh I almost pinged lemon

slate swan
#

I am gonna ping lemon

primal token
silk fulcrum
#

imagine allowing everyone to ban joe and kick lemon

cerulean shale
#
import discord
import http
import aiohttp
from discord.utils import get
from discord.ext import commands
from aiohttp import ClientSession 

class Chatbot(commands.Cog):

  def __init__(self, bot):
    self.bot = bot

  @commands.Cog.listener()
  async def on_message(self, message):
    cmdChannel = self.bot.get_channel(1008668481484500992)
    inp = message.content
    
    if message.author == self.bot.user:
      return
    
    elif message.channel.id != cmdChannel.id:
      return
    
    else:
      await message.channel.typing()
      async with aiohttp.ClientSession() as cs:
        async with cs.get(f'https://api.popcat.xyz/chatbot?msg={inp}&owner=Ricky&botname=Estelle') as r:
          res = await r.json()
    
    await message.reply(f"{res['response']}")


async def setup(bot):
  await bot.add_cog(Chatbot(bot))
#

can anyone explain? new to this vsc ;-;

#
async def main():
    for file in os.listdir('./cogs'):
        if file.endswith('.py'):
            await bot.load_extension(f'cogs.{file[:-3]}')
            print(f'{file} cog is working!')
slate swan
#

how to get user avatar url in dpy 2.0? since member.avatar_url doesn't work anymore

primal token
# silk fulcrum what?

This server only has bots that serve a good purpose and have a good efficient code base e.g the ones they have created @unkempt canyon for example

silk fulcrum
unkempt canyonBOT
#
Nah.

No documentation found for the requested symbol.

silk fulcrum
#

gah

primal token
#

!d discord.Asset.url

silk fulcrum
#

you understood

unkempt canyonBOT
slate swan
#

thanks

silk fulcrum
cerulean shale
#

master pls ๐Ÿ‘‰ ๐Ÿ‘ˆ

silk fulcrum
#

@cerulean shale do not create a session in on_message async with aiohttp.ClientSession() as cs:

#

that is just complete trash

primal token
silk fulcrum
#

you need only one

primal token
#

i havent watched anime in a few lmao

cerulean shale
cerulean shale
#

its already 10:10 pm rn ;-;

cerulean shale
primal token
#

down bad bro

torn sail
cerulean shale
silk fulcrum
#

i'd save in setup_hook

torn sail
cerulean shale
slate swan
#

someone ever used tornado?

cerulean shale
#

๐Ÿ’€

torn sail
silk fulcrum
#

other master :lmao:

primal token
#

so much masters who is the real master

torn sail
sage otter
silk fulcrum
#

@strong ibexgimme back my nitro

torn sail
cerulean shale
#

anyways what should i do to fix my issue?

primal token
silk fulcrum
slate swan
primal token
cerulean shale
torn sail
cerulean shale
#

or else give me some docs to read ;-;

torn sail
primal token
#

oh nvm its another async lib

silk fulcrum
primal token
cerulean shale
#

๐Ÿ›

#

btw docs pls ๐Ÿฅฒ

slate swan
silk fulcrum
#

i was also thinking of NeverGonnaGiveYouUp

cerulean shale
slate swan
#

!pip tornado

unkempt canyonBOT
#

Tornado is a Python web framework and asynchronous networking library, originally developed at FriendFeed.

cerulean shale
#

hey

#

:)