#discord-bots

1 messages · Page 57 of 1

junior verge
#

idk

tawdry tendon
#

Is it the same with sql and regular Python

torn sail
#

It’s probably very similar

tawdry tendon
#

Ok

junior verge
#

I know how to fork but how to like get it to work etc

silk fulcrum
#

pip install git+your_fork_repo_link

junior verge
#

I know that yes

torn sail
junior verge
#

I don't have an discord.Embed.empty

torn sail
#

The module u are using does

silk fulcrum
#

....

junior verge
#

yeah

#

but how would i change that then if its not in my code?

torn sail
#

So u gotta either ditch the module ore fix it urself

silk fulcrum
#

...

torn sail
#

Fork it on GitHub make the changes then install it

junior verge
#

Needs to be a fork for it tho

torn sail
#

You are gonna fork it

junior verge
#

yes thats what I meant

tawdry tendon
#

I have no clue what I’m doing

torn sail
#

With the fork button

junior verge
#

Yeah

#

But doubt there will even be one

short axle
#

how would i go about making a cmd that gets the users id, channel, and guild then proceed to dump to json

torn sail
junior verge
#

I will just make a new help command ig

torn sail
#

Take it a bit slow

tawdry tendon
torn sail
silk fulcrum
junior verge
torn sail
silk fulcrum
#

im not sure if == works

junior verge
#

for pag

torn sail
junior verge
#

Just making a full new command imo

tawdry tendon
#

?? This is hard for me, damn

#

== didn’t work either

#

It’s probs just me doing everything wrong

silk fulcrum
torn sail
#

Oh then = instead of ==

#

Yeah don’t rush ur self

tawdry tendon
torn sail
#

Well they must have told u the method to do it above

hollow lantern
#

is there a way to do message.content.startswith() but checks what it ends with?

silk fulcrum
#

lol

hollow lantern
#

o

#

alr thanks

slate swan
#

🤣

torn sail
#

Ok I’m gonna go

#

Byebye

silk fulcrum
#

