#discord-bots

1 messages · Page 637 of 1

manic wing
#

lol i forgot about this gem

#

i literally put my token in a json like 8 months ago

#

forgot it was there

#

pushed it straight to github

brittle ingot
#

Lmfao

#

Got a message from Safety Jim did ya?

manic wing
#

ive gotten like 5

brittle ingot
#

Same

manic wing
#

stupid shit…lots of stupid shit xD

slate swan
#

Whos that if you dont guys mind me asking jam_cavedude

brittle ingot
#

It’s an automated message from discord when GitHub notifies them of a valid bot token on its platform

manic wing
#

i accidentally pushed the token when i was on holiday for a couple weeks when it was about to be verified on top.gg - i host it locally so i was a bit panicked lol

slate swan
#

Ah i see

manic wing
brittle ingot
#

Nope GitHub partnered with discord in a way and GitHub scans repos for tokens

manic wing
#

oh cool

slate swan
#

How to save transcript like ticket bot?

#

Once the bot’s done w a conversation in dms, it saves the transcript of the chat and posts it in a specific channel

#

I have this:

#
channel = client.get_channel(914409887948222494)
            messages = await dm.history().flatten()

            with open(f'{channel}_messages.txt', 'a+', encoding='utf-8') as f:
                print(f"\nTranscript Saved.\n\n", file=f)
                for message in messages:
                    embed = ""
                    if len(message.embeds) != 0:
                        embed = message.embeds[0].description
                        print(f"{message.author.name} - {embed}", file=f)
                    print(f"{message.author.name} - {message.content}", file=f)
            await channel.send(f"{message.author.mention}, Transcript saved.")
            history = discord.File(fp=f'{channel}_messages.txt', filename=None)
            await channel.send(file=history)
#

await ctx.send(f"{len(bot.users)}") this sends the count of users that are used by the bot right? like the total count of all members in all servers that the bots in?

slate swan
slate swan
brittle ingot
#

!d discord.ext.commands.Bot.users

unkempt canyonBOT
slate swan
#

Ah i seepithink

#

i found this on reddit, could it provide an accurate number? sum([len(guild.members) for guild in bot.guilds])

brittle ingot
#

Not if you don’t have member intents, also the bot.users does it for you…. So one is API taxing the other is not…

dark pawn
#

is there a way to make a superwide embed? cuz i have all my values inline but after 3 values it drops below

slate swan
#

and intents = discord.Intents.all() as well

brittle ingot
#

Just do bot.users

distant warren
slate swan
#

just {bot.users}

#

How to save transcript like ticket bot?

Once the bot’s done w a conversation in dms, it saves the transcript of the chat and posts it in a specific channel

I have this:

#
channel = client.get_channel(914409887948222494)
            messages = await dm.history().flatten()

            with open(f'{channel}_messages.txt', 'a+', encoding='utf-8') as f:
                print(f"\nTranscript Saved.\n\n", file=f)
                for message in messages:
                    embed = ""
                    if len(message.embeds) != 0:
                        embed = message.embeds[0].description
                        print(f"{message.author.name} - {embed}", file=f)
                    print(f"{message.author.name} - {message.content}", file=f)
            await channel.send(f"{message.author.mention}, Transcript saved.")
            history = discord.File(fp=f'{channel}_messages.txt', filename=None)
            await channel.send(file=history)
magic ore
slate swan
slate swan
#

so if its in 2 servers with 2 members each, than the output should be 4

magic ore
magic ore
#

!d io.StringIO

unkempt canyonBOT
#

class io.StringIO(initial_value='', newline='\n')```
A text stream using an in-memory text buffer. It inherits [`TextIOBase`](https://docs.python.org/3/library/io.html#io.TextIOBase "io.TextIOBase").

The text buffer is discarded when the [`close()`](https://docs.python.org/3/library/io.html#io.IOBase.close "io.IOBase.close") method is called.

The initial value of the buffer can be set by providing *initial\_value*. If newline translation is enabled, newlines will be encoded as if by [`write()`](https://docs.python.org/3/library/io.html#io.TextIOBase.write "io.TextIOBase.write"). The stream is positioned at the start of the buffer.

The *newline* argument works like that of [`TextIOWrapper`](https://docs.python.org/3/library/io.html#io.TextIOWrapper "io.TextIOWrapper"), except that when writing output to the stream, if *newline* is `None`, newlines are written as `n` on all platforms.

[`StringIO`](https://docs.python.org/3/library/io.html#io.StringIO "io.StringIO") provides this method in addition to those from [`TextIOBase`](https://docs.python.org/3/library/io.html#io.TextIOBase "io.TextIOBase") and [`IOBase`](https://docs.python.org/3/library/io.html#io.IOBase "io.IOBase"):
slate swan
#

use utf-8?

magic ore
#

What?

slate swan
#

discord.File(io.BytesIO(transcriptstring.encode("utf-8")), "transcript.txt")

#

I think I got it

#

lemme try

magic ore
#

You can just use StringIO without having to encode the string

#

But that might work sure

slate swan
#

Kk

vast spindle
#

is it possible to detect if a user is sending an emoji or not

brittle ingot
#

There is an emoji package?

vast spindle
#

what

brittle ingot
#

!pypi emojis

unkempt canyonBOT
polar ice
#

Hello silly question but ive just started a bot. any ideas why i cant get the command to work?

@client.command()
async def test(ctx):
    print("works")
    ctx.send("works")```
brittle ingot
#

await ctx.send(“works”)

polar ice
#

Ofcourse yes, but also the print isnt working?

slate swan
#

I think because it couldnt send the message

brittle ingot
polar ice
#

sure

brittle ingot
slate swan
#

Forgot about that

#

Maybe the bot isnt online

#

Or as you said the bot instance

polar ice
#

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

jaunty terrace
#

Where should i got to get help on installing git for linux?

vast spindle
#

how can I detect who sends a message

polar ice
brittle ingot
unkempt canyonBOT
jaunty terrace
unkempt canyonBOT
polar ice
brittle ingot
polar ice
#

oh damnn ofcourse!!

vast spindle
slate swan
brittle ingot
#

Looks like it.

slate swan
polar ice
#

@brittle ingotcan i not have my commands anywhere in the code with @client.command?

brittle ingot
#

Here is why you shouldn’t do anything in on_ready

vast spindle
brittle ingot
slate swan
vast spindle
polar ice
#

