#discord-bots

1 messages · Page 641 of 1

sick birch
#

Find and replace

#

It does a swell job

maiden fable
#

Yea

slate swan
#

Very handy

sick birch
#

Even notepad has it

tawdry perch
#

wrong, the ["discord"]

sullen shoal
#

another way would be to use sys.modules btw

maiden fable
sullen shoal
#

!d sys.modules

unkempt canyonBOT
#

sys.modules```
This is a dictionary that maps module names to modules which have already been loaded. This can be manipulated to force reloading of modules and other tricks. However, replacing the dictionary will not necessarily work as expected and deleting essential items from the dictionary may cause Python to fail. If you want to iterate over this global dictionary always use `sys.modules.copy()` or `tuple(sys.modules)` to avoid exceptions as its size may change during iteration as a side effect of code or activity in other threads.
sullen shoal
#

change disnake to discord

maiden fable
#

Ah

tawdry perch
sullen shoal
#

no need to replace imports or change it afaik

maiden fable
sullen shoal
#

if you do it in main file

tawdry perch
#

My English has just broken down, I'll try to talk later

sick birch
#

story of my life

tawdry perch
#

indeed

maiden fable
#

Anyways hi there Robin. Long time :D

slate swan
#

Wdym???

maiden fable
#

!d discord.Guild.created_at

unkempt canyonBOT
maiden fable
#

And that's a property

slate swan
#

Ohhh i thought he ment a event

maiden fable
#

Lol it's fine, got ya covered

jagged root
#
py
#suggest
@bot.command()
async def suggest(ctx, *, query):

    embed = discord.Embed(
        color=0xff0000,
        description=
        f":bust_in_silhouette: ❘ **User:** {ctx.author.mention}\n\n:bulb: ❘ **Suggestion:**\n\n{' '.join(ctx.message.content.split(' ')[1:])}")

    if "!suggest + your suggestion here." not in ctx.channel.topic:
        return

    embed.set_thumbnail(url=ctx.author.avatar_url)
    channel = bot.get_channel(867484283526578256)
    msg = await channel.send(embed=embed)
    await msg.add_reaction("![checkkkfts](https://cdn.discordapp.com/emojis/845965440387252234.webp?size=128 "checkkkfts")")
    await msg.add_reaction("![nono](https://cdn.discordapp.com/emojis/832534707127189514.webp?size=128 "nono")")
    await ctx.send(f"✅ {ctx.author.mention}, succesfully sent your suggestion to [#867484283526578256](/guild/267624335836053506/channel/867484283526578256/).", delete_after=12)```

Why i cannot react to the emojis?
slate swan
#

You can do