:(

#

bye master

torn sail
#

Have fun

#

Bye other master

short axle
#

bye

silk fulcrum
#

right at the start of the day

tawdry tendon
#

I’ve tried this too

primal token
#

just installed discord on xubuntu and it already says its installation is corrupted kekducky_party

tawdry tendon
#

Oh

#

Semi colon

short axle
#

how would i go about making a cmd that gets the users id, channel, and guild then proceed to dump to json

tawdry tendon
#

Ugh

#

Still doesn’t workkkkkkk

hollow lantern
#

anyone know how to return what the last word in a message is? So like assign it to a variable. Thanks

short axle
#

e = message.content.endswith()

silk fulcrum
short axle
#

alright

hollow lantern
short axle
#

take his

tawdry tendon
#

This is the method but I don’t understand it

silk fulcrum
tawdry tendon
#

Ok

junior verge
#
Color = discord.Color.random()
``` Doesn't this work in 2.0?
limber bison
#

Can a bot press a button Ager a certain time ?

torn sail
junior verge
#

oh

#

used to be Color in 1.7.3 yeah?

torn sail
#

nah it never was

junior verge
limber bison
#

Like
MSG = CTX.send(embed = embed , view= view)
Await Asyncoi.sleep(290)
If msg.view !=none
#press button in view class
Something like this ?

torn sail
#

no i meant the color kwarg

junior verge
#

oh mb lol

limber bison
# torn sail wdym

So there is a game with 2 buttons , is join , second start(only the person how started game can click) now i want if the person started don't click on button for next 3 min it automatically pressed and results comes

#

I build it till 2 buttons without autostart

torn sail
subtle orbit
#

o nvm

torn sail
#
class MyView(discord.ui.View):
    def my_method(self):
        ...
    @discord.ui.button(...)
    async def button(self, ...):
        self.my_method()

async def cmd():
    view = MyView()
    await send(view=view)
    
    #later
    view.my_method()
limber bison
#

This is how this game working, but now tha join count should be more then 4 or owner should start !

torn sail
#

so you want the game to autostart after a certain amount of time?

ember harness
limber bison
ember harness
#

can someone help me pls

limber bison
#

If no one start

#

If it start view will be none

torn sail
limber bison
torn sail
limber bison
limber bison
#

Ohk k 😳

torn sail
#
class GameView(discord.ui.View):
    def __init__(self):
        self.started = False
        super().__init__()
    def start_game(self):
        self.started = True
        print('game is starting')
    @discord.ui.button(label='start')
    async def button(self, inter, button):
        self.start_game()

async def cmd(ctx):
    view = GameView()
    await ctx.send(view=view)
    await asyncio.sleep(60)
    
    if not view.started:
        view.start_game()
slate swan
#

is there a way to see if a user pings someone in a channel? Not specifically the bot, just any other user

sick birch
unkempt canyonBOT
slate swan
#

tyty

torn sail
#

or what robin said

slate swan
#

o

sick birch
#

oh you said any user, my bad

torn sail
#

depends on how u wanna do it

slate swan
#

ye like if i pinged Robin, the bot would see that and say, save robins userid in a variable for example

torn sail
#

i see

sick birch
slate swan
#

Oki ill look into it a bit more when i get home ^^ RosyLove

junior verge
subtle orbit
#

huh

#

for

#

??

unkempt canyonBOT
#

Hey @limber bison!

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

torn sail
torn sail
unkempt canyonBOT
#

Hey @slate swan!

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

terse coyote
#

who know tutorials how to do music bot with spotify?

sick birch
#

At least not AFAIK

slate swan
terse coyote
sick birch
terse coyote
# sick birch No

this bot steaming music from spotify, and i wanna to do similar bot... how to get music from spotify?

sick birch
#

Think you need premium

slate swan
#

why ?

sick birch
#

I’m sure it’s against their TOS

torn sail
limber bison
slate swan
#

.-.

#

i have a host but i'm just coding now !

#

i don't want to waste it for just coding

sick birch
#

If you’re just coding it use VSC

slate swan
sick birch
#

Which are?

slate swan
#

wait

slate swan
sick birch
#

You need to await it

sick birch
slate swan
limber bison
#

U can host things on you pc mean Running a program 24*7 called hosting

slate swan
limber bison
slate swan
limber bison
#

Path variables, take yt tutorials

#

?

slate swan
#

i have

#

i think i will reinstall the vsc

limber bison
#

Hmm try

terse coyote
#

how to see if a member is in a voice channel?

marsh violet
tawdry tendon
#

Ok I’m trying to get users input so I can use it to get what the user wants the permissions to be, I’m learning sql tho

#

Do you need only the basics of sql for this?

#

To use commands

#

So only the basics?

#

What would that do

#

And what’s cursor.expedite

#

Execute*

#

Did you get it from Google?

#

The code

#

How don’t you know what it does tho

#

What does it do?

#

Oh ye that was autocorrect

#

Ok

#

Can I show h my code and you can tell me what to do?

#

@bot.command()
async def permissionpurge(ctx, perm):
await (f"You have chosen to use {perm} as the permission to use the purge command")

@has_permissions(administrator=True)
async def purge(ctx, amount = 1):
await ctx.channel.purge(limit=amount+1)
await ctx.send(f"{amount} messages have been purged!")

#

That’s what I have

#

That’s never gonna work in a 100000 years

#

Rn I have it set to admin so I don’t get errors

#

What I tried to do was get the users argument and use it as the permission they want for people to use that command

slate swan
#
@client.command()
@commands.guild_only()```
#

is there an @ command to only allow admins to use the command

tawdry tendon
#

Oh I though I meant that code was for admin only lol

#

You can do it, yes

#

Sorry I misunderstood you

#

You don’t have to have the .core after.commands

slate swan
#

Oh wow that's awesome

tawdry tendon
#

@ has_role(rolename=True)

slate swan
#

Thank you so much

#

@has_role("Professionals")

tawdry tendon
#

Without the space

tawdry tendon
#

I don’t think it’s like that

#

Does it work?

#

@slate swan can you help me?

slate swan
#

I mean the command works but Idk if it checks if I have the role or not

#

oh yeah it does work

tawdry tendon
#

Ok

slate swan
#

Thank you both so much for all of your help

tawdry tendon
#

has_permissions and has_role have different syntax then

tawdry tendon
terse coyote
#
AttributeError: 'NoneType' object has no attribute 'connect'```
sick birch
#

It means the member is not in a voice channel

#

Or your intents are not configured properly

terse coyote
sick birch
#

Is the user in a voice channel?

terse coyote
winged coral
#

Does the bot have access to view the voice channel?

tawdry tendon
#

Is it possible to make a database table through replit

winged coral
#

Can you create files? If yes, then you can create a database

sick birch
#

doesn't replit have their own shitty database or something

tawdry tendon
#

Idk tbh

winged coral
#

I’d probably use sqlite instead

tawdry tendon
#

I’m only using replit for 24/7 🤣

winged coral
#

Get a cheap VPS

tawdry tendon
#

Is that how a db file looks like

sick birch
#

well the file name and extension doesn't really mean anything

#

it's what's inside of it

tawdry tendon
#

Ok

#

Code?

winged coral
#

Nextcord ☹️☹️☹️☹️

balmy bobcat
#

hi, is there a way to make role menus like this still work even after rebooting the bot?

winged coral
#

You want persistent views, they take use of custom IDs instead of allowing the lib to generate their own

#

Yes there is??

#

Bro 💀

winged coral
tawdry tendon
#

You did the intents and everything on another file @slate swan ?

winged coral
#

No

#

You’re using nextcord

winged coral
#

I don’t use it?

tawdry tendon
#

Did you import it

winged coral
#

So how could I help you

tawdry tendon
#

So…

winged coral
#

No it’s not, it’s not fully typehinted, the code standard is awful, there’s no library consistent formatting, they ignored the predicates set by d.py

tawdry tendon
#

Idk maybe like.. make a class or def

#

Not too sure 🤷‍♂️

sick birch
#

this is one of the downsides of not using a popular fork or d.py itself 😦

fresh iron
#

why doesn't it work when i get message.author.id with this event

sick birch
fresh iron
primal token
#

You should check your intents

#

!d discord.Intents.message_content

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

primal token
#

if you have them activated then the condition isnt true

fresh iron
#

intents are true

primal token
#

can you show them?

fresh iron
primal token
#

Can you show your code? You should change your variable naming as well

primal token
#

the on_message

#

oh wait

#

i just saw the issue uppon looking at it again, the if statement you used to compare ids will never be true as youre comparing an int with a string, User.id | Member.id return ints

fresh iron
#

ahh data type error

primal token
#

yeah 😅

primal token
#

remove the quotes in the condition so youre comparing the same data type lol

red kernel
#

in order to run pip install discord do you have to have the discord app or can it be the browser version

vagrant brook
#

you dont need any of those

pulsar bridge
#

I hath returned!

Making a section of code that splits a message sent into individual words and then tries to add an emoji to that message based on the words used.
e.g. If I said "I love cookies and cats" it would add both the 🍪 and 🐱 emoji as a reaction to that message

I've got this so far --

scan_reactions = lowered_message.split(' ')
 print(scan_reactions)
 for x in scan_reactions:
     print(f':{x}:') # Debug
      await message.add_reaction(x)```
**Questions**
How do I make the code continue running even if it runs into the "Emoji not found" Error?

What am I supposed to put in 'x' within `await message.add_reaction(x)` cause it doesn't like strings like 'cookie' or '\:cookie\:'  

And lastly, what's the best way of doing things like synonyms? 
E.g. having 'love' in the message would add the ❤️ (\:heart\:) reaction
I think I've got a way, but it would be extremely inefficient
potent spear
# pulsar bridge I hath returned! Making a section of code that splits a message sent into indi...

you'd loop through every word and find the key value structure in a json format or DB which stores the emoji
example

{
"love": ":love:",
"like": ":thumbsup:"
}```
```python
some_message = "I love you"
new_message_words = []
for word in some_message.split(" "):
  replaced_emoji = data.get(word.lower()) or word
  new_message_words.append(replaced_emoji)
new_message = " ".join(new_message_words) # "I :love: you"

you could replace the value with a unicode of the emoji or whatever

slate swan
#
import discord
from discord.ext import commands

TOKEN = ''

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


@bot.event
async def on_ready():
  print('I am running!')

@bot.command()
async def hello(ctx):
  await ctx.reply('Hello There! 👋')



bot.run(TOKEN)```

I keep getting this error (yes i am ware that the token variable is blank, thats because I dont want others to get my bot's token lol): ```Traceback (most recent call last):
  File "main.py", line 6, in <module>
    bot = commands.Bot(command_prefix='?')
TypeError: __init__() missing 1 required keyword-only argument: 'intents'```
potent spear
slate swan
#

you need to add message_content intents

potent spear
slate swan
#

connectodb is not a Bot method

#

its a simple coroutine here

slate swan
#

if you know why would you use it as bot.connectodb

potent spear
#

error says it all, you're calling a method connecttodb() which isn't a method of the bot class

slate swan
#

subclass Bot class and add that method to your bot

potent spear
#

you most likely want to extend your bot class and add the method there

balmy bobcat
#

hi! how can I allow only one person to interact with the bot drop down role menu?

#

only works on interactions

#

it's not like I haven't tried

#

yeah

#

I wanted it to be ephemeral but it's not possible so I want to restrict it to the person who triggers it

slate swan
#

!d discord.ui.View 1 minute

unkempt canyonBOT
#

class discord.ui.View(*, timeout=180.0)```
Represents a UI view.

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

New in version 2.0.
balmy bobcat
slate swan
unkempt canyonBOT
#

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

A callback that is called when an interaction happens within the view that checks whether the view should process item callbacks for the interaction.

This is useful to override if, for example, you want to ensure that the interaction author is a given user.

The default implementation of this returns `True`.

Note

If an exception occurs within the body then the check is considered a failure and [`on_error()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.View.on_error "discord.ui.View.on_error") is called.
slate swan
#

yes

#

wtf is that?

#

its discord.ext.commands.Bot

#

depends on your imports...

elfin moon
#

Why does my command appear twice and how do i fix it

slate swan
#

show code

slate swan
#

nice database

#

oh you removed the password good

fresh iron
#
@client.command()
async def search(self, ctx, query: Option(str)):
        msg = await ctx.respond(f"Searching...🔍")
        embed = discord.Embed(title=f"Search results", description=f"Query: {query}")
        for j in search(query, num=5, stop=5, pause=2):
            embed.add_field(name="Search result:", value=j)
        await msg.edit(embed=embed)
        ```
#

what's the error here

slate swan
cerulean shale
slate swan
#

its still not a bot class method

#

learn OOP

slate swan
cerulean shale
#

OOPs concept 💀

fresh iron
cerulean shale
#

Oh-

slate swan
#

learn oop and how to subclass objects. I'm not spoonfeeding

slate swan
# slate swan show your intents code and bot var
import discord
from discord.ext import commands

TOKEN = ''

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

client = commands.bot(command_prefix=';', intents=intents)


@client.event
async def on_ready():
  print('I am running!')

@client.command()
async def test(ctx):
  await ctx.reply('Hello There! 👋')



client.run(TOKEN)```
slate swan
#

add intents.message_content = True before client = ...

fresh iron
slate swan
cerulean shale
#

^

#

Query is missing as in the required argument is missing

slate swan
cerulean shale
#

What are some good and cheap bot hosting services? I used to use uptime bot when I used to use replit but I shifted over to vsc so yeah 💀

sage otter
#

There’s a thread about that in this channel

#

Labeled discord-bot-hosting

slate swan
#

self host ~

woven imp
#

Hey

#

I sarth#0460 need help

#

Nmakeing discord bot

slate swan
woven imp
#

Making discord bot

#

Someone said to or

slate swan
#

Do you really think you are ready for it?

woven imp
#

I'll get banned

slate swan
#

Banned from what?

woven imp
#

y9#8009 sure I've code before not python tho

#

y9#8009 sever

mystic lotus
#

you need to learn python first

woven imp
#

And they infriend

#

gibbiemonster#6242 no now

#

I'll pay it farward

mystic lotus
woven imp
#

Plz

slate swan
#

!resources

unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

woven imp
#

Nono

slate swan
woven imp
#

Someone do it plz

mystic lotus
#

nobody will do that here

woven imp
#

What u want

slate swan
woven imp
#

Why

mystic lotus
slate swan
#

Read the rules

woven imp
#

Help

#

I'm recording

slate swan
woven imp
#

I have to do this in 24

#

Hrs

#

Plz

slate swan
#

I don't know what your situation is but no ones gonna make you a bot here

woven imp
#

I'd mind working just need help with strings

#

y9#8009 plz

mystic lotus
#

look man, python discord bots are really easy to do nowadays. Take the python tutorial and make a bot. Worst case scenario you don't finish in 24hrs

woven imp
#

Ok if I don't finish 24 hrs

slate swan
woven imp
#

Nonon

mystic lotus
#

Literally nobody will make you a bot

woven imp
#

@slate swan ok

#

I forgot

#

Thanks

#

Finally I made it

#

Thanks guys

slate swan
#
print("Hello") # string
print('Hello') # string
woven imp
slate swan
woven imp
#

Author bot

slate swan
woven imp
#

Yes

#

I wrote in java

slate swan
#

you are confusing

woven imp
#

Phone sucks

#

Python sucks

mystic lotus
woven imp
#

Sorry it's hard

slate swan
#

take your time typing

mystic lotus
#

you're so confusing

woven imp
#

@mystic lotus only know java

#

Not python

mystic lotus
#

any Java dev should pick up python easy

slate swan
woven imp
#

Thanks

mystic lotus
woven imp
#

Java fresh

#

Free java

slate swan
primal token
woven imp
#

I love ujava

slate swan
#

how do i mention a user with a discord bot?

woven imp
#

Thank you

#

@slate swan on java or pthyon

slate swan
primal token
unkempt canyonBOT
slate swan
woven imp
slate swan
woven imp
#

Nvm

#

Well since Noone helps

#

Plz least time idk python

#

I need people

#

Not viedo

slate swan
woven imp
#

@slate swan

mystic lotus
woven imp
#

Plz help a little

#

Got in general vc

primal token
#

the animation when receiving a message on the new mobile client is so unfluent

woven imp
#

Vc 1

slate swan
mystic lotus
woven imp
#

Plz

#

Talk

#

Y9

slate swan
#

Learn some basic python, you won't be able to make a discord bot without knowing at the very least the basics @woven imp

mystic lotus
#

nobody is making you a bot - do it yourself or find one that works for you

woven imp
#

I younot help I'll find someone else

primal token
slate swan
woven imp
#

That's what I should do

mystic lotus
#

we'd be more than glad to help you if you actually make a bot and you actually made some code

woven imp
#

I'll find someone that knows python.

primal token
woven imp
#

Ik

slate swan
primal token
#

not including me

woven imp
#

No they dont

slate swan
woven imp
#

Only noid

primal token
#

what

woven imp
#

@slate swan show me

slate swan
#

Show you what?

woven imp
#

Bro thinks he's cool

slate swan
#

What?

woven imp
#

Show me you're work

#

You so call python

slate swan
#

what is this chat bro 😭

#

Why do I have to show you anything?

primal token
#

This whole chat is confusing me more than a level i can comprehend

woven imp
#

@slate swan bro sraced

slate swan
#

kick the dude or something

mystic lotus
woven imp
#

Can't do anything my guy

slate swan
#

<@&831776746206265384> I think he may be trolling, not to sure..

woven imp
#

Wow

#

Troll is allowed

#

And u no ping mod

primal token
woven imp
#

I'm playing with u

mystic lotus
#

you do have to be trolling there's no way none of this makes sense

woven imp
#

But why not help

#

If help I'll stop

slate swan
mystic lotus
primal token
mystic lotus
#

worded*

slate swan
#

Look man, if you are somehow serious, you need to know at the very least the basics or you're gonna be coming back here every 5 minutes for help @woven imp

woven imp
#

Ok

primal token
slate swan
woven imp
#

If that's doesn't work you guys are try hard that think their cool

#

Bit not

slate swan
woven imp
#

Sigh

slate swan
woven imp
#

Help me bless their little dirt hearts

primal token
#

i'm correct.

mystic lotus
woven imp
#
 await channel.send(discord.User.mention)```
#

Yes where the bot

#

Where

#

Come out

mystic lotus
#

he has to be trolling

woven imp
#

How

mystic lotus
#

there's no way

woven imp
#

How bot come out

#

It rake 24

primal token
#

What are you gaining by trolling? Happiness? because to me its sad that youre wasting your time here trolling

slate swan
primal token
slate swan
#

im hella confused lol

slate swan
slate swan
woven imp
#

Jit can't even code

#

How biut battle

mystic lotus
#

shut up Mr Minecraft pfp

woven imp
#

Code battle

primal token
sick birch
#

I think this has gone on for long enough. Please read the #rules and the #code-of-conduct and be respectful to other memebrs

woven imp
#

Ok

sick birch
#

Thank you 😄

woven imp
#

But

sick birch
#

Now, shall we get back on topic?

woven imp
#

Listen out

sick birch
#

No, let's not prolong this any further

#

Drop it and move on

woven imp
#

Real quick I need help

#

With pythom

sick birch
#

If you've got an actual question, we'd be more than happy to help

woven imp
#

Thanks

#

Tutorial doesn't help

sick birch
woven imp
#

I need more explanation

primal token
#

Make robin a moderator so then hes more vulnerable to being ban due to his behaviors and actions at such a high level in the role higherarchy

woven imp
#

Some kid sent tutorial that is useless

primal token
woven imp
#

In my sever

#

But it doesn't work

#

I need more info

sick birch
#

Ask the question

primal token
#

did you actually read the whole tutorial?

slate swan
woven imp
primal token
#

You cant blame a tutorial if you never read it.....

sick birch
woven imp
#

In depth about general of python

potent spear
#

wrong channel

woven imp
#

I code java

mystic lotus
woven imp
#

Not python

slate swan
woven imp
#

@mystic lotus idc

#

Well gtg

primal token
sick birch
#

Erm.. okay?

#

If you've got any questions feel free to open up a help channel

slate swan
mystic lotus
sick birch
mystic lotus
primal token
#

btw have you guys seen the new feature about slash commans mentioning? looks cool

sick birch
#

If you're just mentioning someone an ID will suffice

mystic lotus
#

Haven't really used it yet though

slate swan
#

some people still prefer old prefixes rather than slash commands

primal token
#

you can get the commands id when invoking it

sick birch
#

let me try in a test server

mystic lotus
#

oh that is so cool!

sick birch
#

HTML closing tag type shit

mystic lotus
#

lol

primal token
#

no but it actually looks like html tags kek

sick birch
#

fr

primal token
#

You know what else looks like a html tag? || not your mom ofc ||

mystic lotus
#

legit have no idea how to get a slash command id

#

someone help

primal token
mystic lotus
#

aw it's not on mobile yet

sick birch
primal token
#

if youre on mobile its probably holding your finger on the blue text btw

slate swan
#

@primal token Is your pfp Hiro ?

primal token
#

No its 016

#

kekducky_beer

slate swan
#

that's hiro's code iirc

primal token
#

yes

slate swan
#

I didn't even finish that anime

primal token
#

smh

#

still waiting for season2😔

slate swan
#

I watched 6 episodes

mystic lotus
#

Yeah doesn't look like it's here on mobile yet

primal token
mystic lotus
#

I did

primal token
#

when you invoke the command it will send a response message

mystic lotus
#

when you tap on the blue text that menu comes up

fresh iron
slate swan
primal token
#

reason why mobile client is trashducky_beer

mystic lotus
#

meh, oh well

slate swan
#

I hate the mobile client

mystic lotus
#

I'll look at it tomorrow

slate swan
#

slash commands don't even work half the time

mystic lotus
primal token
#

canary > any client

#

😳

slate swan
#

I use the one you download from the discord website

mystic lotus
#

off topic but surprised discord doesn't allow 3rd party mobile clients

primal token
mystic lotus
#

see if only people didn't actually just suck lol

#

there's always that one guy

primal token
#

its not really exploiting but some plugins can see a users current device

mystic lotus
#

okay it's 12am I should probably sleep now

#

adios

primal token
#

people say its not a problem using modded clients until they catch your token uppon making a request and some also just take your logging info kek

slate swan
#
    if user == None:
        user = ctx.author

these are equal right?

user = user or ctx.author
primal token
#

or checks if the first values boolean value is Falsy while the first check if the value is None

#

!e

print(False or True)
unkempt canyonBOT
#

@primal token :white_check_mark: Your 3.11 eval job has completed with return code 0.

True
slate swan
primal token
#

yeah, but it would depend if youre checking specific types no matter there boolean value

slate swan
#

can't you oneline check if it's None too?

primal token
#

the only reason why the second check would work is because None's boolean value is False and it doesnt check identities

slate swan
#

like a different way though

paper sluice
primal token
slate swan
primal token
#

!d is

unkempt canyonBOT
#
is

6.10.3. Identity comparisons

The operators is and is not test for an object’s identity: x is y is true if and only if x and y are the same object. An Object’s identity is determined using the id() function. x is not y yields the inverse truth value. 4

primal token
#

it checks identity over value

#

!e

print(0==False, 0 is False)
unkempt canyonBOT
#

@primal token :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | <string>:1: SyntaxWarning: "is" with a literal. Did you mean "=="?
002 | True False
paper sluice
#

is just checks if the object on the left and right are exactly the same, or are pointing to the same thing. None is singleton i.e only one instance of it is created so we is here instead of ==

slate swan
#

How can I like make a command which is available in both slash commands and prefix?

paper sluice
#

hybrid commands

slate swan
#

Any example?

primal token
elfin moon
#

i have a problem where a slash command appears twice, I kicked and added it back and it was a single command now but when i ran it, it created an error

#

then when i restarted the bot there are repeated commands again

potent spear
#

don't autosync I'd say

slate swan
#

any help?

potent spear
#

or better yet, update
since you're most likely on v1.7.3, and discord ui is for dpy v2

slate swan
slate swan
primal token
#

I was thinking of making message collectors that can be used with decorators and can take arguments like, per message, per channel and per guild collectors, and the function when decorated gets called and passes one argument being, a list with tuples, which each tuple has the time when the message was sent and the message, i was also thinking of having a content checker to only collect messages with a certain content and i was also thinking of being able to provide regex patterns anyone want to work on it with me?

elfin moon
primal token
rugged shadow
primal token
#

you can always make a pr lol

pliant gulch
#

I remember making my own collectors for my own discord API wrapper

primal token
#

same

#

i stopped after making the message modelducky_beer

pliant gulch
primal token
#

making a wrapper is easy its just models are a pain

#

and making good abstractions and having a good codebase

pliant gulch
#

Models easy, good codebase is somewhat harder

#

It's quite a task to keep everything in order

primal token
#

that is so

primal token
pliant gulch
#

To bad the wrapper is dead

primal token
#

i only made base models and my message model then i stop developing the wrapper because of so much endpoints and especially how much rewrites i needed to do, i always wanted a good codebase and modular abstractions

#

modular as in not bounded to any bad abstraction

vocal snow
pliant gulch
#

Instead of hard coding the endpoints just make it procedural

#

Don't do a discord.py and have like a 1k+ line file just for HTTP

primal token
#

kek, my HTTP client was only like 72 ish lines

pliant gulch
#

Maybe if you do 70% I'll do the other 30% 🥺

primal token
#

and was modular so you couldve used it for any other request handling over dpys that passes your token on to each header per request

slate swan
#

🗿my rest/client.py is like 700 lines atm ( including docs )

maiden fable
pliant gulch
#

Typical HTTP client

#

Mine uses semaphores for concurrent ratelimit handling

#

😏

primal token
#

mine just used locks kek

slate swan
#

haven't touched my code since 10 days

maiden fable
#

haven't touched coding since 3 months

slate swan
#

won't be coding for another year

maiden fable
#

I've been touching grass 💅

primal token
#

i havent touched mine in maybe 4 months or more

primal token
maiden fable
#

Why tf won't u code now 😐

primal token
#

im not in university but its a pain lol

vocal snow
#

need like 98%+ to get in iit

maiden fable
#

Niceee
I forgot he's our Einstein

slate swan
primal token
#

kek

slate swan
#

msg = await ctx.send(“hi”)
How can I delete this message ?

sick birch
sick birch
slate swan
#

And for bot.msg = await ctx.send. . .
It would be await bot.msg.delete()?

silk fulcrum
#

hi

sick birch
#

hello there

primal token
#

General kenobi

echo wasp
# sick birch hello there

can you help me with slash commands? I am doing a test on a bot i contribute to and testing a command i get this error ```py
Traceback (most recent call last):
File "/home/maskuhpq/.local/lib/python3.9/site-packages/discord/app_commands/commands.py", line 851, in _do_call
return await self._callback(interaction, **params) # type: ignore
File "/home/maskuhpq/status/bot.py", line 114, in add
if interaction.guild.me.server_permissions.manage_channels == False and lock == False:
AttributeError: 'Member' object has no attribute 'server_permissions'

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

Traceback (most recent call last):
File "/home/maskuhpq/.local/lib/python3.9/site-packages/discord/app_commands/tree.py", line 1240, in _call
await command._invoke_with_namespace(interaction, namespace)
File "/home/maskuhpq/.local/lib/python3.9/site-packages/discord/app_commands/commands.py", line 876, in _invoke_with_namespace
return await self._do_call(interaction, transformed_values)
File "/home/maskuhpq/.local/lib/python3.9/site-packages/discord/app_commands/commands.py", line 869, in _do_call
raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'add' raised an exception: AttributeError: 'Member' object has no attribute 'server_permissions'```

silk fulcrum
primal token
echo wasp
echo wasp
silk fulcrum
#

they dont change everything

#

only a couple of things

echo wasp
#

ok so what should that read? py if interaction.guild.me.guild_permissions.manage_channles == False and lock == False: await interaction response.send_message("") return

echo wasp
silk fulcrum
#

what is wrong with that

#

oh yeah

echo wasp
silk fulcrum
#

you removed a lot for some reason

echo wasp
silk fulcrum
#

it's guild_permissions instead of server_permissions

#

and you removed guild.me for some reason

echo wasp
silk fulcrum
#

will you try it?

echo wasp
echo wasp
# silk fulcrum sooo?
Traceback (most recent call last):
  File "/home/maskuhpq/.local/lib/python3.9/site-packages/discord/app_commands/commands.py", line 851, in _do_call
    return await self._callback(interaction, **params)  # type: ignore
  File "/home/maskuhpq/status/bot.py", line 114, in add
    if interaction.guild.me.guild_permissions.manage_channles == False and lock == False:
AttributeError: 'Permissions' object has no attribute 'manage_channles'

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

Traceback (most recent call last):
  File "/home/maskuhpq/.local/lib/python3.9/site-packages/discord/app_commands/tree.py", line 1240, in _call
    await command._invoke_with_namespace(interaction, namespace)
  File "/home/maskuhpq/.local/lib/python3.9/site-packages/discord/app_commands/commands.py", line 876, in _invoke_with_namespace
    return await self._do_call(interaction, transformed_values)
  File "/home/maskuhpq/.local/lib/python3.9/site-packages/discord/app_commands/commands.py", line 869, in _do_call
    raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'add' raised an exception: AttributeError: 'Permissions' object has no attribute 'manage_channles'``` instead
echo wasp
silk fulcrum
#

should be channels

echo wasp
#

i didn't code it so just making the bot work before prod lol

#

because i contribute

echo wasp
#

wait nvm

#

it went

#

this error is on me i think it is a mongodb error lol

echo wasp
silk fulcrum
echo wasp
silk fulcrum
#

of the command

#

and do you have an error handler?

echo wasp
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

echo wasp
#

the error that came slow

echo wasp
silk fulcrum
echo wasp
silk fulcrum
echo wasp
silk fulcrum
echo wasp
silk fulcrum
#

and by the way, use async db to not block the asyncio event loop

#

that might a problem too

primal token
silk fulcrum
echo wasp
silk fulcrum
#

what

silk fulcrum
primal token
maiden fable
#

It's normal here

echo wasp
silk fulcrum
primal token
#

go to sleep again

maiden fable
#

Yr brain is still sleeping

silk fulcrum
#

oooo Master Oogway in Training is online already

#

but not here

primal token
# silk fulcrum why?

You need a restart or else your brain processes will crash due to memory corruption

primal token
#

kek

maiden fable
silk fulcrum
#

maybe ill go play minecraft

maiden fable
#

Phew, at least u ain't Windows, that can't fix a single thing if it crashes

primal token
silk fulcrum
primal token
#

i never get errors, because i am the error kek

silk fulcrum
#

aight, gonna play minecraft, ping me when @cerulean shale comes here

#

(right now cus i pinged him)

echo wasp
#
    @app_commands.command(description="Get the down message for your bot")
    @app_commands.describe(member="The user to get the down message for")
    async def config(self, interaction: discord.Interaction, member: discord.Member):
        user = bot.get_user(member.id)``` it says bot is not defined
silk fulcrum
echo wasp
silk fulcrum
#

what do you have in __init__ of the cog

maiden fable
#

Just use interaction.client

#

!d discord.Interaction.client

unkempt canyonBOT
#

property client```
The client that is handling this interaction.

Note that [`AutoShardedClient`](https://discordpy.readthedocs.io/en/latest/api.html#discord.AutoShardedClient "discord.AutoShardedClient"), [`Bot`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot"), and [`AutoShardedBot`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.AutoShardedBot "discord.ext.commands.AutoShardedBot") are all subclasses of client.
echo wasp
# silk fulcrum what do you have in `__init__` of the cog
Traceback (most recent call last):
  File "/home/maskuhpq/.local/lib/python3.9/site-packages/discord/app_commands/commands.py", line 850, in _do_call
    return await self._callback(self.binding, interaction, **params)  # type: ignore
  File "/home/maskuhpq/status/cogs/misc.py", line 52, in config
    user = self.bot.get_user(member.id)
AttributeError: 'Misc' object has no attribute 'bot'

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

Traceback (most recent call last):
  File "/home/maskuhpq/.local/lib/python3.9/site-packages/discord/app_commands/tree.py", line 1240, in _call
    await command._invoke_with_namespace(interaction, namespace)
  File "/home/maskuhpq/.local/lib/python3.9/site-packages/discord/app_commands/commands.py", line 876, in _invoke_with_namespace
    return await self._do_call(interaction, transformed_values)
  File "/home/maskuhpq/.local/lib/python3.9/site-packages/discord/app_commands/commands.py", line 869, in _do_call
    raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'config' raised an exception: AttributeError: 'Misc' object has no attribute 'bot'
silk fulcrum
#

🤢 Danny him self named it client

maiden fable
#

Everyone hates that but Danny ¯_(ツ)_/¯

silk fulcrum
#

of the cog'

maiden fable
#

He has nothing

vocal snow
#

what else would you call it

maiden fable
#

At least no self.bot

maiden fable
#

What the fuck

echo wasp
# silk fulcrum what's in your `__init__`
import discord
from discord import app_commands
from pymongo import MongoClient
import os
# database connection
cluster = MongoClient(os.environ.get("mongo"))
db = cluster["discord"]
collection = db["status"]

class Misc(app_commands.Group):
    """Misc commands"""
``` not there
#

that it then to commands

vocal snow
silk fulcrum
maiden fable
#

!d disnake.Interaction.bot

unkempt canyonBOT
#

property bot```
The bot handling the interaction.

Only applicable when used with [`Bot`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.Bot "disnake.ext.commands.Bot"). This is an alias for [`client`](https://docs.disnake.dev/en/latest/api.html#disnake.Interaction.client "disnake.Interaction.client").
maiden fable
#

It did take time. Nice

echo wasp
#

cough cough

maiden fable
#

But eh, ig Danny doesn't really care 🤷‍♂️

maiden fable
silk fulcrum
maiden fable
#

interaction.client, not bot

silk fulcrum
#

istead of bot

maiden fable
silk fulcrum
maiden fable
#

🤷‍♂️

#

I don't code anymore

silk fulcrum
#

burh

maiden fable
#

Or at least haven't coded since a few months

echo wasp
maiden fable
#

Code

echo wasp
# echo wasp lovely a application didn't respond but no errors in console lol

you know i say that and the console spits one out ```py
localhost:27017: [Errno 111] Connection refused, Timeout: 30s, Topology Description: <TopologyDescription id: 63085f7ed07bc127e921d54c, topology_type: Unknown, servers: [<ServerDescription ('localhost', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('localhost:27017: [Errno 111] Connection refused')>]>

maiden fable
#

Huh

echo wasp
#

what i said

#
    @app_commands.command(description="Get the down message for your bot")
    @app_commands.describe(member="The user to get the down message for")
    async def config(self, interaction: discord.Interaction, member: discord.Member):
        user = interaction.client.get_user(member.id)
        try:
            results = collection.find()
            for result in results:

                if str(result["_id"]) != str(user.id):
                    await interaction.responce.send("Hm I can't find that bot in my database!")
                    pass
                else:
                    for query in result:
                        if str(query) == "_id":
                            pass
                        else:
                            server = result[query]
                            channel = interaction.client.get_channel(server[0])
                            down_message = server[2]
                            auto_publish = server[3]
                            lock = server[5]
                            embed=discord.Embed(title="Config", description="Shows the config of the selected user")
                            embed.add_field(name="Down Message", value="{down_message}", inline=True)
                            embed.add_field(name="Channel set", value="<#{channel.id}>")
                            embed.add_field(name="Auto Publish", value="Auto Publish is set to {auto_publish}", inline=False)
                            embed.add_field(name="Lock", value="Locking the server is set to {lock}", inline=True)
                            await interaction.response.send_message(embed=embed)
        except Exception as e:
            print(e)
            pass```
echo wasp
silk fulcrum
#

still not async db

echo wasp
#

The Aplication no respond without that last error

echo wasp
echo wasp
# silk fulcrum still not async db

also the console spit up this ```py
localhost:27017: [Errno 111] Connection refused, Timeout: 30s, Topology Description: <TopologyDescription id: 63086050a98638b71e78bbb9, topology_type: Unknown, servers: [<ServerDescription ('localhost', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('localhost:27017: [Errno 111] Connection refused')>]>

primal token
#

It raised that error as you arent hosting your mongodb server, thats what i can assume as mongodb's default port is 27017

echo wasp
#

It is fine with the connection string I used on other commands

primal token
echo wasp
#

Wait do I need to define the database again in the cog let me try that

echo wasp
echo wasp
# silk fulcrum still not async db

yo i have a question i defined how to connect to the database so why is it attempting local host when the connection string isn't local host?

slate swan
#

await interaction.response.send_message("test") AttributeError: 'Button' object has no attribute 'response'

#
@ui.button(label="test",style=discord.ButtonStyle.green)
    async def menu1(self,button:ui.Button,interaction:discord.Interaction):
        await interaction.response.send_message("test")```
#

any idea?

potent spear
slate swan
#

what's wrong?

potent spear
#

I just told you...

slate swan
#

what's wrong in my order of args

potent spear
#

flip button and interaction

fast thunder
#

Can someone help me i have a discord.py pterodactyl egg but its not working

slate swan
#

oh yeah it works now, thanks!

potent spear
#

nope
I suppose you mean "store"

#

on_message can handle that perfectly fine

slate swan
#

like to store all messages into some database?

potent spear
#

not really... for what purpose?

slate swan
potent spear
#

just storing the ID is all you'd need

#

unless you want to "snipe" them

#

~ recover when deleted

slate swan
#

better to get the message content too imo

slate swan
potent spear
#

then I'd just store it when on_message_delete gets called...

#

so you'd have a DB of "deleted messages" that might have explicit language or whatever

slate swan
#

yeah perhaps

#

you probably don't want to use text files as a database

potent spear
#

well, just use channel.history() for that...

#

if it's well structured and ACTUALLY in a db instead of a txt, then sure ig

slate swan
#

I wouldn't say it's bad practice

#

pretty sure a lot of bots do it

#

like ticket bots save transcripts etc

#

Yeah

#

never recommend storing stuff in json or text files

#

I'm not too sure probably a good choice

#

I usually hear about sql and mongo

#

I don't know much about any of them

#

good luck

potent spear
#

the async wrapper ~asqlite or aiosqlite preferably

drifting arrow
#

Is it possible to keep an active connection to a server using a discord bot?

silk fulcrum
#

hey m back

drifting arrow
drifting arrow
slate swan
#

Hi @silk fulcrum i have quetion. I'm imported file config.py and system created this folder:

#

is it normal?

slate swan
keen talon
#

yeah, python keeps creating cache

silk fulcrum
drifting arrow
#

rcon, remote connection to a server lol

slate swan
silk fulcrum
#

so what's the problem?

drifting arrow
silk fulcrum
#

as i see it has async support

#

so everything's gud

drifting arrow
#

hhmm

#

but terminating the connection is an issue xD

drifting arrow
#

i tried test code and my cmd just stops working

#

brb figuring it out

potent spear
#

mhm

vale wing
# slate swan is it normal?

Yes and you can disable its creation if you want to by setting the env var PYTHONDONTWRITEBYTECODE to any non-empty string

pulsar bridge
#

Could I compare something to every variable in a list instead of individually writing everything out in a long if statement?
E.g.
If I wanted a command to not run in a few different channels, then I could do

if channel.id != channel_id_1 and channel.id != channel_id_2 and... and channel.id != channel_id_30 and...:
Do stuff

or, could I do something like:

channel_ids = [
id_1,
id_2,
id_3,
...
id_20,
]
if channel.id != channel_ids:
Do stuff
pulsar bridge
#

oh my lord

#

I'm an idiot facepalm1

#

Thanks for that MeguDed

silk fulcrum
#

lmao shit happens

#

np

vale wing
#
all(id in your_list for id in ids)```
pulsar bridge
#

The stupid thing is that I legit just used that in a command I wrote an hour or so ago MeguDed

silk fulcrum
pulsar bridge
#

Wouldn't master's work though?

silk fulcrum
#

that's if he had two list of ids

#

but he wants to check if one id is in the list

vale wing
#

Ok

pulsar bridge
#

Thanks again, Master! MiyanoHey

vale wing
#

That wasn't for him

vale wing
#

I was just typing random stuff

silk fulcrum
#

oh ok

#

why was there _ы_

vale wing
#

ы is a nice letter

silk fulcrum
vale wing
#

In my code I name all the variables starting with ы

silk fulcrum
vale wing
#

Public names start with single ы, protected with two and private with three. Static ones always end with ы

#

And constants start with capital Ы

silk fulcrum
#

my gosh what the heck is all that

pulsar bridge
silk fulcrum
#

that has logic

pulsar bridge
#

Rxh's method has logic

#

sorts things out nicely

vale wing
#
ы_id = 123748294959029284747 ########## ыыыыы ыыы ыыыыыыыы```
silk fulcrum
#

Rxh's

vale wing
#

Can't you read base64 encoded strings

silk fulcrum
pulsar bridge
silk fulcrum
#

ъуъ_guild = 56789865678876

vale wing
#

!e import base64
print(base64.urlsafe_b64decode(b'RXhlbmlmaXg=').decode())

unkempt canyonBOT
#

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

Exenifix
silk fulcrum
pulsar bridge
#

Would you call me Nexus or copy paste my actual username?

vale wing
#

I would call you in base64

pulsar bridge
#

;-;

silk fulcrum
#

kall me by nick @pulsar bridge

vale wing
#

!e import base64
print(base64.urlsafe_b64encode(b"Nexus").decode())

unkempt canyonBOT
#

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

TmV4dXM=
pulsar bridge
vale wing
#

Hello TmV4dXM=

silk fulcrum
pulsar bridge
#

Aight, lets stay on topic

#

Imma go do code

#

ciao

vale wing
#

Hey guys how can I make a discord bot only using socket builtin

silk fulcrum
glad cradle
#

why everyone says ciao

vale wing
#

Okay good idea

silk fulcrum
glad cradle
silk fulcrum
glad cradle
#

it's Italian

silk fulcrum
#

well if from italian then hi

slate swan
#
@bot.command(name="test", description="jakiś")
@has_permissions(administrator = True)
async def test(ctx, member: disnake.Member):
    await ctx.member.send("siema")```

how to send a message for this object member?
silk fulcrum
#

if in english its synonim to bye

pulsar bridge
silk fulcrum
glad cradle
silk fulcrum
#

ctx.yomama

glad cradle
#

!e import base64
print(base64.urlsafe_b64encode(b"<Snipy object at 0x7e66f0b1f0>").decode())

unkempt canyonBOT
#

@glad cradle :white_check_mark: Your 3.11 eval job has completed with return code 0.

PFNuaXB5IG9iamVjdCBhdCAweDdlNjZmMGIxZjA-
silk fulcrum
#

ctx.test

slate swan
#

thanks boys

silk fulcrum
#

ctx.db

silk fulcrum
vale wing
#

Hey PFNuaXB5IG9iamVjdCBhdCAweDdlNjZmMGIxZjA-

glad cradle
#

it's too long

#

😭

vale wing
#

I have another idea

silk fulcrum
#

!e py import base64 print(base64.urlsafe_b64encode(b"Master32").decode())

unkempt canyonBOT
#

@silk fulcrum :white_check_mark: Your 3.11 eval job has completed with return code 0.

TWFzdGVyMzI=
glad cradle
rugged shadow
#

imagine some social media actually uses the b64 of usernames as tokens

vale wing
#

!e import hashlib
print(hashlib.sha256(b"Exenifix").hexdigest())

unkempt canyonBOT
#

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

9047064c7ec960627a11743bfa49b0af3e8dd702ef771cec3e908b5cd28b477e
vale wing
#

Let's call each other by our sha256

silk fulcrum
#

oof