@brittle ingot```client = commands.Bot(command_prefix='!', intents=intents) like this?````

brittle ingot
#

Yeah

polar ice
#

@brittle ingotI have that at the very top of my code. so the command should work how it is?

slate swan
slate swan
polar ice
#

Very 🙂

pliant gulch
# brittle ingot Here is why you shouldn’t do anything in on_ready

The READY event dispatched from the gateway only gives user about the current authorised user and presences if intents are enabled really. Most of the important and time consuming data is given in GUILD_CREATE which will be dispatched for every guild the client is in during startup

polar ice
pliant gulch
#

And that's not really a valid reason 2 not do stuff in READY

#

A good reason would be that it can be dispatched more then ONCE

#

Or the fact that changing presence during READY dispatch can cause a 1006 websocket error code

brittle ingot
#

On line 126 right after your return and outside the if statements add:
await bot.process_commands(message)

brittle ingot
slate swan
#

If its a messag event its^

graceful gulch
#

so its a message event

slate swan
brittle ingot
#

Thanks

slate swan
graceful gulch
slate swan
#

What for? I am so confused

vast spindle
#

is message.react not a thing?

slate swan
#

No dont think so

graceful gulch
#

message.add_reaction im pretty sure

slate swan
graceful gulch
#

what?

vast spindle
#

now how do I add custom emojis?

slate swan
graceful gulch
slate swan
brittle ingot
#

You can just paste in the emoji like they’re saying or you can fetch the emojis by it’s ID

slate swan
#

Mostly use the id for custom emojis

graceful gulch
vast spindle
#

ok, and if I use a custom emoji will it work in servers that don't have that emoji

brittle ingot
#

Let’s just keep it simple. To the specific application at hand

graceful gulch
slate swan
#

Youll have to use the id

vast spindle
#

k ty for all the help

cedar stream
slate swan
cedar stream
#

Can u set an animated pfp?

brittle ingot
#

As far as emojis yes, not pros

#

Pfps

graceful gulch
#

bots dont have nitro lol

slate swan
#

Yeah

pliant gulch
#

They have a sorta nitro

cedar stream
#

Ohh

pliant gulch
#

Not exactly nitro but they have some features of it

slate swan
brittle ingot
#

It’s like an advanced member state

graceful gulch
#

they just can do extra stuff cause they are a bot account and not a user account

graceful gulch
slate swan
slate swan
#

Not all but have some

cedar stream
#

Well It’ s nice to be able to send emojis from other servers

graceful gulch
#

no all they literally have is the emoji feature

#

and stickers

slate swan
cedar stream
graceful gulch
#

its a bot

slate swan
graceful gulch
#

theres a difference, u cant compare them to user accounts

brittle ingot
#

Alright let’s reign it in

slate swan
#

I swear this guy thinks im a beginner 😭

graceful gulch
#

u act like one lmao

brittle ingot
#

Stick to the facts. Bots can send animated emojis and regular custom emojis from other servers as well as sticker.

brittle ingot
cedar stream
#

I agree

graceful gulch
brittle ingot
#

The entire point of this channel is to help others and learn things yourself. Just because my name is green doesn’t mean I’m better than others. It means I paid money for it.

cedar stream
#

Can we all calm down pls 😭

brittle ingot
cedar stream
#

This channel had like 5 arguments in 3 days

brittle ingot
#

Anyways onwards and upwards

cedar stream
#

Ty

dapper cobalt
slate swan
brittle ingot
#

Scoopy 🤜🏽

slate swan
#

Im not here to fight with little kids,only to help others

dapper cobalt
slate swan
#

And i will like to keep it civil and to topic so if you dont like that you may leave

slate swan
brittle ingot
#

Alright docs challenge again 😄

slate swan
slate swan
brittle ingot
#

Docs Challenge
Find and post one thing from discord.py docs that was the most challenging thing for you to learn. How did you overcome it and understand it in the end

polar ice
#

is it possible to mention another channel in an embed?

brittle ingot
#

Yes

polar ice
#

Im trying channel_id.mention but im getting an error with the .mention

brittle ingot
#

You can either send the mention as a string or get the channel object and use .mention on it

#

So to get the string mention as I call it you just mention the channel here in discord and put a backslash in front of it and hit send

low parcel
slate swan
#

how can i uninstall dpy v2 and go to dpy v1.(x)?

brittle ingot
#

#python-discussion is [#python-discussion](/guild/267624335836053506/channel/267624335836053506/)

polar ice
#
    channel_id = readsettings('BOT_SETTINGS', 'general_channel'))

    embed.add_field(
        name="If you need urgent support please open a ticket by reacting below.",
        value=f"Before opening a ticket, ask yourself is it urgent? Why not try ask the community to see if they can help? {channel_id.mention}",```
dapper cobalt
slate swan
slate swan
#

Lmao

dapper cobalt
slate swan
brittle ingot
slate swan
#

@dapper cobalt your repos are very lovely yert

brittle ingot
#

Like so

polar ice
#

Ohh okay ill give it ago

#

<#channel_id>

brittle ingot
#

<#{channel}> in an f-string

polar ice
#

gotchaa

slate swan
#

Iircbot.get_channel()

#

That doesnt need to be awaited iirc

brave vessel
#

You wouldn't await discord.Client.get_channel

#

Oh someone already answered it

slate swan
brittle ingot
#

Yeah get channel is just getting the channel object from cache isn’t not awaitable

#

lol

polar ice
#

@brittle ingotAwesome dude, never knew that thanks

brittle ingot
#

Np

brittle ingot
#

Wait is it bot.get_channel or guild.get_channel

dapper cobalt
#

Both.

#

!d discord.Guild.get_channel

unkempt canyonBOT
#

get_channel(channel_id, /)```
Returns a channel with the given ID.

Note

This does *not* search for threads.
brittle ingot
#

!d discord.ext.commands.Bot.get_channel

unkempt canyonBOT
brittle ingot
#

I guess so

dapper cobalt
#

Read the note, though.

brittle ingot
#

Huh would have thought it the other way around

cedar stream
brittle ingot
#

Lol seems like something I would totally do

slate swan
brittle ingot
#

Me either

slate swan
#

Seems useless to me

cedar stream
brittle ingot
cedar stream
#

🤷🏼‍♂️

slate swan
brittle ingot
#

Oh my word 😹😹

cedar stream
pliant gulch
#

Once voice recv becomes a bigger thing you could do an alexa or siri type thing

slate swan
#

Or a bot that joins a vc and roasts you or disconnects you

cedar stream
brittle ingot
#

I imagine if you had some voice recognizer or some type of AI you could moderate VCs checking words against voice notes stored for certain bad or banned words people may use. How you’d do that I have no damn clue. But an interesting thought

pliant gulch
#

Computation resources maybe? The coding part will take a bit though

#

I would need to train the machine, otherwise use an already trained machine

cedar stream
pliant gulch
#

The hard part first though is actually implementing voice recv

cedar stream
#

I dont think someone could make a good virtual assistant by themselves

pliant gulch
#

Or it might be easy, I'm not sure, I'm basically gonna let blanket do the voice recv impl for lefi

cedar stream
pliant gulch
#

I cba to learn all that byte stuff

brittle ingot
#

I actually follow a guy on TikTok who works in AI. Pretty cool stuff

cedar stream
#

Did yall see a site where u can type in english what you want your code to do and ai will write the code

#

It’ s codex or something

#
OpenAI

We’ve created an improved version of OpenAI Codex, our AI system that translates natural language to code, and we are releasing it through our API in private beta starting today. Codex is the model that powers GitHub Copilot, which we built and launched in partnership with GitHub a month

brittle ingot
#

Blanket 😮 haven’t seen them in forever

pliant gulch
#

Cause he got banned from pydis

brittle ingot
#

Oof lmfao

slate swan
brittle ingot
#

No clue

brave vessel
pliant gulch
brave vessel
#

Ah

brittle ingot
#

Well that’s freaking cool

pliant gulch
#

It seems like blanket has added recv packets

#

Just not decode

brave vessel
#

I wish I could work on the converters more often but schools been busy unfortunately

brave vessel
pliant gulch
#

I need to do slash command converters either way

brave vessel
#

Yea that's fine

wild oak
#

Ummm so my help command isnt showing anything for my seasonal cog and this is all my code

#

does anyone know what is causing this

#

I thought the """
""" was the help description

#

@ me when you can help

tawny knoll
#

is there any way to get the message history of a specific user without first check the entire message history?

#

like the usual way i would handle it is iterating over channel history and checking if each message author is the targeted author, but that is super slow

dapper cobalt
#

Add a check.

tawny knoll
#

i got an error saying check was an invalid keyword

jade tartan
#
Traceback (most recent call last):
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\thoma\Desktop\discord.py\python\bot.py", line 38, in on_raw_reaction_remove
    for key, value in data:
ValueError: too many values to unpack (expected 2)```
#