msg = await bot.get_channel(ints).send(embed=embed

Makes it more compact

slate swan
velvet tinsel
#

I made the biggest mistake of my life

#

🙈

maiden fable
#

Hmmmmmm

velvet tinsel
#

You don’t want to know what happened

maiden fable
#

My biggest mistake was..... nvm, won't continue

maiden fable
velvet tinsel
#

It was traumatising actually. I think I’ll have nightmares

maiden fable
#

Best of Luck then

velvet tinsel
#

when did I never have no nightmares anyways hru Hunter?

slate swan
#

!ot yert

unkempt canyonBOT
maiden fable
slate swan
velvet tinsel
#

yert ok

velvet tinsel
tawdry perch
#

You be swearing?

velvet tinsel
#

Yes

slate swan
tawdry perch
#

In what way correct?

maiden fable
#

U still need to connect with code

maiden fable
slate swan
#

yes

#

they updated it

tawdry perch
#

Sniping a message is against ToS? Or what kind of sniping

slate swan
#

u can go to any server with dank memer

#

and type 'pls snipe'

#

huh idc tbh

#

that gives you all the info on it

#

🤷‍♂️

slate swan
summer flume
maiden fable
slate swan
#

oh dw i'm using snipe for logs only 🙏

tawdry perch
slate swan
#

snipe commands on their own arent allowed

maiden fable
#

That's a whole different thing ngl

slate swan
#

and it worked

#

thanks man

maiden fable
#

Where is it written that its against ToS?

#

🤨

slate swan
#

man just ignore them

#
    await coro(*args, **kwargs)
  File "c:\Users\rrfda\OneDrive\Desktop\sublime\commands\snipe.py", line 78, in on_message
    x,y = set(lastest_string) ,set(self.blacklisted_stuff)
TypeError: 'NoneType' object is not iterable
Command raised an exception: AttributeError: 'Bot' object has no attribute 'db'```
maiden fable
slate swan
#

oh ik wheres that

maiden fable
#

bot.db is None

#

!botvar use this

slate swan
#

yeah but where is it being called lmao

unkempt canyonBOT
#

Python allows you to set custom attributes to most objects, like your bot! By storing things as attributes of the bot object, you can access them anywhere you access your bot. In the discord.py library, these custom attributes are commonly known as "bot variables" and can be a lifesaver if your bot is divided into many different files. An example on how to use custom attributes on your bot is shown below:

bot = commands.Bot(command_prefix="!")
# Set an attribute on our bot
bot.test = "I am accessible everywhere!"

@bot.command()
async def get(ctx: commands.Context):
    """A command to get the current value of `test`."""
    # Send what the test attribute is currently set to
    await ctx.send(ctx.bot.test)

@bot.command()
async def setval(ctx: commands.Context, *, new_text: str):
    """A command to set a new value of `test`."""
    # Here we change the attribute to what was specified in new_text
    bot.test = new_text

This all applies to cogs as well! You can set attributes to self as you wish.

Be sure not to overwrite attributes discord.py uses, like cogs or users. Name your attributes carefully!

slate swan
#

makes sense?

tawdry perch
sullen shoal
slate swan
maiden fable
slate swan
#

some famous servers make their logs public lmao

slate swan
#

hows that

maiden fable
slate swan
#

thats for moderation purposes as i stated

tawdry perch
#

If you link me the part of ToS I would understand that but otherwise I won't

slate swan
#

yeah

#

snipe commands are recreational and used in the channel a message was deleted in

slate swan
# sullen shoal good job

this is how this looks like

@bot.command()
async def gamer(ctx):
    conn = sqlite3.connect('test.sql')
    c = conn.cursor()
    good = random.randint(100, 150)
    some = random.randint(50, 80)
    player = ctx.author
    await ctx.send('There Is a Zombie Apocolypse right now and You have 2 Choices \n(A)A Baseball Bat With Iron Wires Coverd\n(B)An M16 With 90 Bullets\nWhat will you choose?')
    msg = await bot.wait_for('message')
    if msg.content in ('a','(a)','(A)','A'):
        c.execute(f'UPDATE data SET balance = balance+{good} WHERE ID = {player.id}')
        conn.commit()
        await ctx.send(f'You Are A Real Gamer **{good}:nexus:** as Gift From Every Gamer')
    else:
        c.execute(f"UPDATE data SET balance = balance+{some} WHERE ID = {player.id}")
        conn.commit()
        await ctx.send(f'Wrong but you still get some {some} for trying')
summer flume
maiden fable
slate swan
maiden fable
maiden fable
#

Half knowledge is dangerous 😐

tawdry perch
#

Ye

sullen shoal
#

!d str.lower

unkempt canyonBOT
#

str.lower()```
Return a copy of the string with all the cased characters [4](https://docs.python.org/3/library/stdtypes.html#id15) converted to lowercase.

The lowercasing algorithm used is described in section 3.13 of the Unicode Standard.
slate swan
vocal shoal
#
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'WindowsPath' object is not subscriptable

does this mean that the path doesnt exists?

slate swan
vocal shoal
# maiden fable Can I see code?
    @commands.command(description="Add a word to the blacklist", usage="<word>")
    @commands.has_guild_permissions(administrator=True)
    async def blacklistWord(self, ctx, *, word:str):
        if not word:
            return await ctx.send("What word should I blacklist?")
        
        self.client.blacklisted_words.append(word)
        await ctx.send(self.client.blacklisted_words)
        data = utils.jjson.read_json("blacklist")
        await ctx.send(data["blacklistedWords"])
maiden fable
#

;-; why I get into an argument with literally everyone most of the time when I am here

slate swan
slate swan
vocal shoal
sullen shoal
unkempt canyonBOT
#

@sullen shoal :white_check_mark: Your eval job has completed with return code 0.

case doesnt matter
maiden fable
vocal shoal
# vocal shoal `data = utils.jjson.read_json("blacklist")`
def get_path():
    """
    A function to get the current path to main.py

    Returns:
     - cwd (string) : Path to main.py directory
    """
    cwd = Path(__file__).parent[1]
    cwd = str(cwd)
    return cwd

def read_json(filename):
    """
    A function to read a json file and return the data.

    Params:
     - filename (string) : The name of the file to open

    Returns:
     - data (dict) : A dict of the data in the file
    """
    cwd = get_path()
    with open(cwd+'/client_config/'+filename+'.json', 'r') as file:
        data = json.load(file)
    return data
slate swan
maiden fable
#

Ah that

slate swan
maiden fable
tawdry perch
slate swan
maiden fable
#

Just save the JSON in the same directory and use absolute paths

slate swan
#

and hey 😔 dont use json as a database

maiden fable
vocal shoal
#

mm ok thanks :)

maiden fable
sage otter
vocal shoal
sage otter
#

Not subscriptable means you can’t index or slice it.

maiden fable
#

Oh hi there NIR! Long time dude

pale turtle
#

Yap

edgy lion
sage otter
#

Because guilds don’t have regions

edgy lion
sage otter
#

Voice channels do

maiden fable
unkempt canyonBOT
#
Naw.

No documentation found for the requested symbol.

maiden fable
#

Tf?

sage otter
#

Is that even a thing you can change?

#

I thought discord automatically selects that for you.

maiden fable
#

!d discord.VoiceChannel.rtc_region

unkempt canyonBOT
#

The region for the voice channel’s voice communication. A value of None indicates automatic voice region detection.

New in version 1.7.

sage otter
#

Ah

maiden fable
#

There (:

sage otter
#

That man hunter hit the docs up so fast.

maiden fable
#

Bruh why couldn't Danny name it to fricking region instead of rtc_region

maiden fable
sage otter
safe fulcrum
maiden fable
#

!d discord.ext.commands.Context.author

unkempt canyonBOT
safe fulcrum
slate swan
edgy lion
maiden fable
edgy lion
maiden fable
edgy lion
maiden fable
#

O

sage otter
maiden fable
#

Wait

sage otter
#

None means automatically chosen region

maiden fable
#

None means it's set to automatic detection

edgy lion
maiden fable
#

O

sage otter
#

Interesting

maiden fable
#

Hmmmmm did u save the changes pithink

Ik noob question but people sometimes forget to save them

maiden fable
#

Weirdddddddd

slate swan
#

i keep getting an Command raised an exception: NameError: name 'cursor' is not defined
is their a way to define it all over the files ?

velvet tinsel
#

What’s the problem?

slate swan
#

like maybe something like bot.something = await connect my cute database

slate swan
velvet tinsel
#

Is it somewhere in your file?

slate swan
#

i told you , its inside a corotinue in the cog

velvet tinsel
#

Ok

#

It’s a cog? Try loading it

wild oak
slate swan
#

dude

#

lmao its loaded

velvet tinsel
#

Oh

#

I don’t know then

#

I cant do coroutines and cogs off the top of my head

wild oak
sage otter
#

Isn’t this @slate swans?

wild oak
#

yes

sage otter
#

I feel like I remember something like that from his template

slate swan
#

hey @sullen shoal

velvet tinsel
#

Euclid is I pay for Winrar?

wild oak
#

i had to change so much stuff dude omg

velvet tinsel
#

Wait

sage otter
#

you got dem intents?

velvet tinsel
#

I misunderstood, the code is ipayforwinrars

wild oak
#

yas

#

But!

slate swan
#

'py ("hello world")'
i am trying to make this look like

print("hello world")```
wild oak
#

I changed so much stuff omg

slate swan
wild oak
#

like a blank space

slate swan
#

like \n?

velvet tinsel
#

Try using aliases

wild oak
#

maybe

sullen shoal
velvet tinsel
velvet tinsel
sage otter
#

Idk tbh. If Guild.owner returns None. Im pretty sure it would be an intents problem.

slate swan
velvet tinsel
#

If it is a function, then use aliases

sullen shoal
velvet tinsel
velvet tinsel
#

If it’s a function try aliases

slate swan
slate swan
#

so i've got my cursor and db loaded inside a coroutine and in the cog commands , i was wondering if i can make it public all over the files and stuff cuz whenever i try to use it , gives me an undefined error altho i made it global which isnt a good practice

velvet tinsel
#

I mean I don’t really understand your question

slate swan
velvet tinsel
sullen shoal
#

im confused what are you talking about

velvet tinsel
#

Or is it some kind of function

velvet tinsel
slate swan
outer violet
#

How do I get the arguments part for subclassing help command?

velvet tinsel
#

Errr…I just started learning it, and I have read the docs

slate swan
# sullen shoal ?

okay this is gonna be hard to explain
sooo
look at dis
inorder to write dis

print("hello world")```
#

check asyncio docs aswell

#

you gotta type like dis

velvet tinsel
#

😭 biggest mistake was skipping it now I have to go through it

velvet tinsel
slate swan
velvet tinsel
sage otter
sullen shoal
velvet tinsel
#

I don’t understand at all

velvet tinsel
slate swan
#

oh god

slate swan
velvet tinsel
slate swan
slate swan
wild oak
slate swan
wild oak
#

this ```

velvet tinsel
#

Ok

wild oak
#

OH

velvet tinsel
#

…?

sullen shoal
sage otter
velvet tinsel
#

I don’t understand anything so I’m just going to watch this and provide support , best I can do 😭

#

I think my English bad

slate swan
velvet tinsel
#

🤷‍♂️💀

sage otter
#
async def foo():
    pass

foo()
#

Will return a coro object

velvet tinsel
sullen shoal
#

ah discord doenst allow me to send the example

#

i gotta go afk now

slate swan
sage otter
#

Such as a cog

#

For example if you had a bot subclass

#

you can have like
self.dbcursor = cursor shit
In the instance variables.

velvet tinsel
#

sage otter
#

And just that attribute normally.

velvet tinsel
#

I think only me and okimii are here

#

Listening ;-;

slate swan
#

Im just watching the show while eating pizza pithink

velvet tinsel
#

Ribs

#

🙂

slate swan
#

😋

sick birch
#

rather you can save the connection instance, and get a cursor from that every time you want to do something with the database

velvet tinsel
slate swan
velvet tinsel
#

I dont really like pepperoni

#

I like cheese better, a bit of a softer taste

slate swan
velvet tinsel
#

I think we went a bit ot

#

💀 hunters coming

slate swan
#

Hes Running here

velvet tinsel
#

Wait

#

He’s not coming

#

!ot ill do it

unkempt canyonBOT
slate swan
#

how do I hid links under text?

sick birch
velvet tinsel
sick birch
#

or is it the other way around

slate swan
slate swan
manic wing
#

"[Text To Click](https://www.youtube.com/ "Hovertext")"

  • Needs to be a full url (http/https)
  • Hovertext is optional
  • If sent by a bot/user it needs to be in an embed
  • If sent in a webhook you can hyperlink raw text cuz fuck being consistent amirite discord
  • This only works in the embed description and field value
    If you want to hyperlink a title or set_author, you can use the url kwarg
#

hyperlinks ^

sullen shoal
#

u type fast

manic wing
#

nop

#

copy and pasted from R.Danny

sullen shoal
#

oh

manic wing
#

but I do type fast

slate swan
manic wing
#

ill take a typing test rn

sullen shoal
#

nice

slate swan
#

Ight

#

Have fun

slate swan
#

or

slate swan
slate swan
#

Thats an example

slate swan
slate swan
slate swan
slate swan
#
        await ctx.send('you made a beautiful painting of a [women](https://cdn.discordapp.com/attachments/871082657742725182/915304518214905866/1200px-Mona_Lisa2C_by_Leonardo_da_Vinci2C_from_C2RMF_retouched.png/) and she looks good or idk')```
#

like [p] ()

sullen shoal
slate swan
slate swan
craggy cloak
#

How to fix this? What should i need to install?

sullen shoal
#

values and description

slate swan
slate swan
sullen shoal
#

however webhook messages are allowed to send them in raw text

velvet tinsel
#

Have you ever seen a beginner who hangs around an expert, tries to help but all they’re doing is rephrasing what the expert says but using different words?

faint echo
velvet tinsel
#

Oh

slate swan
#

and then few days later that person starts dming me for help

craggy cloak
slate swan
#

oh wait its replit

faint echo
sullen shoal
#

maybe they arent using 2.0

velvet tinsel
sullen shoal
#

in replit's terminal

slate swan
velvet tinsel
#

Yes

#

A bit

faint echo
slate swan
#

Yes i am continues to compare a list with a int

velvet tinsel
velvet tinsel
slate swan
#

Long time ago

#

Btw is there away to make cooldown in on_message event

slate swan
#

@commands.cooldown() is only for commands

sullen shoal
slate swan
slate swan
slate swan
velvet tinsel
#

…that stops the event temporarily

velvet tinsel
slate swan
slate swan
velvet tinsel
#

Purposely to see if python returns an error

slate swan
#

Anyways tnx

#

Yw

manic wing
#

.bm?

velvet tinsel
#

Bookmark

slate swan
#

And you have to be replying to a msg

craggy cloak
sullen shoal
#

show me the terminal where you did it

faint echo
#

go on shell and type pip show discord

craggy cloak
faint echo
#

and it did not work?

craggy cloak
#

no 😢

faint echo
#

did it return anything?

sullen shoal
#

yo guys this is my script please think of it in your brain yourself and help me fix the thing, i aint showing it

craggy cloak
#

import discord-ui i used

faint echo
sullen shoal
faint echo
#

go into the shell and type pip show discord

sullen shoal
slate swan
faint echo
#

can I send images here?

manic wing
#

what is .bm

sullen shoal
slate swan
faint echo
dire folio
#

does anyone know how i can make this work

@client.command()
@commands.has_role('Staff')
async def close(ctx):
    if discord.TextChannel.category == 'TICKETS':
        await ctx.channel.delete()
tawdry perch
dire folio
#

i tried with an id but no luck

velvet tinsel
manic wing
#

oh

dire folio
#

so i thought i should try with a string

slate swan
# manic wing oh

Its a book mark if you have dms on it will dm you the message with the link of it and a bit of text so you can save it for later

manic wing
#

was it int, was it valid

#

you dont put in str

dire folio
#

ye it was int

manic wing
#

!d discord.ext.commands.has_role

unkempt canyonBOT
#

@discord.ext.commands.has_role(item)```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member invoking the command has the role specified via the name or ID specified.

If a string is specified, you must give the exact name of the role, including caps and spelling.

If an integer is specified, you must give the exact snowflake ID of the role.

If the message is invoked in a private message context then the check will return `False`.

This check raises one of two special exceptions, [`MissingRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") if the user is missing a role, or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") if it is used in a private message. Both inherit from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").

Changed in version 1.1: Raise [`MissingRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")
manic wing
manic wing
slate swan
#

The issue is here, no need to search that much..

dire folio
#

1 sec lemme try again

#

wdym

faint echo
#

oops..

slate swan
#

discord.TextChannel should represent your channel object

#

Such as ctx.channel

manic wing
#

damnit he deleted it before i could reply

faint echo
#

I didn't mean to post that

#

lol

velvet tinsel
#

What is scoopy?

manic wing
#

thats what they alll say

slate swan
#

Why would you use a role for a ticket system,anyone can go to the channel and close it you should save the authors id

slate swan
manic wing
#

crap

slate swan
#

#simp

manic wing
#

didnt mean to bloody ping

manic wing
slate swan
#

So what?

slate swan
manic wing
#

notice the corelation

#

there isnt one

slate swan
#

So you had to insult to say that?

slate swan
#

Welcome to the Python server I guess..

velvet tinsel
#

Stop

#

Arguing

slate swan
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

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

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

slate swan
#

This channel is turning to the toxic discord.py support channels XD

#

!ot

unkempt canyonBOT
manic wing
#

toxic cus someone said idiot

slate swan
#

Stop guys

velvet tinsel
#

Stop

#

Or i will ping a mod

slate swan
#

Guys actually chill

sick birch
#

this is not bing chilling

faint echo
#

Guys calm down

velvet tinsel
#

Chill

#

We dont want it to return to the age of Noobian

slate swan
#

😭

velvet tinsel
#

How?

#

@slate swan AYYYY

faint echo
slate swan
velvet tinsel
#

He was typing

slate swan
#

You scared him

#

He left now

velvet tinsel
#

Oh

#

Sorry

slate swan
dire folio
slate swan
slate swan
velvet tinsel
#

Have you put any caps?

#

In like when using the command

slate swan
velvet tinsel
#

Yes wont work

velvet tinsel
slate swan
#

object oriented programming

#

Damn me who knows about it😭

velvet tinsel
slate swan
slate swan
#

it is

#

really it is

velvet tinsel
#

Then why ask? Were you asking for what it stands for?

slate swan
#

YES

velvet tinsel
#

Oh

#

Sorry

slate swan
#

😭

velvet tinsel
#

There was a funny joke about OOP

slate swan
slate swan
outer violet
#

How do I get the permission level of a command?

slate swan
#

woof woof

velvet tinsel
#

I dont know where it is tho

velvet tinsel
#

I laughed for like 10 hours

slate swan
velvet tinsel
outer violet
slate swan
slate swan
outer violet
outer violet
#

Ohh

slate swan
#

if everyone has the permission to use it: add a string

#

^

outer violet
#

Okay

slate swan
#

Pretty easyyert

slate swan
velvet tinsel
#

well

#

nothing happens?

slate swan
#

@velvet tinsel you have no clue do you😭 pithink

#

me neither

velvet tinsel
#

I do have a bit of clue

slate swan
#

On mobile so i didnt even checked

#

I do get a little bit of a headache seeing the code be so unorganised

velvet tinsel
#

well...what does it send?

velvet tinsel
slate swan
slate swan
velvet tinsel
#

not even an embed?

slate swan
slate swan
velvet tinsel
slate swan
#

but I'm just tryna help salamalego

#

Oh yeah it's elif

velvet tinsel
slate swan
#

Only language that has elif

slate swan
#

Replace it

#

and those indents, spaces and empty lines
oh no bruv

velvet tinsel
#

it sends no embed. Make an else statement that just does something

#

and execute it again

slate swan
#

this ?

#

Yes

#

The if in the middle

velvet tinsel
#

might not be

slate swan
#

Replace it to an elif

velvet tinsel
#

it looks similar to the one on top and the middle

slate swan
#

No it doesn't

velvet tinsel
#

so we don't know if he screenshotted the top one or the one in the middle.

slate swan
#

See the space under the first if

#

It's not in the small screenshot

velvet tinsel
#

oh, yes

#

I stand corrected. My apologies.

slate swan
#

Yes

velvet tinsel
#

now run it

slate swan
#

and why don't you just put

if time.content == "yes":
    #put the time
if pfp.content == "yes":
    #put the pfp
#

Don't do that

#

It will be slower

#

how

velvet tinsel
#

I think he wants to check if it does both

slate swan
#

As it will always check every single if

#

well it's two if statements

#

If you use if, elif, elif once it hits the first elif it will stop trying the others

slate swan
velvet tinsel
#

top tip: Leave the chat when I ask for code help

slate swan
#

sorry for those 2 milliseconds

#

🙏

slate swan
velvet tinsel
slate swan
slate swan
slate swan
#

it's just bad logic what's happening here

#

If the first if is true, it won't even try the others

velvet tinsel
slate swan
#

it's a 1/4 chance that the first if is true

velvet tinsel
#

I think my google broke

slate swan
#

Same for the second and third

#

the other 3/4 times, it's either the same amount of memory or even more

#
    if time.content == "yes" and pfp.content == "yes":

        emb = discord.Embed(title=title.content, description=desc.content, timestamp=ctx.message.created_at)
        emb.set_thumbnail(url=f"{author.avatar_url}")
        await ctx.send(embed=emb)  

This isnt work either

#

oh lol

#

what version are you using

#

These two arent working

    if time.content == "yes" and pfp.content == "yes":

        emb = discord.Embed(title=title.content, description=desc.content, timestamp=ctx.message.created_at)
        emb.set_thumbnail(url=f"{author.avatar_url}")
        await ctx.send(embed=emb)  
    elif time.content == "no" and pfp.content == "yes":
        emb = discord.Embed(title=title.content, description=desc.content)
        emb.set_thumbnail(url=f"{author.avatar_url}")
        await ctx.send(embed=emb)
#

in 2.0, it's gonna be author.avatar.url

sick birch
#

I built the connection instance into a custom context, if that makes any sense

#

I was looking at RoboDanny (discord.py bot that danny made) and it does something similar

sage otter
#

I have custom context but I haven’t used it for things like that.

#

Just for embed stuff.

velvet tinsel
#

My google brokk

#

😦

#

site not loading

#

every other site works tho

#

I think the site brokken

slate swan
velvet tinsel
#

f
no I trust google

sick birch
#

i don't whatsoever

#

i use librewolf + ddg lmao

slate swan
#

👍

feral cosmos
#

I'm doing this request:
r = requests.post(f'https://discord.com/api/v8/channels/{channelId}/messages', headers=headers, data=payload, files=files)
And it works with channel IDs in servers but it doesnt, when i want to message a user by using the ID i get when right clicking a friend and pressing "Copy ID"
DO I have to change the request link in order for it to work

slender pollen
#

Hello I'm trying to make a bot that when anyone join to send a welcome card but It's not working any ideas?
`import discord

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

@client.event
async def on_message_join(member):
channel = client.get_channel(channel_id)
embed=discord.Embed(title=f"Welcome {member.name}", description=f"Thanks for joining {member.guild.name}!") # F-Strings!
embed.set_thumbnail(url=member.avatar_url)
await channel.send(embed=embed)`

sullen shoal
#

what is channel_id

#

do you get any error

slate swan
#

Maybe you want on_member_join instead of on_message_join

sullen shoal
#

oh yes

slender pollen
slender pollen
#

Thanks, It's working!

polar ice
#

Hey im trying to use the discord buttons

#

Im getting ModuleNotFoundError: No module named 'discord.ui'

#

Ive installed the discord.py and tried updating it

import discord
from discord.ui import Button, View
from discord.ext import commands, tasks```
#

Any ideas what im doing wrong?

slate swan
#

Have you installed v2.0?

zinc reef
polar ice
#

Run it in a cmd window?

slate swan
#

Yes

polar ice
#

Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.

Python is installed with PyCharm

#

Discord versoin is 1.73?

#

Im installing it with PyCharm interpterter ive tried updating it

zinc reef
#

yeah, discord.ui is 2.0+

polar ice
#

is there a way i can manually install v2

zinc reef
#

you need to install it from git, since it's not on pypi

slate swan
#

To install the development version, do the following:

$ git clone https://github.com/Rapptz/discord.py
$ cd discord.py
$ python3 -m pip install -U .[voice]
zinc reef
#

you don't exactly need to manually clone it locally though

polar ice
slate swan
#

Not copy paste

#

Since you maybe don't use python3

#

Do it in the same place where you got the version number

#

One line after the other

polar ice
#

Im using python 3.9 pycharm says

#

okay so ive just ran the command in pycharm terminal window

#

says its installed but still isnt working?

slate swan
#

can samone givr exemple of random anime photo and natauki random photo command please?

velvet tinsel
#

errrr

#

code or an actual picture?

#

@slate swan

slate swan
#

make a list of strings

#

the strings are just GIFs

#

!d random.choice use this with passing in the list and send the result in a message

unkempt canyonBOT
#

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

done

velvet tinsel
#

or use os *cough* or PIL, whatever you use to go through your files

polar ice
#
administrator_help = Button('Administrator', color="green")```

This should be producing a button?
velvet tinsel
#

what module are you using

#

;-;

polar ice
velvet tinsel
#

oh
I never used it sorry
but I'll look into it

polar ice
#

Which do you use? 🙂

#

Im new to this whole button malarky is there a better one?

slate swan
#

discord-components is pretty popular

#

disnake too

slate swan
manic wing
#

cough 2.0

slate swan
#

it's pretty easy and the support server is helpful

polar ice
#

Ill check the github out now

velvet tinsel
slate swan
#

but I think the disnake owner helps in this server quite a lot

velvet tinsel
#

I'll join it, no idea

rare saddle
#

Why doesn't the check work for me? The participant ID is in the database, but the check does not work and does not display an error that the person is in the black list

slate swan
#

so I'm helping him promo and he'll be proud of me

velvet tinsel
#

cant find it

slate swan
sage otter
#

Yes

velvet tinsel
#

apparently discord --version nor discord.py --version works ;-; idk what to do now but I'm not really bothered

sage otter
#

Precisely

slate swan
# sage otter Yes

well i found this on asyncio docs ,

Coroutines declared with the async/await syntax is the preferred way of writing asyncio applications. For example, the following snippet of code (requires Python 3.7+) prints “hello”, waits 1 second, and then prints “world”:```
velvet tinsel
#

I saw that example

slate swan
#

consider reading them and telling me what you understood , i might've understood them wrong

velvet tinsel
#

I miss pandabweer and Ipayforwinrar 😦

#

try for r in ctx.guild.roles @slate swan

#

if you're using a command

sage otter
#

In a specific role

velvet tinsel
#

am I doing something wrong

sage otter
#

Role.members()

velvet tinsel
#

Oh, knew it

slate swan
#

why do you need a for loop

#

!d discord.Role.members

unkempt canyonBOT
velvet tinsel
velvet tinsel
#

;-; imposing threat, Charisma a definite +3 modifier. Maybe he's a warlock? (sorry, dnd reference)

slate swan
velvet tinsel
slate swan
#

you can do that, yeah

velvet tinsel
#

I swear all helpers here have a charisma modifier of 15, maybe okimii has like 13 or 12 (or possibly 10) and caeden is probably a higher Charisma modifier

slate swan
#

what's that

velvet tinsel
#

sorry went a bit ot

rare saddle
#

Why doesn't the check work for me? The participant ID is in the database, but the check does not work and does not display an error that the person is in the black list

slate swan
#

no, no

velvet tinsel
#

I was speaking to myself there ;-; I do it a lot (I have no friends)

slate swan
#

actually what's that

velvet tinsel
slate swan
#

yes

velvet tinsel
#

err...dnd reference

slate swan
#

do not disturb reference?

velvet tinsel
#

you get a high Intimidation if you have high Charisma, I'm scared of some of the helpers here

velvet tinsel
slate swan
velvet tinsel
#

I should stay on topic

slate swan
#

now that you say

#

yes, definitely

#

👀

velvet tinsel
#

I confused everyone

#

but It's true, you guys are sometimes intimidating

slate swan
velvet tinsel
#

whenever I see something like Tylerr is typing or Myxi is typing or okimii is typing I get nervous

velvet tinsel
#

no spoonfeed

#

😠

velvet tinsel
slate swan
#

I'm not on the list

#

happy

velvet tinsel
slate swan
#

told u what to do

velvet tinsel
#

I think it's like help a man to fish, feed him for a day, teach him how to fish, feed him for a lifetime

slate swan
sage otter
velvet tinsel
#

Tylerr intimidating af

#

But shady is more intimidating

#

I think Andy is less intimidating

sage otter
#

Shady?

velvet tinsel
#

Shady the evil cat lady

sage otter
#

Is this another one of your dnd references?

slate swan
#

@slate swan So I have a list of the members now but I want to check if they have a specific role.

Tried

if role in role_bla.members.roles:
  print("bla")```

It can't check if they have the role because role.members just gives a list
#

'list' object has no attribute 'roles'

#

you didn't use the for loop

#

members is a list

#

you can iterate through that

#

So


for role_bla.members.roles in what tho?```
#

for member in role_bla.members

#

I guess you wanna check everyone that has a specific role

#

that's how I understood

#

BRUH NO I have it now

#

sorry dude

#

i was a bit braindead

velvet tinsel
#

I can ping her now, but she'll kill me

velvet tinsel
slate swan
#

lol true

#

hey

#

no

velvet tinsel
#

yes

#

i pause about 10 seconds before writing down the beginning of the script

slate swan
#

sry quick question, how do i check if a channel is a TextChannel

#

cant find it and i already spent 20 minutes searching the docs

#

if isinstance(channel, discord.TextChannel)

manic wing
slate swan
#

thanks

manic wing
#

shit you got there quicker

slate swan
#

eZ

#

thanks you both

manic wing
#

i deserve all credit

#

he copied my work pithink

cobalt coyote
#

Hello! I'm trying to make my own Discord bot with welcome cards like Mee6, but i'm stucked. I'm trying to find the code to do that and i find that but i dont how to make it after that. I'm doing it on replit but i dont know if its gonna work there.

`from PIL import Image, ImageDraw, ImageFont

get an image

base = Image.open("Pillow/Tests/images/hopper.png").convert("RGBA")

make a blank image for the text, initialized to transparent text color

txt = Image.new("RGBA", base.size, (255,255,255,0))

get a font

fnt = ImageFont.truetype("Pillow/Tests/fonts/FreeMono.ttf", 40)

get a drawing context

d = ImageDraw.Draw(txt)

draw text, half opacity

d.text((10,10), "Hello", font=fnt, fill=(255,255,255,128))

draw text, full opacity

d.text((10,60), "World", font=fnt, fill=(255,255,255,255))

out = Image.alpha_composite(base, txt)

out.show()`

manic wing
#

and whats the problem?

cobalt coyote
#

I tried but it didn't worked

slate swan
#

no dpy in this code

slender pollen
cobalt coyote
#

I'm new and i'm not sure what is dpy.

slate swan
#

what the actual thing

slate swan
#

!docs

unkempt canyonBOT
warm mirage
#

if i wanna message someone directly using my bot what can i do to like message that specific person?

rare saddle
#

Why does the cycle start to operate if I specified the condition that if there are no documents in the collection then return

slim whale
#

what its the import for mongodb?

rare saddle
slim whale
slate swan
warm mirage
#

nvm i got it to work

#

but thanks for the help

slate swan
#

Nice

#

Yw

wild oak
#
    @commands.command(name="serverinfo")
    async def serverinfo(self, context):
        """
        Get some useful (or not) information about the server.
        """
        server = context.message.guild
        roles = [x.name for x in server.roles]
        role_length = len(roles)
        if role_length > 50:
            roles = roles[:50]
            roles.append(f">>>> Displaying[50/{len(roles)}] Roles")
        roles = ", ".join(roles)
        channels = len(server.channels)
        time = str(server.created_at)
        time = time.split(" ")
        time = time[0]

        embed = discord.Embed(
            title="**Server Name:**",
            description=f"{server}",
            color=0x1eff00
        )
        embed.set_thumbnail(
            url=server.icon_url
        )
        embed.add_field(
            name="Owner 👑",
            value=f"{server.owner}\n{server.owner.id}"
        )
        embed.add_field(
            name="Server ID 🤓",
            value=server.id
        )
        embed.add_field(
            name="Member Count 🎅",
            value=server.member_count
        )
        embed.add_field(
            name="Text/Voice Channels 📃",
            value=f"{channels} "
        )
        embed.add_field(
            name=f"Roles ({role_length}) 👮‍♂️",
            value=roles
        )
        embed.set_footer(
            text=f"Created at: {time} ⏰"
        )
        await context.send(embed=embed)```
#

uhh what

#

please @ me if you can help

slate swan
#

@wild oak the server owner id is None

wild oak
#

wym how do i fix it

#

@slate swan

#

whoops sorry

#

i swear this used to work

summer flume
#

try server.owner_id

slate swan
dire folio
#

how would i set the current date as an embeds footer?

slate swan
#

!d discord.Embed

unkempt canyonBOT
#

class discord.Embed(*, colour=Embed.Empty, color=Embed.Empty, title=Embed.Empty, type='rich', url=Embed.Empty, description=Embed.Empty, timestamp=None)```
Represents a Discord embed.

len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.

bool(b) Returns whether the embed has any data set.

New in version 2.0.

Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty").

For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") for you.
slate swan
summer flume
#

!d discord.Guild.owner_id

unkempt canyonBOT
summer flume
#

@wild oak use it

slate swan
#

well umm

#

did you quit the for loop?

#

show some code

#

why

#

why are you using a while true

#

with spamming API calls

#

and you don't even leave it

#

just delete the while true...

#

and find a way you won't spam send()

#

that's no good for nobody

#

boy I gotta go

#

👍

#

good night

#

Why is their a while true if your iterating through a list?

#

Make a delay when sending a msg so you wont get rate limited

visual island
#

use zip

#

!d zip

unkempt canyonBOT
#
zip

zip(*iterables, strict=False)```
Iterate over several iterables in parallel, producing tuples with an item from each one.

Example:

```py
>>> for item in zip([1, 2, 3], ['sugar', 'spice', 'everything nice']):
...     print(item)
...
(1, 'sugar')
(2, 'spice')
(3, 'everything nice')
```...
visual island
#

ADthink all of their messages were deleted

final iron
#

Pretty sure thats against discord TOS

sick birch
#

it is

#

api ratelimits are there for a reason

#

getting around it is a no no for TOS reasons and courtesy

slate swan
#

ive classified a cog, properly, loaded it in the main file, but the command isnt found

final iron
#

I would suggest deleting your message

#

This one

slate swan
#

not sure why, ive restarted it multiple times now

sick birch
#
  • the setup function
slate swan
#

sec

final iron
#

The python bot logs deleted messages while discord doesn't

slate swan
#

all of my other cogs load fine im not sure whats wrong with this one

#

main file bot.load_extension('cogs.misc')

final iron
#

If an admin wanted to punish you deleting the message wouldn't matter. What I did prevented your entire account from getting terminated

slate swan
#

cog

import imports_here

class misc(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

whitelisted = [813989866236149770, 431427182926102528, 853544955300806657, 755127293432692757, 911079118165131284]

def terror(ctx): 
    return ctx.author.id in whitelisted


    @commands.command()
    @commands.check(terror)
    async def changepfp(self, ctx):
        with open('./pfp/acrella.png','rb') as f:
            await self.bot.user.edit(avatar=f.read())

#defs
    
    @commands.command(pass_context=True, aliases=['eval', 'exec', 'evaluate'])
    @commands.check(terror)
    async def eval(self, ctx, *, code: str):

#stuff

def setup(bot):
     bot.add_cog(misc(bot))```
sick birch
#

ah

#

they're all indented

slate swan
#

wdym

sick birch
#

move the commands into the misc class

sick birch
#

right now they're nested into the terror function

slate swan
#

yaaa

#

i just fixed that

#
whitelisted = [813989866236149770, 431427182926102528, 853544955300806657, 755127293432692757, 911079118165131284]

def terror(ctx): 
    return ctx.author.id in whitelisted


class misc(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
summer flume
#

how do I check if someone is tagged in a x time

slate swan
slate swan
sick birch
#

Did you see that in the docs?

#

Having more context on what you mean would help us help you

slate swan
sick birch
#

For which

slate swan
#

??

sick birch
#

Where exactly did you find it in the docs?

slate swan
sick birch
slate swan
#

line 44

sick birch
#

Line 44 is just @bot.command()

slate swan
sick birch
#

Then make the command accordingly with the right arguments

#

Unless you mean that in the help command

#

If I'm understanding you right, the command has 3 aliases: repeat, rep, r. When you run the help command, it shows all 3 instead of just the first one

#

Is that what the issue is?

slate swan
#

yes

sick birch
#

You'll need to do some overriding and customization

slate swan
#

how do i do that?

sick birch
#

I'm pretty sure you can get the aliases as a list, you can just get the first one

#

Or, alternatively, you can get the name. Each command can only have 1 name, but multiple aliases

#

You can get both of these by the command.aliases and command.name respectively, where the command variable is of type discord.ext.commands.Command

slate swan
#

oh okay

#

also how would i add the command prefix to a command if it has no args?

#

@sick birch

#

is contextLib not a valid import?

visual island
#

or self.context.prefix for help command subclass

visual island
#

lower i

slate swan
#

okay

#

can we not have more than 1. event in our discord bot?

#

whenever i add another event, the first 1 stops working

sick birch
#

You have to add the arguments, prefix, etc manually

sick birch
visual island
slate swan
sick birch
#

Not necessarily

#

You should stay away from @bot.events, but there are many cases where it's required

#

And if you do use @bot.event, some of them have some special caveats which you have to keep in mind

slate swan
#

they both have specific conditions so its fine ig

#

for now atleast

vocal plover
#

I can barely think of one

sick birch
gaunt tinsel
#

Anyone know the deal with discord.Users? I’m getting major errors when I try and use it.

sudden aspen
#

Hey does anyone know how to make a level bot?

slate swan
#

ye does anyone know how to make a level bot (xp, leaderboards, and double xp in certain days or for certain channels?)

maiden fable
unkempt canyonBOT
#

discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") is created and sent.

This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.messages "discord.Intents.messages") to be enabled.

Warning

Your bot’s own messages and private messages are sent through this event. This can lead cases of ‘recursion’ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
maiden fable
#

!d random.randint

unkempt canyonBOT
#

random.randint(a, b)```
Return a random integer *N* such that `a <= N <= b`. Alias for `randrange(a, b+1)`.
vocal zephyr
#

!d discord.on_reaction_add

polar ice
#

Hey im trying to install discord.20 so i can use buttons. cant seem to get it installed though

#

im using py -3 -m pip install -U discord.py in pycharm terminal window

final iron
#

Is it not installing period or not installing 2.0

polar ice
#

Not installing at all by using py -3 -m pip install -U discord.py

#

Only if i install it through pycharm interpreter but then i get v1.73

#

which i cant use the fancy buttons 😄

#

@final ironany ideas?

final iron
polar ice
#

This is the correct version?

sullen shoal
#

pip install -U git+https://github.com/Rapptz/discord.py

maiden fable
sullen shoal
#

yes

polar ice
#

@maiden fableOh really, which one would you suggest? Im pretty new to all this my bad

sullen shoal
#

no slash commands

#

disnake

polar ice
#

@sullen shoalI can install disnake straight through with PyCharm right?

polar ice
#

Awesome ill take a look. is there any examples of how to create a button with disnake?

sullen shoal
#

yes, check their github repo

final iron
polar ice
#

Awesome, @sullen shoal@final iron i had a part in my code which was the loop Client.loop any idea how this is replaced with disnake? has a search through their documentation cant find anything

cyan hare
#

i need help with just one code line can somone help me

#

it was big so i was like to do in dm

#

please dm me

polar ice
#
@client.loop(seconds=60)```
sick birch
# polar ice which i cant use the fancy buttons 😄

The beta version of discord.py has very good buttons and selects, slash commands and context menus you can implement yourself with relatively little effort. I don't like any of the forks as they are not headed by as experienced developers as danny, but you're free to use whatever you want

#

Even though it says it's beta, it's quite stable. At least, it's worked like a charm for me and haven't run into any issues

polar ice
#

@sick birchThat was my worry, id preferably like to stick with discord.py just because i can find alot of help just by googling.

#

@sick birchI just cant seem to get it installed properly 😦

sick birch
#

What seems to be the issue with it?

#

If you install through pip, you'll get the older version

polar ice
#

I tried to install Discord v2.0 but its just installing 1.7.3

sick birch
#

Are you getting it through pip?

polar ice
#

Im running the pip command from their github through pycharm terminal?

sick birch
#

Explains it

#

You can't get the beta version through pip, only 1.7.3. That's the last version before beta iirc

#

You'd need to install it manually

polar ice
#

gotcha

sick birch
#

Quite easy, it's a 3 liner

polar ice
#

How would i install it manually?

sick birch
#

Well I use linux for development, so hang on while i take a look on how you do it for windows

polar ice
#

tried searching youtube .etc but didnt find much

#

awesome man, thanks

sick birch
#

According to the official GitHub page, here's how you install the development version:

git clone https://github.com/Rapptz/discord.py
cd discord.py
python3 -m pip install -U .[voice]

The first part is where you clone the GitHub repository, meaning it downloads it to your local machine.
The second part just moves into the directory, i.e sets it as the current working directory
Last part basically just installs it through the local files, without getting it from pip

#

I hope that makes sense, and you can use the latest features 🙂

polar ice
#

thanks for your help dude. i just use those commands in a CMD window?

pliant gulch
#

You could just do pip install git+https://github.com/Rapptz/discord.py

polar ice
#

@pliant gulch Once i download it from github which directory do i put it in?

polar ice
sick birch
#

Ah yeah you'll want to install git first

polar ice
#

ohhh

slate swan
#

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

polar ice
#

okay. is there a command for that? or is there a program to download?

sick birch