anyone?

jade tartan
polar ice
#

hey when using MySQL with discord do i need to open the connection everytime i update something? or can i open the connection once and go from there?

distant warren
#

How do I get the User ID of the bot

#

I want to get the ID of the bot

vast gale
#

bot.user.id

spring flax
#

Is the best way to get when a user stopped boosting the sever through on_member_update for roles and see if he lost the premium role

vast gale
#

i never thought of that

#

there also may be a guild update

spring flax
#

Idts

vast gale
#

hmm?

spring flax
#

I don't think so*

#

Guild update is there yes but not for boost tracking

odd walrus
#

so im making a discord bot where i want the command to loop something but it continously stops unexpectedly
any way for it to not break? there are no errors in the logs of the cmd so im unsure why its stopping

heady night
#

so im tryna run a main.py and it saying this

vague grove
#

!d discord.Message.pinned

odd walrus
#

import requests

heady night
#

how do i do that

odd walrus
#

in your code

#

on top of everything

vague grove
#

how do i detect a pin?

heady night
#

do import requests

odd walrus
#

type in
import requests

heady night
#

alright

#

@odd walrus

#

i put still same issue

odd walrus
#

uhh

vague grove
#

!d discord.Message.pin

odd walrus
#

try do pip install requests

#

in cmd

heady night
odd walrus
#

no worries

vague grove
#

hey guys, how can i detect a new pin in a channel

brave flint
#

hello, did anyone can help me?. currently im making stats cmd for my bot
im trying make uptime with time and psutil and get error :
An error occurred: Command raised an exception: TypeError: get_uptime() takes 0 positional arguments but 1 was given
code :

jade tartan
#

How do i specify member on line 180?

#

ohh nvm i got it

high pollen
#
ModuleNotFoundError: No module named 'discord'```
#

and pip install discord.py Requirement already satisfied

slate swan
#

Restart your Ide

jade tartan
#
@client.event
async def on_ready():
    print(f"{client.user.name} is online")
    DiscordComponents(client)

@client.event
async def on_raw_reaction_remove(payload):
    with open('reactrole.json') as react_file:
        data = json.load(react_file)
        for key, value in data.items():
            if value['emoji'] == payload.emoji.name:
                role = discord.utils.get(client.get_guild(
                    payload.guild_id).roles, id=['role_id'])

                await client.get_guild(payload.guild_id).get_member(payload.user_id).remove_roles(role)

@client.event
async def on_member_join(member):
        guild = client.get_guild(730651046459998218)
        channel = guild.get_channel(885464532959526913)
        myEmbed = discord.Embed(title = f"Welcome",
        description= f"You are member {guild.member_count}, \n Enjoy your stay here and dont forget to read the await [#904279966693355550](/guild/267624335836053506/channel/904279966693355550/)", color=0x0ff00)
        await channel.send(embed=myEmbed)
        role = guild.get_role(832120561848156180)
        await member.add_roles(role)

@client.event
async def on_raw_reaction_add(payload):
    ourMessageID = 903210158803537970

    if ourMessageID == 903210158803537970:
        member = payload.member
        guild = member.guild

        emoji = payload.emoji.name
        if emoji == '✅':
            role = discord.utils.get(guild.roles, name="Member")
            await member.add_roles(role)


@client.event
async def on_raw_reaction_add(payload):
    if payload.member.bot:
        pass

    else:
        with open('reactrole.json') as react_file:
            data = json.load(react_file)
            for key, value in data.items():
                    if value['emoji'] == payload.emoji.name:
                        role = discord.utils.get(client.get_guild(
                        payload.guild_id).roles, id=['829665222380879912'])

                        await payload.member.add_roles(role)``` 
i have this code but this code aint really working its not giving the autorole role
sullen shoal
#

exec executes code directly as if its a part of the script, it doesnt have any return value
you could try doing smth like,

def func(code):
    new = "\n".join(["\t" + line for line in code.splitlines()])
    exec(f"def _func():\n{new}\nglobals()['_return']=_func()")
    return _return

print(func("return 'hi'"))

not sure if it works tho

high pollen
vagrant brook
#

eval() instead of exec() if you want return value btw

slate swan
jade tartan
#

Hello

vagrant brook
#

For every functions inside classes

brave flint
#

oh so get_uptime(self)

vagrant brook
#

Yes

brave flint
vagrant brook
#

Then you can call it with self.get_uptime()

brave flint
#

but on my return value is it true?

vagrant brook
#

try it and see

brave flint
jade tartan
#

Hello any one?

brave flint
jade tartan
#

my bot isnt giving the auto role this is my code but it aint giving errors

#
@client.event
async def on_ready():
    print(f"{client.user.name} is online")
    DiscordComponents(client)

@client.event
async def on_raw_reaction_remove(payload):
    with open('reactrole.json') as react_file:
        data = json.load(react_file)
        for key, value in data.items():
            if value['emoji'] == payload.emoji.name:
                role = discord.utils.get(client.get_guild(
                    payload.guild_id).roles, id=['role_id'])

                await client.get_guild(payload.guild_id).get_member(payload.user_id).remove_roles(role)

@client.event
async def on_member_join(member):
        guild = client.get_guild(730651046459998218)
        channel = guild.get_channel(885464532959526913)
        myEmbed = discord.Embed(title = f"Welcome",
        description= f"You are member {guild.member_count}, \n Enjoy your stay here and dont forget to read the await [#904279966693355550](/guild/267624335836053506/channel/904279966693355550/)", color=0x0ff00)
        await channel.send(embed=myEmbed)
        role = guild.get_role(832120561848156180)
        await member.add_roles(role)

@client.event
async def on_raw_reaction_add(payload):
    ourMessageID = 903210158803537970

    if ourMessageID == 903210158803537970:
        member = payload.member
        guild = member.guild

        emoji = payload.emoji.name
        if emoji == '✅':
            role = discord.utils.get(guild.roles, name="Member")
            await member.add_roles(role)


@client.event
async def on_raw_reaction_add(payload):
    if payload.member.bot:
        pass

    else:
        with open('reactrole.json') as react_file:
            data = json.load(react_file)
            for key, value in data.items():
                    if value['emoji'] == payload.emoji.name:
                        role = discord.utils.get(client.get_guild(
                        payload.guild_id).roles, id=['829665222380879912'])

                        await payload.member.add_roles(role)```
#

@brave flint

#

here is my whole code if u want it

high pollen
brave flint
vagrant brook
#

isn't sending better smh

unkempt canyonBOT
#

Hey @jade tartan!

Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:

• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)

• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:

https://paste.pythondiscord.com

vagrant brook
#

Why do you have 2 on_raw_reaction_add events

jade tartan
jade tartan
# vagrant brook Why do you have 2 on_raw_reaction_add events
async def on_raw_reaction_add(payload):
    ourMessageID = 903210158803537970

    if ourMessageID == 903210158803537970:
        member = payload.member
        guild = member.guild

        emoji = payload.emoji.name
        if emoji == '✅':
            role = discord.utils.get(guild.roles, name="Member")
            await member.add_roles(role)


@client.event
async def on_raw_reaction_add(payload):
    if payload.member.bot:
        pass

    else:
        with open('reactrole.json') as react_file:
            data = json.load(react_file)
            for key, value in data.items():
                    if value['emoji'] == payload.emoji.name:
                        role = discord.utils.get(client.get_guild(
                        payload.guild_id).roles, id=['829665222380879912    '])

                        await payload.member.add_roles(role)```
#

there 2 difference reaction codes

vagrant brook
#

You can only have one

jade tartan
#

first one

#

is for the message

#

2nd for json file

vagrant brook
#

But can't you just have both of the code in one event 🙂

jade tartan
#

i can do that but i cant it separate

vagrant brook
#

Well

#

It would still be okay if they are in the same function
How would it make any differences

brave flint
vagrant brook
#

Because you can't have two events with the same name

jade tartan
#

yeah well that aint a problem in python it kinda still works

#

could you just help me with question

#

or concern

vagrant brook
#

I just did

#

One of your functions got shadowed

jade tartan
#

ok then i dont think so but okay

vagrant brook
#

That's how d.py works

#

It's not python

#

If you want 2 events with the same name you need a listener

jade tartan
#
async def on_raw_reaction_add(payload):
    if payload.member.bot:
        pass
    else:
        with open('reactrole.json') as react_file:
            data = json.load(react_file)
            for key, value in data.items():
                    if value['emoji'] == payload.emoji.name:
                        role = discord.utils.get(client.get_guild(
                        payload.guild_id).roles, id=['829665222380879912    '])
                        await payload.member.add_roles(role)
                        ourMessageID = 903210158803537970
    if ourMessageID == 903210158803537970:
        member = payload.member
        guild = member.guild

        emoji = payload.emoji.name
        if emoji == '✅':
            role = discord.utils.get(guild.roles, name="Member")
            await member.add_roles(role)

#

so its like this

vagrant brook
#

why is ourMessageID inside the for loop lmao

slate swan
slate swan
patent lark
#

you actually can have the same event twice, use bot.listen("on_raw_reaction_add") then define the function as a different function name.

vagrant brook
#

Yeah that's what I meant a listener

jade tartan
#

omg is my code even readable?

#

or like easy to read

vagrant brook
#

it's kinda short so yeah it's readable

jade tartan
#

ok

#

So what?

graceful mulch
graceful mulch
#

Then also same error

#

?

high pollen
#

yes

graceful mulch
#

Huh

#

Lemme check

high pollen
jade tartan
#

So @vagrant brook ?

graceful mulch
high pollen
#

local

graceful mulch
#

names are so funny

high pollen
#

vscode

upbeat otter
high pollen
high pollen
graceful mulch
#

see I would recommend REPLIT because vs code is kinda complicated

#

I got the same error

upbeat otter
graceful mulch
#

forever

#

until I used vs code

high pollen
graceful mulch
#

such a bad experience

upbeat otter
graceful mulch
high pollen
#

i dont like replit

final iron
upbeat otter
final iron
#
While this may seem like a nice and free service, it has a lot more caveats than you might think, such as:
- The machines are super underpowered.
- - This means your bot will lag a lot as it gets bigger.
- You need to run a webserver alongside your bot to prevent it from being shut off.
- - This isn't a trivial task, and eats more of the machines power.
- Repl.it uses an ephemeral file system.
- - This means any file you saved via your bot will be overwritten when you next launch.
- They use a shared IP for everything running on the service.
This one is important - if someone is running a user bot on their service and gets banned, everyone on that IP will be banned. Including you.
#

^ in regard to replit

final iron
high pollen
#

ok

upbeat otter
high pollen
#

will try

final iron
#

I personally use 3.9.6 and it works fine

upbeat otter
#

I use 3.9.9

jade tartan
#

So what now?

upbeat otter
#

Cry

graceful mulch
final iron
upbeat otter
upbeat otter
final iron
#
- Bots are not what the platform is designed for. Heroku is designed to provide web servers (like Django, Flask, etc). This is why they give you a domain name and open a port on their local emulator.
- Heroku's environment is heavily containerized, making it significantly underpowered for a standard use case.
- Heroku's environment is volatile. In order to handle the insane amount of users trying to use it for their own applications, Heroku will dispose your environment every time your application dies unless you pay.
- Heroku has minimal system dependency control. If any of your Python requirements need C bindings (such as PyNaCl binding to libsodium, or lxml binding to libxml), they are unlikely to function properly, if at all, in a native environment. As such, you often need to resort to adding third-party buildpacks to facilitate otherwise normal CPython extension functionality. (This is the reason why voice doesn't work natively on heroku.)
- Heroku only offers a limited amount of time on their free programme for your applications. If you exceed this limit, which you probably will, they'll shut down your application until your free credit resets.
#

^ In reference to Heroku

upbeat otter
final iron
distant warren
distant warren
jade tartan
#

ok well my code works but now its giving me the role when i react to my emoji on the embed message

#

can someone help

high pollen
distant warren
#

!docs multiprocessing

unkempt canyonBOT
jade tartan
upbeat otter
distant warren
#

ok

#

it's basically like threading

high pollen
upbeat otter
distant warren
#

except it runs on top of each other

jade tartan
maiden fable
distant warren
#

instead of like threads

high pollen
distant warren
jade tartan
#

@upbeat otter

final iron
jade tartan
final iron
#

I'm not even sure if making a bot with threads is possible

upbeat otter
distant warren
maiden fable
jade tartan
#
async def on_raw_reaction_add(payload):
    ourMessageID = 903210158803537970

    if ourMessageID == 903210158803537970:
        member = payload.member
        guild = member.guild

        emoji = payload.emoji.name
        if emoji == ':white_check_mark:':
            role = discord.utils.get(guild.roles, name="Member")
            await member.add_roles(role)


@client.event
async def on_raw_reaction_add(payload):
    if payload.member.bot:
        pass

    else:
        with open('reactrole.json') as react_file:
            data = json.load(react_file)
            for key, value in data.items():
                    if value['emoji'] == payload.emoji.name:
                        role = discord.utils.get(client.get_guild(
                        payload.guild_id).roles, id=['829665222380879912'])

                        await payload.member.add_roles(role)```
#

and have this code

#
async def reactrole(ctx, emoji, role : discord.Role, *, message):
  if ctx.author.guild_permissions.manage_roles == True:
    if emoji == '☑️':
        await ctx.send(embed=discord.Embed(title="Reaction Roles", description="**Syntax** : `gm<reactrole (emoji) (name or role) (message)`", color=discord.Color.blue()))
    elif role == None:
        await ctx.send(embed=discord.Embed(title="Reaction Roles", description="**Syntax** : `gm<reactrole (emoji) (name or role) (message)`", color=discord.Color.blue()))
    else:
        emb = discord.Embed(title=f"React for {role.name} Role!", description=message, color=discord.Color.blue())
        msg = await ctx.channel.send(embed=emb)
        await msg.add_reaction("\U00002705")

        with open('reactrole.json') as json_file:
            data = json.load(json_file)

            new_react_role = {'role_name': role.name,
                              'role_id': role.id,
                              'emoji': emoji,
                              'message_id': msg.id}
            
            data['Member'] = new_react_role

        with open('reactrole.json', 'w') as f:
            json.dump(data, f, indent=4)
  else:
    await ctx.send(embed=discord.Embed(title="Missing Permissions", description="You dont have permission to use this command!", color=discord.Color.blue()))
upbeat otter
jade tartan
#

thats fine others will help

maiden fable
#

What's the problem

jade tartan
#

that its not giving me the role when i react to the emoji on an embed message

high pollen
#

i am adding it to path and will try

#

nvm same problem

#

will install 3.9.9

upbeat otter
maiden fable
#

Why install 3.9 tho. I use Dpy 2.0 with 3.10

high pollen
maiden fable
#

What's the error

upbeat otter
#

Module not found

visual island
maiden fable
graceful mulch
#

Hello I want to make a work command for my bot like it is in economy bots like dank memer how can I do it

upbeat otter
#

Refresh your terminal and code editors and try again @high pollen

maiden fable
maiden fable
visual island
high pollen
upbeat otter
visual island
upbeat otter
high pollen
#

ok

graceful mulch
#

Pls help me

visual island
upbeat otter
high pollen
#

ok

visual island
upbeat otter
#

Thank me later

graceful mulch
#

No I cant understand whether i should use a json file or what

graceful mulch
#

i dont have

visual island
#

sqlite3 or something else

visual island
#

its built-in

jade tartan
#
Traceback (most recent call last):
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\thoma\Desktop\discord.py\python\bot.py", line 71, in on_raw_reaction_add
    await payload.member.add_roles(role)
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\member.py", line 777, in add_roles
    await req(guild_id, user_id, role.id, reason=reason)
AttributeError: 'NoneType' object has no attribute 'id'```
#

plz

sullen shoal
#

just because it works, you shouldn't

#

its not meant to be a database

upbeat otter
graceful mulch
#

too i DONT KNOW HOW DO I SOLVE IT

#
@client.command(aliases = ["lb"])
async def leaderboard(ctx,x = 3):
    users = await get_bank_data()
    leader_board = {}
    total = []
    for user in users:
        name = int(user)
        total_amount = users[user]["wallet"] + users[user]["bank"]
        leader_board[total_amount] = name
        total.append(total_amount)

    total = sorted(total,reverse=True)    

    em = discord.Embed(title = f"Top {x} Richest People" , description = "This is decided on the basis of raw money in the bank and wallet",color = discord.Color(0xfa43ee))
    index = 1
    for amt in total:
        id_ = leader_board[amt]
        member = ctx.get_user(id_)
        name = member.id
        em.add_field(name = f"{index}. {name}" , value = f"{amt}",  inline = False)
        if index == x:
            break
        else:
            index += 1

    await ctx.send(embed = em)
slate swan
#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

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

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

jade tartan
#
async def reactrole(ctx, emoji, role : discord.Role, *, message):
  if ctx.author.guild_permissions.manage_roles == True:
    if emoji == '☑️':
        await ctx.send(embed=discord.Embed(title="Reaction Roles", description="**Syntax** : `gm<reactrole (emoji) (name or role) (message)`", color=discord.Color.blue()))
    elif role == Member:
        await ctx.send(embed=discord.Embed(title="Reaction Roles", description="**Syntax** : `gm<reactrole (emoji) (name or role) (message)`", color=discord.Color.blue()))
    else:
        emb = discord.Embed(title=f"React for {role.name} Role!", description=message, color=discord.Color.blue())
        msg = await ctx.channel.send(embed=emb)
        await msg.add_reaction("\U00002705")

        with open('reactrole.json') as json_file:
            data = json.load(json_file)

            new_react_role = {'role_name': role.name,
                              'role_id': role.id,
                              'emoji': emoji,
                              'message_id': msg.id}
            
            data['Member'] = new_react_role

        with open('reactrole.json', 'w') as f:
            json.dump(data, f, indent=4)
  else:
    await ctx.send(embed=discord.Embed(title="Missing Permissions", description="You dont have permission to use this command!", color=discord.Color.blue()))

???

graceful mulch
graceful mulch
#

And If I remove id from member it says None

spring flax
#

@slate swan question: Which is the best way to check for who stopped boosting a server?

visual island
upbeat otter
graceful mulch
#

AttributeError: 'NoneType' object has no attribute 'id'

unkempt canyonBOT
#

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

A full traceback could look like:

Traceback (most recent call last):
    File "tiny", line 3, in
        do_something()
    File "tiny", line 2, in do_something
        a = 6 / b
ZeroDivisionError: division by zero

The best way to read your traceback is bottom to top.

• Identify the exception raised (in this case ZeroDivisionError)
• Make note of the line number (in this case 2), and navigate there in your program.
• Try to understand why the error occurred (in this case because b is 0).

To read more about exceptions and errors, please refer to the PyDis Wiki or the official Python tutorial.

slate swan
graceful mulch
slate swan
jade tartan
#
Traceback (most recent call last):
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\thoma\Desktop\discord.py\python\bot.py", line 72, in on_raw_reaction_add
    await payload.member.add_roles(role)
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\member.py", line 777, in add_roles
    await req(guild_id, user_id, role.id, reason=reason)
AttributeError: 'NoneType' object has no attribute 'id'
``` same error
upbeat otter
graceful mulch
#

See

spring flax
jade tartan
#
async def on_raw_reaction_add(payload):
    if payload.member.bot:
        pass

    else:
        with open('reactrole.json') as react_file:
            data = json.load(react_file)
            for key, value in data.items():
                    if value['emoji'] == payload.emoji.name:
                        role = discord.utils.get(client.get_guild(payload.guild_id).roles, id=('829665222380879912'))
                        await payload.member.add_roles(role)```?
steep drift
#

I need some help, the bot will not work, please help me!

graceful mulch
jade tartan
#

@visual island

graceful mulch
#

<t:>

visual island
slate swan
jade tartan
slate swan
visual island
jade tartan
spring flax
#

Oh

visual island
graceful mulch
#


@client.command()
async def ranks(ctx, x=10):
  with open('level.json', 'r') as f:
    
    users = json.load(f)
    
  leaderboard = {}
  total=[]
  
  for user in list(users[str(ctx.guild.id)]):
    name = int(user)
    total_amt = users[str(ctx.guild.id)][str(user)]['experience']
    leaderboard[total_amt] = name
    total.append(total_amt)
    

  total = sorted(total,reverse=True)
  

  em = discord.Embed(
    title = f'Top {x} highest leveled members in {ctx.guild.name}',
    description = 'The highest leveled people in this server'
  )
  
  index = 1
  for amt in total:
    id_ = leaderboard[amt]
    member = client.get_user(id_)
    
    
    em.add_field(name = f'{index}: {member}', value = f'{amt}', inline=False)
    
    
    if index == x:
      break
    else:
      index += 1
      
  await ctx.send(embed = em)
``` See this my code
jade tartan
#

int how?

visual island
# slate swan

why not just use on_guild_update pretty sure its dispatched on premium_subscriber change

jade tartan
#

id=(['829665222380879912']))

spring flax
# slate swan flags do not include nitro related stuff

this would work right?

@bot.event
async def on_member_update(before, after):
    channel = disnake.utils.get(before.guild.channels, id=880097117803266099)
    role = disnake.utils.get(after.guild.roles, id=803191738683621416)
    #if role in before.roles and role not in after.roles:
    if after.guild.premium_subscriber_role in before.roles and after.guild.premium_subscriber_role not in after.roles:
            await channel.send(f"Someone stopped boosting the server")
steep drift
#

:D

visual island
visual island
steep drift
#

what, lol

upbeat otter
visual island
graceful mulch
steep drift
graceful mulch
#
{"856787557429018645": {"900992402356043806": {"experience": 1244.0, "level": 5}, "908185207163744297": {"experience": 16, "level": 2}}, "898850971776593930": {"900992402356043806": {"experience": 44.0, "level": 2}, "776867805727031336": {"experience": 3.0, "level": 1}, "871795742589726850": {"experience": 2, "level": 1}, "908185207163744297": {"experience": 1, "level": 1}}, "893770828632719453": {"900992402356043806": {"experience": 182.5, "level": 3}, "908185207163744297": {"experience": 3, "level": 1}, "748500414277877841": {"experience": 75, "level": 2}, "893166314435256401": {"experience": 3, "level": 1}}, "906408723709296681": {"900992402356043806": {"experience": 271.5, "level": 4}, "748500414277877841": {"experience": 48, "level": 2}}, "883572338975715358": {"719112857261965335": {"experience": 130.5, "level": 3}, "775643767943725066": {"experience": 3.0, "level": 1}, "785749328626319360": {"experience": 1.5, "level": 1}, "889834325804195861": {"experience": 26, "level": 2}}, "912559425921892392": {"737946035694993408": {"experience": 532, "level": 4}, "900992402356043806": {"experience": 2556, "level": 7}, "908185207163744297": {"experience": 129, "level": 3}}, "912569937116147772": {"900992402356043806": {"experience": 1202, "level": 5}, "908185207163744297": {"experience": 139, "level": 3}, "748500414277877841": {"experience": 109, "level": 3}, "871795742589726850": {"experience": 64, "level": 2}}, "892238407315619881": {"900992402356043806": {"experience": 116, "level": 3}, "513300232415739904": {"experience": 3, "level": 1}, "748500414277877841": {"experience": 13, "level": 1}}}
upbeat otter
visual island
slate swan
graceful mulch
upbeat otter
graceful mulch
#

i cant

visual island
graceful mulch
#

cuz it has to be server idepenedent

jade tartan
#

Like this?

steep drift
slate swan
steep drift
visual island
upbeat otter
steep drift
graceful mulch
steep drift
#

tried anyways

graceful mulch
#

EOF also comes when there is unidentied character

visual island
jade tartan
#

@visual island correct?

visual island
steep drift
sullen shoal
#

why do you guys think of some people as your compiler

high pollen
#

@upbeat otter pls check you DMs

sullen shoal
#

just run it and see if it works

slate swan
jade tartan
steep drift
slate swan
steep drift
#

what would that be?

#

I new so sorry.

graceful mulch
jade tartan
#

ohh oops

#

comes after the @client.event

graceful mulch
#

@unkempt canyon

visual island
steep drift
graceful mulch
#

How do I grow my bot?

jade tartan
graceful mulch
#

Only 9 servers and people remove bots in between

visual island
visual island
steep drift
jade tartan
#

no error but still wont give me the role

jade tartan
visual island
steep drift
#

k now only 1 problem, lol

#

the import discord so odd, why does it not work

visual island
visual island
steep drift
#

or no?

spring flax
unkempt canyonBOT
#

discord.on_guild_channel_pins_update(channel, last_pin)```
Called whenever a message is pinned or unpinned from a guild channel.

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

how do i make a bot that detects if a channel reaches 100+ messages in the past 5 minutes, it sends something?

graceful mulch
#

It sends none of every user except itself

#

why I want that only to improve

#

btw 1st is me

slate swan
#

does anybody know js here?

obsidian ledge
slate swan
steep drift
#

k I insalled it but now this is the error

slate swan
visual island
unkempt canyonBOT
#

Cooldowns in discord.py

Cooldowns can be used in discord.py to rate-limit. In this example, we're using it in an on_message.

from discord.ext import commands

message_cooldown = commands.CooldownMapping.from_cooldown(1.0, 60.0, commands.BucketType.user)

@bot.event
async def on_message(message):
    bucket = message_cooldown.get_bucket(message)
    retry_after = bucket.update_rate_limit()
    if retry_after:
        await message.channel.send(f"Slow down! Try again in {retry_after} seconds.")
    else:
        await message.channel.send("Not ratelimited!")

from_cooldown takes the amount of update_rate_limit()s needed to trigger the cooldown, the time in which the cooldown is triggered, and a BucketType.

visual island
spring flax
visual island
#

not enviorn

graceful mulch
#

Hey help me pls

steep drift
#

TYSM!!!!!

#

:D

upbeat otter
visual island
spring flax
#

is it not the most efficient because the boost role can be none?

graceful mulch
visual island
#

there are many factors

upbeat otter
spring flax
#

hmmmm so you suggest what you said about comparing the before boosters and after boosters to see who stopped?

upbeat otter
visual island
spring flax
#

well

maiden fable
upbeat otter
maiden fable
#

Morning

upbeat otter
slate swan
#

word limits prolly

maiden fable
upbeat otter
maiden fable
#

Discord broke 🥲

upbeat otter
slate swan
upbeat otter
#

rate limit

maiden fable
#

Tf?

maiden fable
jade tartan
#

So whats going on my bot doesnt seem to give the role to the member

#

?

jade tartan
#

plz someon

upbeat otter
maiden fable
#

😐

jade tartan
visual island
maiden fable
maiden fable
upbeat otter
#

lmao

jade tartan
# maiden fable Code?

idk which cuz i dont have any error like when u react to the emoji it wont give any error

#

so

#

but okay

maiden fable
#

lemon_sentimental welp

jade tartan
#
async def on_raw_reaction_add(payload):
    ourMessageID = 914720242297630750

    if ourMessageID == 914720242297630750:
        member = payload.member
        guild = member.guild

        emoji = payload.emoji.name
        if emoji == '✅':
            role = discord.utils.get(guild.roles, name="Member")
            await member.add_roles(role)


@client.event
async def on_raw_reaction_add(payload):
    if payload.member.bot:
        pass

    else:
        with open('reactrole.json') as react_file:
            data = json.load(react_file)
            for key, value in data.items():
                    if value['emoji'] == payload.emoji.name:
                        role = discord.utils.get(client.get_guild(payload.guild_id).roles, id=829665222380879912)
                        await payload.member.add_roles(role)```
#
async def reactrole(ctx, emoji, role : discord.Role, *, message):
  if ctx.author.guild_permissions.manage_roles == True:
    if emoji == '☑️':
        await ctx.send(embed=discord.Embed(title="Reaction Roles", description="**Syntax** : `gm<reactrole (emoji) (name or role) (message)`", color=discord.Color.blue()))
    elif role == Member:
        await ctx.send(embed=discord.Embed(title="Reaction Roles", description="**Syntax** : `gm<reactrole (emoji) (name or role) (message)`", color=discord.Color.blue()))
    else:
        emb = discord.Embed(title=f"React for {role.name} Role!", description=message, color=discord.Color.blue())
        msg = await ctx.channel.send(embed=emb)
        await msg.add_reaction("\U00002705")

        with open('reactrole.json') as json_file:
            data = json.load(json_file)

            new_react_role = {'role_name': role.name,
                              'role_id': role.id,
                              'emoji': emoji,
                              'message_id': msg.id}
            
            data['Member'] = new_react_role

        with open('reactrole.json', 'w') as f:
            json.dump(data, f, indent=4)
  else:
    await ctx.send(embed=discord.Embed(title="Missing Permissions", description="You dont have permission to use this command!", color=discord.Color.blue()))

maiden fable
#

😐

jade tartan
#

What?

#

ok

#

Whats the idea? and okay

maiden fable
#

@jade tartan please edit your code with codeblocks

#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

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

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

vast spindle
#

How could I add something like this

maiden fable
#

Ah buttons

#

U need to use Discord.py 2.0 or any fork like disnake or nextcord

#

!d discord.ui.button

unkempt canyonBOT
#

discord.ui.button(*, label=None, custom_id=None, disabled=False, style=<ButtonStyle.secondary: 2>, emoji=None, row=None)```
A decorator that attaches a button to a component.

The function being decorated should have three parameters, `self` representing the [`discord.ui.View`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.View "discord.ui.View"), the [`discord.ui.Button`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.Button "discord.ui.Button") being pressed and the [`discord.Interaction`](https://discordpy.readthedocs.io/en/master/api.html#discord.Interaction "discord.Interaction") you receive.

Note

Buttons with a URL cannot be created with this function. Consider creating a [`Button`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.Button "discord.ui.Button") manually instead. This is because buttons with a URL do not have a callback associated with them since Discord does not do any processing with it.
maiden fable
#

!d discord.ButtonStyle

unkempt canyonBOT
#

class discord.ButtonStyle```
Represents the style of the button component.

New in version 2.0.
obsidian ledge
#

how do i make my embed footer edit after someone presses a button?
like if someone were to press a button the footer would edit to "this user has pressed this button!"?

sullen shoal
#

update the embed instance and then edit the message with the updated embed

obsidian ledge
#

code example?

graceful mulch
#

@maiden fable how you add this

sullen shoal
maiden fable
graceful mulch
#

like these checkboxes

#

how the unchecked one

maiden fable
slate swan
graceful mulch
#

Can I copy your code a bit of welcomer.py mine isnt working @maiden fable

maiden fable
graceful mulch
graceful mulch
#

sorry

maiden fable
#

From where did u get that 🤨

#

And which cog

graceful mulch
#

Sorry OMG @slate swan

slate swan
#

lol

graceful mulch
#

Really sorry I am really mad nowadays

slate swan
#

you can use that , but its still under development

graceful mulch
#

I was checking Kakashi

#

Ok

maiden fable
#

My man still in sleep

slate swan
#

you can just set the channel and message for now , im adding color and welcome type options

graceful mulch
#

why you added the database

#

I dont have any experience in it

slate swan
#

the bot's meant for multiple servers , and i dont want to use json so yea

#

as for the database , its sqlite so you wont have to do any setup for it :)

graceful mulch
#

!d discord.ui.button

unkempt canyonBOT
#

discord.ui.button(*, label=None, custom_id=None, disabled=False, style=<ButtonStyle.secondary: 2>, emoji=None, row=None)```
A decorator that attaches a button to a component.

The function being decorated should have three parameters, `self` representing the [`discord.ui.View`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.View "discord.ui.View"), the [`discord.ui.Button`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.Button "discord.ui.Button") being pressed and the [`discord.Interaction`](https://discordpy.readthedocs.io/en/master/api.html#discord.Interaction "discord.Interaction") you receive.

Note

Buttons with a URL cannot be created with this function. Consider creating a [`Button`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.Button "discord.ui.Button") manually instead. This is because buttons with a URL do not have a callback associated with them since Discord does not do any processing with it.
graceful mulch
#

!dislash

slate swan
#

its not documented in the bot

graceful mulch
#

OH

slate swan
graceful mulch
#

ok thank

ionic pebble
#

is discordpy here to stay now? and is discord-py-slash-command the most popular slash command lib?

brittle ingot
#

Discord.py’s library was discontinued. It still works but is missing some key additions. You are welcome to use it as its stable. However you will need to use external libraries to add functionality that is missing. There are other forks that developers are working from to recreate and improve on the current library

vocal plover
#

no

slate swan
zealous dagger
#

How to make a slash command and remember I have used discord.py and discord client not bot.

simple gulch
#

I'm trying to make a discord.py bot and in it I am doing this

   return```
To make sure my users have my other bot in the server. The Helper bot is in there, but it isn't seeing it?
#

Intents is on btw

zealous dagger
#

!d discord.ui.select

urban shell
#

hey, is there a way to check for messages sent in a channel

#

and DM the content of those messages to a user

slate swan
#

use on_message event

#

and user.send , you get the user from the cache by bot.get_user

earnest swallow
#

does anyone have idea how to code bots so they can react, and when user reacts they edit their message? :v

slate swan
#

!d discord.on_reaction_add

unkempt canyonBOT
#

discord.on_reaction_add(reaction, user)```
Called when a message has a reaction added to it. Similar to [`on_message_edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_message_edit "discord.on_message_edit"), if the message is not found in the internal message cache, then this event will not be called. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") instead.

Note

To get the [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") being reacted, access it via [`Reaction.message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Reaction.message "discord.Reaction.message").

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

Note

This doesn’t require [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") within a guild context, but due to Discord not providing updated user information in a direct message it’s required for direct messages to receive this event. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") if you need this and do not otherwise want to enable the members intent.
maiden fable
unkempt canyonBOT
#

class discord.ui.Select(*, custom_id=..., placeholder=None, min_values=1, max_values=1, options=..., disabled=False, row=None)```
Represents a UI select menu.

This is usually represented as a drop down menu.

In order to get the selected items that the user has chosen, use [`Select.values`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.Select.values "discord.ui.Select.values").

New in version 2.0.
earnest swallow
maiden fable
narrow tide
#

hi

maiden fable
#

U can Right Click the user and Copy ID

urban shell
slate swan
#

^

maiden fable
#

Nope, not without bot

urban shell
cloud bison
#

how i can make the bot respond depends in member role
I've tried this

if ctx.author.has_role(the role) :

still wont work

earnest swallow
maiden fable
shadow wraith
#

how do i make the bot status "playing <game>"

#

like ik it has to be in on_ready

maiden fable
unkempt canyonBOT
#

await change_presence(*, activity=None, status=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Changes the client’s presence.

Example

```py
game = discord.Game("with the API")
await client.change_presence(status=discord.Status.idle, activity=game)
```   Changed in version 2.0: Removed the `afk` keyword-only parameter.
earnest swallow
maiden fable
#

???

shadow wraith
#

guys

earnest swallow
#

discord.on_reaction_add(reaction, user)

shadow wraith
#

how do i make the bot in a playing status

earnest swallow
#

this part @maiden fable

earnest swallow
zealous dagger
#

How to make a slash command and remember I have used discord.py and discord client not bot.

#

Please tell

boreal ravine
#

🤔

zealous dagger
#

means

boreal ravine
#

e.g disnake, pycord etc

boreal ravine
#

try fetching it I guess

simple gulch
#

ty

cloud bison
jade tartan
# maiden fable <@506940530333057025> please edit your code with codeblocks
async def on_raw_reaction_add(payload):
    ourMessageID = 914720242297630750

    if ourMessageID == 914720242297630750:
        member = payload.member
        guild = member.guild

        emoji = payload.emoji.name
        if emoji == '✅':
            role = discord.utils.get(guild.roles, name="Member")
            await member.add_roles(role)


@client.event
async def on_raw_reaction_add(payload):
    if payload.member.bot:
        pass

    else:
        with open('reactrole.json') as react_file:
            data = json.load(react_file)
            for key, value in data.items():
                    if value['emoji'] == payload.emoji.name:
                        role = discord.utils.get(client.get_guild(payload.guild_id).roles, id=829665222380879912)
                        await payload.member.add_roles(role)```
slate swan
#

or a list of discord.Role obj

cloud bison
tawdry perch
unkempt canyonBOT
#

MyBot/cogs/moderation/general.py line 121

async def cog_check(self, ctx):```
high pollen
zealous dagger
#

how to set this

spring flax
#
@bot.event
async def on_guild_update(before, after):
    channel = disnake.utils.get(before.guild.channels, id=880097117803266099)
    #role = disnake.utils.get(after.guild.roles, id=803191738683621416)
    if after.premium_subscribers != before.premium_subscribers:
        member = set(before.premium_subscribers) - set(after.premium_subscribers)
        embed = disnake.Embed(description=f"{member.mention} {str(member)}")
        embed.set_author(url=member.avater_url)
        embed.set_footer(text=f"{member.id} | {embed.timestamp}")

This would work right?

zealous dagger
#

how to set this

maiden fable
#

!d discord.Client.change_presence @zealous dagger

unkempt canyonBOT
#

await change_presence(*, activity=None, status=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Changes the client’s presence.

Example

```py
game = discord.Game("with the API")
await client.change_presence(status=discord.Status.idle, activity=game)
```   Changed in version 2.0: Removed the `afk` keyword-only parameter.
zealous dagger
#

No

#

For the users

slate swan
maiden fable
unkempt canyonBOT
spring flax
#

does it seem right

zealous dagger
tawdry perch
#

I can't say, I'm outside

maiden fable
#

Also the first if statement won't work

spring flax
maiden fable
#

Since the booster roles can't be changed

spring flax
#

why not?

maiden fable
weary gale
#

im a bit gay rn, can someone correct this

spring flax
cloud bison
maiden fable
#

But that should work (sorry I misread premium_subscribers as the premium role before)

spring flax
weary gale
#

im stupid, thanks

maiden fable
#
role = discord.utils.get(ctx.author.roles, id=role-id) 
#

!d discord.utils.get

unkempt canyonBOT
#

discord.utils.get(iterable, **attrs)```
A helper that returns the first element in the iterable that meets all the traits passed in `attrs`. This is an alternative for [`find()`](https://discordpy.readthedocs.io/en/master/api.html#discord.utils.find "discord.utils.find").

When multiple attributes are specified, they are checked using logical AND, not logical OR. Meaning they have to meet every attribute passed in and not one of them.

To have a nested attribute search (i.e. search by `x.y`) then pass in `x__y` as the keyword argument.

If nothing is found that matches the attributes passed, then `None` is returned.

Examples

Basic usage...
maiden fable
#

Why not use get?

jade tartan
maiden fable
jade tartan
#

if value['emoji'] == payload.emoji.name:

#

This?

maiden fable
#

No

#

Line 7

jade tartan
#

omg it finally worked

#

with that

#

ive got something to ask

maiden fable
jade tartan
#

can i make my bot where members select a role and then they go to another channel and select another role and at the end they type for example agree to gain access to the rest of the channels?

covert igloo
jade tartan
#

Does that make sense?

maiden fable
#

Ig?

jade tartan
maiden fable
#

In the on_message event, try to see if the author has those 2 roles

jade tartan
maiden fable
#

Then make one lol

upbeat otter
upbeat otter
maiden fable
plain bison
#

ok so if i have a list of discord id's how can i dm msgs to them

jade tartan
#

Yeah but i mean idk i want my sever to be much easier to access to my channels once they get verifed

maiden fable
unkempt canyonBOT
maiden fable
#

!d discord.User.send

unkempt canyonBOT
#

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

Sends a message to the destination with the content given.

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

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

To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
plain bison
upbeat otter
maiden fable
#

;-;

boreal ravine
#

Nice

jade tartan
upbeat otter
#

to agree and disagree

maiden fable
jade tartan
#

hang on

upbeat otter
#

if they disagree, redirect them to a channel for help

maiden fable
#

:D

upbeat otter
maiden fable
#

🤣

jade tartan
maiden fable
#

Isn't that why I wrote that 🤨

jade tartan
#

maybe i can let the bot dm something like hey i think you have done verification wrong

jade tartan
#

please go back to the channel and re verify

maiden fable
#

Aw 😂

upbeat otter
boreal ravine
#

Can someone help me with trying to make my cogs case insensitive when calling them in the help command? I'm following this (https://gist.github.com/InterStella0/b78488fb28cadf279dfd3164b9f0cf96) but I'm not really sure if what I'm doing is right (I'm using the second way). There are no errors, the bot just doesn't recognize the cog and if I do the cog capitalized it works.

jade tartan
upbeat otter
jade tartan
#

but any way lets just make the agree thing

jade tartan
maiden fable
jade tartan
#

or make a suggestion

maiden fable
#

Just use str.lower() on the input and str.lower() on all the cogs' names

That's what I had do

boreal ravine
upbeat otter
boreal ravine
maiden fable
#

Then....?

jade tartan
boreal ravine
# maiden fable Then....?

I'm using this

    async def send_cog_help(self, cog):
        title = cog.qualified_name or "No"
        await self.send_help_embed(
            f"{title} Category", cog.description, cog.get_commands()
        )
``` I tried getting the cog using `bot` but I kept getting a circular import issue
upbeat otter
maiden fable
#

Okay

upbeat otter
#

sad

maiden fable
#

So I guess u can see how @unkempt canyon has implemented it?

boreal ravine
#

just read it's source code lmfao

maiden fable
boreal ravine
#

oh

jade tartan
#

nah i wanna make it like this

boreal ravine
jade tartan
#

@upbeat otter

maiden fable
boreal ravine
#

ic

upbeat otter
maiden fable
#

But yea, don't mess with the internals

jade tartan
#

could you just help me make the agree thing ?

maiden fable
#

!d discord.ext.commands.HelpCommand.send_cog_help

unkempt canyonBOT
#

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

Handles the implementation of the cog page in the help command. This function is called when the help command is called with a cog as the argument.

It should be noted that this method does not return anything – rather the actual message sending should be done inside this method. Well behaved subclasses should use [`get_destination()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.HelpCommand.get_destination "discord.ext.commands.HelpCommand.get_destination") to know where to send, as this is a customisation point for other users.

You can override this method to customise the behaviour...
boreal ravine
maiden fable
boreal ravine
maiden fable
#

O icy here

upbeat otter
visual island
boreal ravine
boreal ravine
maiden fable
boreal ravine
jade tartan
#

then

maiden fable
visual island
boreal ravine
upbeat otter
jade tartan
#

ok thanks

maiden fable
boreal ravine
#

this'll work right? ```py
cog = self.context.bot.get_cog(cog.upper() or cog.lower())

maiden fable
#

My whole bot is based on buttons and nothing else 🤣

jade tartan
#

ok do u have the docs for the buttons then? maybe for the future

maiden fable
#

But

#

cog.title() gonna work better

boreal ravine
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.
maiden fable
#

!d str.title

unkempt canyonBOT
#

str.title()```
Return a titlecased version of the string where words start with an uppercase character and the remaining characters are lowercase.

For example:

```py
>>> 'Hello world'.title()
'Hello World'
```  The algorithm uses a simple language-independent definition of a word as groups of consecutive letters. The definition works in many contexts but it means that apostrophes in contractions and possessives form word boundaries, which may not be the desired result:

```py
>>> "they're bill's friends from the UK".title()
"They'Re Bill'S Friends From The Uk"
```...
slate swan
unkempt canyonBOT
#

discord/ext/commands/help.py lines 838 to 841

# Check if it's a cog
cog = bot.get_cog(command)
if cog is not None:
    return await self.send_cog_help(cog)```
upbeat otter
#

guys, how do I make an nsfw channel?

unkempt canyonBOT
#

Hey @pastel cobalt!

Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:

• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)

• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:

https://paste.pythondiscord.com

maiden fable
#

!d discord.Guild.create_text_channel

unkempt canyonBOT
#

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

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

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

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

Note

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

nsfw kwarg

upbeat otter
#

ohhh, thank you

velvet tinsel
#

hi

maiden fable
#

@velvet tinsel

velvet tinsel
#

😠

jade tartan
#

sorry tos

jade tartan
#

ok

velvet tinsel
#

there is no rules against it

pastel cobalt
maiden fable
slate swan
#

can someone show me an example of discord.py slash commands