#discord-bots

1 messages · Page 2 of 1

cold tide
#

Oh is it? @slate swan

#

Dang nvm then lol

slate swan
#

Not even discord api allows you to spam bans and all for some event.

cold tide
#

My bad

swift pumice
#

hi guys

slate swan
#

Maybe their intentions are just to make one of the bot they see in channels like sounddrout and all, but yeah even they break tos and shouldn't be allowed

swift pumice
#

rate my pfp

slate swan
slate swan
swift pumice
#

💀

#

why wont just ping by urself?

slate swan
#

the funny thing is he got the everyone role in the worst way possible

slate swan
slate swan
#

no

#

just use the guilds id

#

the everyone role has the same id as the guild pithink

#

guild.default_role ? even easier

#

Did they really try edit there code lololol.... Just tag mods to ban them next time xD

#

the funny thing is he forgot to remove the while True part🥴

#

anyways lets move our topics.

swift pumice
#

a command just to ping everyone?

slate swan
#

.topic

lament depotBOT
#
**What feature would you like to see added to the library? What feature in the library do you think is redundant?**

Suggest more topics here!

swift pumice
#

wouldnt it be faster if they would just ping by them self everyone

slate swan
#

Im still debating whether to move my discord bot into a database tbf... Just recently upgraded it to 2.0 and broke everything 😐 wasn't fun fixing it...

#

⭐just use disnake⭐

slate swan
swift pumice
#

nextcord🗿

slate swan
swift pumice
#

nextcord betta

#

🗿

slate swan
#

Like a complete orm I'd say

#

But that's too overkill for most discord bots

swift pumice
#

.topic

lament depotBOT
#
**What's one feature you wish more developers had in their bots?**

Suggest more topics here!

slate swan
#

that would be a pain

swift pumice
slate swan
# lament depot

A help command which don't ask you to go on their website 💀

slate swan
# lament depot

buttons for better ratelimits and slash commands only so prefix clashing/collisions dont happen

#

better handling as well lmao

swift pumice
#

tbh i dont like slash commands

#

idk why

slate swan
#

^ Such a pain to use arrow keys to navigate b/w commands (especially when you don't have them)

swift pumice
#

.topic

lament depotBOT
#
**What commands/features are you proud of making?**

Suggest more topics here!

swift pumice
#

capybara command

slate swan
#

W

swift pumice
#

like that sends a random img of a capybara

slate swan
#

A button based calculator which (almost) works

swift pumice
#

.topic

lament depotBOT
#
**Do you think there's a way in which Discord could handle bots better?**

Suggest more topics here!

swift pumice
#

no

left vector
#

will this work?

terse coyote
#

how to do time like that?

cold tide
#

Anyone know how i send a message in every channel to grab users attention??

#

Would but helpful for my server

terse coyote
#

!d discord.Guild.fetch_channels

unkempt canyonBOT
#

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

Retrieves all [`abc.GuildChannel`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.GuildChannel "discord.abc.GuildChannel") that the guild has.

Note

This method is an API call. For general usage, consider [`channels`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.channels "discord.Guild.channels") instead.

New in version 1.2.
cold tide
#

Than the await function??

terse coyote
#

yes

cold tide
#

And that will send a message in all channels??

#

@terse coyote

cold tide
#

So how would i do that??

terse coyote
#

that get all channels in guild

cold tide
#

Can you send a example here??

terse coyote
#

hm

slate swan
#

Wait, why would you want to send a message to every channel?

#

How do we know your not going to put some malicious intent behind this message?

cold tide
#

To grab my users attention and make sure my bots moderation works...

#

thats all just why.

slate swan
#

Then use the everyone tag.

#

You can do that yourself.

slate swan
cold tide
#

im so dumb 😭😭😭

#

ight ty

slate swan
#

maybe he should be banned

#

too sus with all these questions

hardy yoke
#

does anyone know how I can get all of my users credit card details it's for my mod bot

slate swan
left vector
#
async def on_message(msg):
    if any(word in msg.content for word in code):
        await ctx.send('Correct!', delete_after=15)
        member = msg.author
        role = get(member.guild.roles, name="NPC")
        await member.add_roles(role)
        await ctx.send('Gave Role', delete_after=15)
        await ctx.send('Removing Role In 5min', delete_after=60)
        await asyncio.sleep(3)
        await ctx.send('Removing Role In 1min', delete_after=15)
        await asyncio.sleep(3)
        await member.remove_roles(role)

ctx isnt defined
please help me its 3 am

terse coyote
left vector
slate swan
#

<@&831776746206265384> @cold tide keeps asking for help with an obvious nuke bot, the whole conversation is againsts tos and should end already.

slate swan
left vector
hardy yoke
left vector
slate swan
terse coyote
left vector
#

kick boot

slate swan
#

.topic

lament depotBOT
#
**What unique features does your bot contain, if any?**

Suggest more topics here!

left vector
slate swan
slate swan
#

use that to send the message

terse coyote
#

how to do time like that?

slate swan
#

!d discord.Message

unkempt canyonBOT
#

class discord.Message```
Represents a message from Discord.

x == y Checks if two messages are equal.

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

hash(x) Returns the message’s hash.
slate swan
left vector
#

AHHHHHHHHHHHH I CANTTT ITS REACTING TO ITS SELF AND ITS GIVING ITS ROLLE TO Its sELf

#

Kill meeeeeeeeeeeeeeeeeeeepuidvkjns;a 😢

#

i cant do this i want to sleep

cold tide
#

🚫

vocal magnet
slate swan
#

I got there user id if needed?

terse coyote
vocal magnet
slate swan
#

and logs are a thing lol

slate swan
terse coyote
slate swan
slate swan
cold tide
#

await ctx.guild.create_text_channel(name="General") throwing indent errors even thought its indented

slate swan
cold tide
#

Okay

#

@bot.command() @commands.has_role("mod") async def backup_command(ctx): await ctx.guild.create_text_channel(name="general")

#

Throwing errors but idk why

left vector
#
@bot.listen()
async def on_message(msg):
    if msg.author.id == 929946521133264938:
        return
    elif any(word in msg.content for word in code):
        await msg.channel.send('Correct!', delete_after=15)
        member = msg.author
        role = get(member.guild.roles, name="NPC")
        await member.add_roles(role)
        await msg.channel.send('Gave Role', delete_after=15)
        await msg.channel.send('Removing Role In 5min', delete_after=60)
        await msg.channel.send('Removing Role In 1min', delete_after=15)
        await member.remove_roles(role)

i.. so so close please just teach me
how do i make the bot add the role to the user and not the bot

#

FRICK IT im making it a fixed user

slate swan
left vector
#

very more ez but i still dont know how to do that

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.

left vector
cold tide
#

@slate swan it was the bot.run(token) that was out of ident ty tho

slate swan
#

Np

terse coyote
left vector
#

thats it

#

its 3:20 am

#

please
how do i make bot add role to a user throughh id

slate swan
left vector
slate swan
slate swan
left vector
slate swan
#

you would fetch the member

#

!d discord.Guild.fetch_member

unkempt canyonBOT
#

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

Retrieves a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") from a guild ID, and a member ID.

Note

This method is an API call. If you have [`Intents.members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.members "discord.Intents.members") and member cache enabled, consider [`get_member()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.get_member "discord.Guild.get_member") instead.

Changed in version 2.0: `member_id` parameter is now positional-only.
left vector
#

member = message.912726263427383296
var = discord.utils.get(message.guild.roles, name = "role name")
member.add_role(var)
boom this would work first time right????????

slate swan
#

Hi, what's the best free way to host your bot? (Not self hosting.)

#

Fields

odd mango
#

i am trying to paginate send_cog_help, i got the buttons and all in place but i am getting troubled to create pages. here's what i do

    async def send_cog_help(self, cog):
        if len(subcommands := cog.get_commands()) == 0:
            return await self.send_empty_cog_help(cog)
        filtered = await self.filter_commands(subcommands, sort=True)
        formatter = await HelpPageSource(
            filtered, self, f"{cog.qualified_name}", cog_check=True
        ).format_page(self, filtered, 1, 1)
        await Support().paginate([formatter], self.context)```how can i create pages
formatter is supposed to be a list of embeds here
i get all 27 commands in 1 page
expecting 6 per page
slate swan
#

Yeah

glad cradle
#

I think it's an embed_field but the second field doesn't have a title, maybe it's an invisible title with special char

slate swan
#

Add another field in the same line with title being an invisible character

glad cradle
#

... == > ...

slate swan
#

** ** or \u200b

#

There are more with different dimensions just in case

odd mango
#

i am trying to paginate send_cog_help, i got the buttons and all in place but i am getting troubled to create pages. here's what i do

    async def send_cog_help(self, cog):
        if len(subcommands := cog.get_commands()) == 0:
            return await self.send_empty_cog_help(cog)
        filtered = await self.filter_commands(subcommands, sort=True)
        formatter = await HelpPageSource(
            filtered, self, f"{cog.qualified_name}", cog_check=True
        ).format_page(self, filtered, 1, 1)
        await Support().paginate([formatter], self.context)```how can i create pages
formatter is supposed to be a list of embeds here
i get all 27 commands in 1 embed
expecting 6 per embed and list of respective embeds
slate swan
warm tulip
#

Hello

#

How I can download dpy 2.0 on replit website?

#

????

pliant gulch
#

That why it is stated as nullable

warm tulip
#

Pls someone helppp I need 2.0 dpy on replit??? 🫂🫂🫂

#

How I can download dpy 2.0 on replit website

slate swan
unkempt canyonBOT
#

discord/types/channel.py lines 47 to 49

class _BaseChannel(TypedDict):
    id: Snowflake
    name: str```
`discord/types/channel.py` line 129
```py
class DMChannel(_BaseChannel):```
pliant gulch
#

Yes it isn't typehinted correctly to the API

#

But, that's not to say they SHOULD typehint it correctly here

warm tulip
#

How I can download dpy 2.0 on replit website?

pliant gulch
#

Because it is out of scope for discord.py to even facilitate bots making group dms (which they can through Oauth2)

warm tulip
#

joe_maverick How I can download dpy 2.0 on replit website?

pliant gulch
slate swan
#

Yeah that's right.. I think it should be fixed though just for the sake of consistency.. pithink

warm tulip
#

How I can download dpy 2.0 on replit website?

slate swan
#

Please don't spam.. If anyone will know they'll just answer

warm tulip
#

ducky_drawing :/

#

Ahhhh

pliant gulch
#

Consistency is nice but there is really no need for it to be fixed and it would just make typing in discord.py even worse

#

And discord.py already has enough type issues like, literally almost everything being generic

#

So when your using strict type checking with subclassing it gets suppper annoying with Unknown type

slate swan
#

Yeah it's never going to happen anyways after all

#

I'm very new to type-hinting so I'm not gonna comment more on it lol

glad cradle
unkempt canyonBOT
#

README.rst lines 49 to 53

To install the development version, do the following:

.. code:: sh

    $ git clone https://github.com/Rapptz/discord.py```
novel prairie
#

File "main.py", line 56
await ctx.message.reply(file=file, embed=embed)
^
IndentationError: unexpected indent

#

how can i fix this?

white aurora
#

it is saying you don't need the indentation there

novel prairie
#

So what do i change?

humble fog
#

i wanna make a discord bot that can either read my minecraft server cmd logging or one that connects to the rcon of the server

terse coyote
#

is it possible to get the time of a song a user is muting in Spotify?

humble fog
terse coyote
humble fog
#

yes its possible

#

thats built in with the music plugin

#

its on github

slate swan
#

how can i use the git clone command?

terse coyote
hardy yoke
# novel prairie So what do i change?

your code is hard to read like this, put it in a codeblock

place py or python in the first line and surround the text on either side with three backticks/backquotes (```) (see https://i.imgur.com/NmHjGsq.png).

The text is then coloured appropriately, making it easier to distinguish between different elements of your code.

print("Hello world!")```

The code you pasted is indented weirdly across the board, nothing is inside the function?
hardy yoke
slate swan
#

how do i install git so i can clone a link?

terse coyote
hardy yoke
novel prairie
#
@bot.command()
async def zrl_link(ctx):
 embed=discord.Embed 
file = discord. File("", filename="zrl_community_made_by_zahos.png")

embed.set_image(url="""https://cdn.discordapp.com/attachments/962040981589463183/1000331877695107143/zrl_community_made_by_zahos.png""")(title=">>> ZRL Server Invite Link ",description="",
color=000000)
 await ctx.message.reply(file=file, embed=embed)```
hardy yoke
#

remove the whitespace after py

#

but yes, none of that code is indented inside the function

#

these need to be inside the function, currently they are not which is why python is tripping up at await ctx which is indented

novel prairie
#

Idk how to indent this im mew to dev

hardy yoke
#

I'd strongly suggest reading up a bit more on python before going forward, indentation is super basic and important. You're going to trip up a lot if you're struggling with that

terse coyote
#

module 'discord' has no attribute 'ui'

slate swan
#

how can I assign a role by id

terse coyote
#

this?

sick birch
sick birch
terse coyote
#

2.0.0 very difficult for me

slate swan
#

Hi, i made dank memer bot

hardy yoke
dull terrace
#

How do you make something that already exists 7739monkathink

slate swan
#

How can I send a base64 encoded image to channel?

gloomy plinth
#

does anyone know why images render outside embeds from time to time?

#

for example

#

i used set_image for this btw

mighty anchor
#

Hey so I have no idea how to make discord bot send webhooks with certain values to a certain channel.

Basically I want a command called +shout <arg>

and the discord bot use that command and send a webhook to a certain channel and the content of the webhook will be arg

i also want to change the values of the webhook like webhook username and pfp url.

if u can guide or help me achieve this i would really appreciate it but i have no idea where to start any help is appreciated thanks in advance

the output would look like this
https://cdn.discordapp.com/attachments/979896670554828840/1000542852348137502/unknown.png

how the webhook name and profile picture is the same as the ctx.author own

sage root
#

i'm new to python, pls help

#

what does this error mean:
if any(str(message.content).lower) == "slay"():
TypeError: 'builtin_function_or_method' object is not iterable

slate swan
#

!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.
white aurora
#

"slay"(): the brackets are used to indicate a function

slate swan
#

👁️ 👁️

sage root
#

I figured it out

slate swan
#

calling a string object🥴

sage root
#

SHHH I WAS DESPERATE 😭

white aurora
#

lol jam_cavedude

dull terrace
#

What... I didn't even know you could call a string object, what does it do?

#

Oh it was a mistake, that makes more sense 7739monkathink

mighty anchor
#

Hey so I have no idea how to make discord bot send webhooks with certain values to a certain channel.

Basically I want a command called +shout <arg>

and the discord bot use that command and send a webhook to a certain channel and the content of the webhook will be arg

i also want to change the values of the webhook like webhook username and pfp url.

if u can guide or help me achieve this i would really appreciate it but i have no idea where to start any help is appreciated thanks in advance

the output would look like this
https://cdn.discordapp.com/attachments/979896670554828840/1000542852348137502/unknown.png

how the webhook name and profile picture is the same as the ctx.author own

sage root
#

someone help me:

#

if msg.startswith("/masspingallowed"):
value = msg.split("/masspingallowed ",1)[1]

if value.lower() == "true":
  db["masspingallowed"] = True
  await message.channel.send("Mass ping is now allowed for the bot.")

else:
  db["masspingallowed"] = False
  await message.channel.send("Mass ping is now disabled for the bot.")

i made a mass ping command but i want to be able to turn it on and off. it returns this error when i tr it:
File "main.py", line 141, in on_message
user = msg.split("/massping ",1)[1]
IndexError: list index out of range

Please help

#

i figured it out
i had a command called
/massping
and my cmd to allow it was
/masspingallowed
and when i renamed it to /spampingallwoed
*allwoed
*allowed
it worked

slate swan
#

print ("whats your pn?")

hazy oxide
#

try to comment all your command

robust fulcrum
hazy oxide
#

ik, just try to comment all your normal commands

#

and see if the errors still appear

robust fulcrum
#

It shows the slash comamnd called ping

#

But i have not made it

rare jewel
#

is there a way to make it return the full traceback of the error instead of just sending a little part of it?

@bot.event
async def on_command_error(ctx, error):
    await ctx.send(f"An error occured: {str(error)}")```
brazen raft
#

You could use traceback.format_exception

from traceback import format_exception

@bot.event
async def on_command_error(ctx, error):
    await ctx.send("An error occurred:\n" + "".join(format_exception(error.__class__, error, error.__traceback__)))

error.__class__ is like type(error)

rare jewel
#

ohh okay ty

rare jewel
brazen raft
#

No because you have "" in the {} but it's also the quotes of the f-string

rare jewel
brazen raft
#

Use another type of quotes than "", yes

rare jewel
#

okay gotcha

#

ty

slate swan
#

help

#

im getting an error while running my bot, it was a html code, i checked it and it says that i am banned from accessing discord.com

slate swan
# slate swan

you've been banned by discord api 'cause you crossed ratelimits
run kill 1 in the shell and it'll reset the ip

rare jewel
slate swan
#

@slate swan yo need another help

hardy yoke
#

just ask

slate swan
#

politer to ask to ask but ask without asking cz yes

paper sluice
slate swan
unkempt canyonBOT
#

@slate swan :white_check_mark: Your 3.11 eval job has completed with return code 0.

Ryuga's uwuness kills us all
hardy yoke
#

til 3.11 is out

slate swan
#

beta version

brazen raft
slate swan
#

it'll release sometime in october else december

robust fulcrum
slate swan
#

@slate swan how do i add a reaction to a bot's msg?

#

i mean, the bot should add reaction to its own embed msg and then will do some stuff

robust fulcrum
#

Store message sent message in varibale

#

For ex

mes1 = await ctx.send("hello")
await mes1.add_reaction("❤️")
shrewd apex
slate swan
#

thanks

shrewd apex
#

is the command showing up in ur server? did u sync?

robust fulcrum
#

But it showing

slate swan
#

;-;

#

ok i added the reaction

#

now how do i make the bot respond to the reaction

robust fulcrum
#

Use bot.wait_for

slate swan
#

will it loop if i add normal if statement

robust fulcrum
#

I can give example

slate swan
slate swan
robust fulcrum
#

You want that it waits for user to add reaction?

slate swan
slate swan
robust fulcrum
#
react = bot.wait_for("raw_reaction_add", check=lambda p: p.message_id == message.id, timeout =20)
if react.emoji.name == "put any emoji here":
    #do stuff here
#

Understood?

slate swan
robust fulcrum
#

Ok

#

Can you help me ols

slate swan
#

timeout = 20 means the bot wont respond if 20 seconds are passed right?

robust fulcrum
#

Ye

slate swan
robust fulcrum
#

Ok

robust fulcrum
swift pumice
#

can bots timeout?

#

like a user

#

timeout a user

white aurora
#

a bot timing out a user?

slate swan
#

you can timeout a member not a user

swift pumice
#

if thats unique

swift pumice
slate swan
#

no need to be sorry

#

!d discord.Member.timeout

unkempt canyonBOT
#

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

Applies a time out to a member until the specified date time or for the given [`datetime.timedelta`](https://docs.python.org/3/library/datetime.html#datetime.timedelta "(in Python v3.10)").

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

This raises the same exceptions as [`edit()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member.edit "discord.Member.edit").
white aurora
#

all goodie 👍

swift pumice
#

thanks

slate swan
#

👍

white aurora
#

okimi, how long have you been programming for?

eternal fox
#

hi yall can yall gib me ideas on what to add to my bot?

slate swan
eternal fox
white aurora
#

oh wow very impressive 👀

slate swan
#

im nothing like other regulars😅

slate swan
eternal fox
slate swan
#

someone has done it but im not sure who, iirc it was scoopy

slate swan
white aurora
slate swan
slate swan
slate swan
#

:<

#

wot to use

#

ive seen the code from a yt tutorial and its bad

slate swan
slate swan
slate swan
slate swan
white aurora
#

lol

swift pumice
slate swan
swift pumice
white aurora
#

if emoji.name==' '

#

await ctx.send()

slate swan
# slate swan yes
async def a():
    ...

here a is a function instance as its just being declared. when you call it

a # function obj
a() # coroutine obj
await a() # scheduling a coroutine and returning the caller when done
white aurora
#

!d coroutine

unkempt canyonBOT
#

Coroutines are a more generalized form of subroutines. Subroutines are entered at one point and exited at another point. Coroutines can be entered, exited, and resumed at many different points. They can be implemented with the async def statement. See also PEP 492.

slate swan
#

This series of videos introduces AsyncIO to Python programmers who haven't used it yet. The first episode is a high-level view on the async ecosystem. We cover:

  • why you'd want to use asynchronous code at all;
  • how latency drives the user experience;
  • what the difference between concurrency and parallelism is;
  • some of the problems you can...
▶ Play video
swift pumice
#

when is the time to learn databases

slate swan
#

learn them when you need them and when you feel ready

swift pumice
#

thanks

slate swan
#

and i ment sql as an sql based db lmao

white aurora
#

sql is fun to learn

slate swan
#

it is, its quite easy to learn and handy non the less

slate swan
white aurora
#

runestone academy is one of my favourite websites

slate swan
robust fulcrum
slate swan
white aurora
#

discord.app_command.tree

robust fulcrum
#

I not even made a slash comamnd

#

It still showing the comamnd

slate swan
#

is that your bot?

#

;-;

white aurora
#

probably made the tree of slash commands

slate swan
robust fulcrum
white aurora
#

right haha

robust fulcrum
#

I never made a slash comamnd but still showing the command

slate swan
#

did you made one before?

robust fulcrum
#

No

#

I not like slash comamnd

slate swan
#

it kinda looks like a collision of states but im probably wrong, can you show your code?

#

BRO

#

have you tried disconnecting your bot from the gateway?

#

hLEP

white aurora
#

👀

slate swan
#

didnt derrick help you?pithink

#

how do i know if a member has added reaction to an embed

#

sent by bot

white aurora
#

async def on_reaction_add(reaction, user)

#

maybe?

slate swan
#

;-;

#

you can check the reactions of the message or detect a gateway event

swift pumice
#

opinion on making your own bot open source? like that everyone can see ur bots code

slate swan
white aurora
#

potential employers :D

swift pumice
#

oh okay

slate swan
#

and making your bot open source lets users implement commands that the community might want!

slate swan
robust fulcrum
slate swan
#

this works?

#

no ;-;;;;;;;;

#

you need to register the event lol

slate swan
#

why is it soo complicated

#

i just want the bot to send another meme when someone adds a reaction

swift pumice
#

😔

slate swan
#

Discord.py is an advanced lib that uses OOP and async python, its not hard you just need to be experienced in python, you can always continue but it will be more easy for you if you learn OOP and async programming

#

¯\_(ツ)_/¯

swift pumice
#

.topic

lament depotBOT
#
**What unique features does your bot contain, if any?**

Suggest more topics here!

swift pumice
#

capyfact and capybara

left vector
#

i cant do this

#

i need to make a random number every time i run this function

#

and that random number needs to be used by another out side function

#

i want to make it run a function in side another function

#

but i cant do that cuz idk

slate swan
#

you can always use that random number and return it on each call

left vector
#

wdym return it on each call?

slate swan
#

when calling the function just return thst random number, do whatever with that number in the function and return that same number

lyric apex
slate swan
#

it avoids the usage of the global keyword

left vector
#

now this is beond my understanding

#

alright ima look it up on google

#

for examples

swift pumice
#

💀

slate swan
#

!e

def a():
    return __import__("random").randint(1, 10)
print(a())
print(a())
unkempt canyonBOT
#

@slate swan :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | 1
002 | 7
left vector
#

return statement?????????

slate swan
#

!global

unkempt canyonBOT
#

When adding functions or classes to a program, it can be tempting to reference inaccessible variables by declaring them as global. Doing this can result in code that is harder to read, debug and test. Instead of using globals, pass variables or objects as parameters and receive return values.

Instead of writing

def update_score():
    global score, roll
    score = score + roll
update_score()

do this instead

def update_score(score, roll):
    return score + roll
score = update_score(score, roll)

For in-depth explanations on why global variables are bad news in a variety of situations, see this Stack Overflow answer.

left vector
#

ohh

#

wait.. what

#
@bot.command()
async def email(ctx):
    await ctx.message.delete()
    await ctx.send("Sending Email...", delete_after=15)
    """"Random Number"""
    range_start = 10**(4-1)
    range_end = (10**4)-1
    numb = randint(range_start, range_end)
    body = 'Your Code: ' + str(numb)
    code = str(numb)
    await asyncio.sleep(2)
    await ctx.send("Email Sent", delete_after=15)
score = whAT the fuck i dont undertAndT This


#

i just need it to carry on code and numb

slate swan
#

why would you need the random number outside of the local scope and why are you using string concentation?

#

YO NEED Help

left vector
#
async def email(ctx):
    await ctx.message.delete()
    await ctx.send("Sending Email...", delete_after=15)
    """"Random Number"""
    global numb, code
    range_start = 10**(4-1)
    range_end = (10**4)-1
    numb = randint(range_start, range_end)
    body = 'Your Code: ' + str(numb)
    code = str(numb)
    """email function"""
    em = EmailMessage()
    em['From'] = email_sender
    em['To'] = email_receiver
    em['Subject'] = 'Code'
    em.set_content(body)
    context = ssl.create_default_context()
    with smtplib.SMTP_SSL('smtp.gmail.com', 465, context=context) as smtp:
        smtp.login(email_sender, email_password)
        smtp.sendmail(email_sender, email_receiver, em.as_string())
    """email function"""
    await asyncio.sleep(2)
    await ctx.send("Email Sent", delete_after=15)```
sadly this didnt work
#

keeps saying that code isnt defined

robust fulcrum
slate swan
#

this command takes memes from a subreddit and sends it, it also makes sures that the meme is not a video.
(if its a video then it doesnt load in an embed)
but it is posting same memes after some times, how do i refresh it or get new ones?

left vector
#
async def email(ctx):
    await ctx.message.delete()
    range_start = 10**(4 - 1)
    range_end = (10**4) - 1
    numb = randint(range_start, range_end)
    code = str(numb)
    return code
@bot.listen(code)
async def on_message(msg):
    await msg.channel.send('code', delete_after=15)```
does anybody know how to fix this
hardy yoke
#

you haven't explained what neds fixing

left vector
#

im trying to call code in another function

#

but i cant

#

and im trying to recreate this:

    test = 11
    return test

def thing2(test):
    if test == 11:
        print(hi)

value = thing()
thing2(value)
hardy yoke
#

you've passed code to the event decorator bot.listen

left vector
#

where.. should i pass it

hardy yoke
#

what's your end goal

#

do you want it posted in a discord channel

left vector
#

wait im going to try to send it all here

#
@bot.command()
async def email(ctx):
    await ctx.message.delete()
    """Random Number"""
    range_start = 10**(4 - 1)
    range_end = (10**4) - 1
    numb = randint(range_start, range_end)
    code = str(numb)
    """email function"""
    return code

@bot.listen()
async def on_message(msg, code):
    if msg.author.id == 929946521133264938:
        return
    elif any(word in msg.content for word in code):
        await msg.channel.send('Correct!', delete_after=15)
        member = msg.author
        role = get(member.guild.roles, name="NPC")
        await member.add_roles(role)
        await msg.channel.send('Gave Role', delete_after=15)
        await msg.channel.send('Removing Role In 5min', delete_after=60)
        await asyncio.sleep(240)
        await msg.channel.send('Removing Role In 1min', delete_after=15)
        await asyncio.sleep(60)
        await member.remove_roles(role)
        await msg.channel.send('Removed Role Please Redo +email To Add Role Again.',delete_after=15)```
#

im making a random number in the first function

#

and the random number needs to update when i run the first function

#

and well basicaly i need to find a way to get the variable code out of the first function

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!

hardy yoke
left vector
left vector
# hardy yoke using command functions to return values is unusual. It won't work the way you w...

welp time for option 2

is there any way for me to run a function inside another function like this for example:

def number():
    range_start = 10**(4 - 1)
    range_end = (10**4) - 1
    numb = randint(range_start, range_end)
    code = str(numb)

@bot.command()
async def email(ctx):
    await ctx.message.delete()
    number()
@bot.listen()
async def on_message(msg):
    await msg.channel.send(code, delete_after=15)
hardy yoke
#

it's not returning anything but yes

also if you want a variable that can be used across functions, and be able to change its value, the bot variable example is a good idea.

left vector
#

i could just replace listen with wait for and put it all in one function

#

but i have no idea how to do that and it would take 3 hours to do that

hardy yoke
#

you aren't returning any value in this function
and even if it did, you aren't actually doing anything with it
but you could store the value of code in a bot variable and be able to use it in on_message

left vector
hardy yoke
#

Yes

left vector
#

alright very nice

#

now.. how tf do i do that

#

man i have no idea how this works

#

aww hell naw

#

what is this

vocal snow
#

Are you referring to the typehint, the keyword-only parameter notation or the docstring

left vector
#
async def email(ctx, *, number: str):
    await ctx.message.delete()
    range_start = 10**(4 - 1)
    range_end = (10**4) - 1
    numb = randint(range_start, range_end)
    code = str(numb)
    code = number
@bot.listen()
async def on_message(msg):
    if msg.author.id == 929946521133264938:
        return
    elif any(word in msg.content for word in number):
        await msg.channel.send('Correct!', delete_after=15)```
#

will that work?

#

to make it a bot variable

hardy yoke
#

no

#

You're looking at the wrong part

#

do you want a user to use a bot command called email and enter a string?

#

to be honest, this seems like a case of 'slow down and learn more python before progressing'

left vector
#

I KNOW PYTHON

#

its just that discord bot is so confusing

#

for me

hybrid garnet
#

Hi I don’t really know if this is the place to ask but, I have been trying to make my discord bot attain a status on the music it’s currently playing in the voice channel like the example below, how would I get this to happen?

hardy yoke
left vector
#

ok maybe i dont know what classes are

#

time to look it up

vocal snow
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...
hardy yoke
#

it's ok not being an ass it's just

#

every step of the way you're going to hit a hurdle

left vector
hardy yoke
#

getting up to speed on classes will definitely help

left vector
#

ohhh its abike

vocal snow
#

Corey Schafer has a good OOP tutorial on youtube

hardy yoke
#

is print('An error has occurred!') being called?

#

well that's why then

#

request isn't being defined because it's hitting an error

#

subre.ddit < is it this perhaps

#

idk you're eating the error that's causing it

#
except Exception as e:
  print(e)```

do this instead of that other print statement
#

but my brief reading of that code

#

makes me think it's because you wrote subre.ddit

#

instead of subreddit

#

ctrl+f

#

you didn't know what was causing it because your Except is making the actual error disappear

slate swan
#

It sends memes from r/meme ?

#

Using praw?

hardy yoke
#

you're just accessing reddit's json, not using praw

#

it would appear that close isn't defined

#

is it in your code anywhere

#

are you copying this

#

I see

#

look for a def code somewhere in the place you're copying

#

it's hard to say without seeing the full thing but in general copy/pasting code will lead to issues unless you fully understand every part of it

unkempt canyonBOT
#

Hey @slate swan!

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

hardy yoke
#

there is no close function there

#

I'm assuming that code is missing something, I'm guessing Close() is meant to have some buttons in it or something

#

you could make that yourself, look up how to make buttons in your library

left vector
#
words = ['@everyone', '@here', 'test', 'Test']
@client.event
async def on_message(message):
    if any(word in msg.content for word in words):
        await message.delete()```
does anybody know why this does not delete all messages that has the words in words
(please ping me)
odd mango
#

how can i add hybrid commands to jishaku cog

left vector
#
words = ['@everyone', '@here', 'test', 'Test']
@client.event
async def on_message(message):
    if any(word in message.content for word in words):
        await message.delete()

welp i tried fixing it but it still does not delete the message if it has the word in words

vagrant brook
#

well check if you have message intents on

#

in both dev portal and code

odd mango
#

usually it is just a decorator py @commands.hybrid_command(name="xyz")which you replace forpy @commands.command(name="xyz")

#

but here there's no commands.command

left vector
odd mango
#

nah just turn all the three on lol

left vector
#

alright i fixed it all i had to do was use
@bot.listen()
instead of
@client.event

unkempt canyonBOT
#

Hey @slate swan!

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

slate swan
#

@slate swan can you share the meme code

#

want to see button thing

#

The next meme button

#

you've made a group of slash commands usinf the random name and that is overwriting the random package import name

#

😩

#

inport random using a different name or chnge your slash group name

#

import random as rdm could be a fix and you do rdm.choice

dusk quest
#

**async def on_member_join **and ** on_member_join ** not returning anything with **await channel.send(embed=embed) **thoughts? They should be sending messages to my text channels but they are not? Not running into any error either . . .

elder dawn
#

Trying to play with cogs:

import os,random,discord,discord.utils,asyncio,datetime,time,asyncio
from discord.ext import commands
from discord.utils import get

class roomba(commands.Cog):
        def __init__(self, bot):
            self.bot = bot
            bot = commands.Bot(command_prefix='.')
            channel = ctx.message.author.voice.channel
            
        @commands.guild_only()
        @commands.command(pass_context = True)
        @commands.has_role('Herra')
        async def clear(self, ctx, amount=None):
            if amount is None:
                await ctx.channel.purge(limit=50)
            elif amount == "all":
                await ctx.channel.purge()
            else:
                await ctx.channel.purge(limit=int(amount))        
        
def setup(bot):
    bot.add_cog(roomba(bot))

In the name of holy simplicity: Why this does not work?
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.roomba' raised an error: NameError: name 'ctx' is not defined

vocal snow
#

because it isn't defined

#

in the _init_

elder dawn
#

Yes but when it is: discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.roomba' raised an error: TypeError: __init__() missing 1 required positional argument: 'ctx'

vocal snow
#

then you need to pass ctx when you instantiate the class

#

which doesnt really make sense

elder dawn
#

🤪

vocal snow
#

im not sure why you want to define channel in the init anyways...

slate swan
#

defining bot again too, next level shit

dusk quest
elder dawn
#

It is part of longer script, I think I had it for reason. now splitting it to cogs and it causes freakign headache...

slate swan
#

My discord bot got some weird long JavaScript / HTML error even tho i made it in python, what's the problem? (My bot isn't starting)

vocal snow
#

If not, that's the reason for the headache

slate swan
elder dawn
slate swan
#

do kill 1 in the shell cause replit

elder dawn
#
import os,random,discord,discord.utils,asyncio,datetime,time,asyncio
from discord.ext import commands
from discord.utils import get
from discord import FFmpegPCMAudio

class clips(commands.Cog):
        def __init__(self, bot):
            self.bot = bot
            bot = commands.Bot(command_prefix='.')
        
        @commands.guild_only()
        
        #Trynda
        @commands.command()
        async def trynda(self, ctx):
            user = ctx.message.author
            voice = get(self.bot.voice_clients, guild=ctx.guild)
            channel = ctx.message.author.voice.channel
            if voice and voice.is_connected:
                await voice.move_to(channel)
            else:
                vc = await channel.connect()
                time.sleep(.5)
                path = "/home/pi/judge_dredd/cogs/mp3/imemunaa.mp3"
                vc.play(discord.FFmpegOpusAudio(path), after=lambda e: print('done', e))
                while vc.is_playing():
                    pass
                await vc.disconnect()
def setup(bot):
    bot.add_cog(clips(bot))
``` for some reason this works just fine
vocal snow
#

but TL;DR: the _init_ is called when the class is created, which you're doing in setup (roomba(bot))

vocal snow
#

and the library passes ctx to it when the command is invoked

slate swan
dusk quest
dusk quest
vocal snow
dusk quest
vocal snow
#

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

jagged estuary
slate swan
#

doesnt make a difference

#

that would just enable presence and message_content intent if 2.0

#

and resource wasting

#

since that would enable unnecessary events to be received

dusk quest
vocal snow
#

you should remove that

timber widget
#

Hello

timber widget
vocal snow
#

I don't know what disomegle is sorry

slate swan
#

how do i make it so that when i click one button in that class, it disables ALL the buttons in that class?

terse coyote
#

can i get a time on which the song plays in Spotify?

slate swan
robust fulcrum
#

Lol

#

Download the Omegle and use

slate swan
robust fulcrum
#

Is it possible to make a discord bot dashboard in django?

slate swan
#

yes

terse coyote
#

can i get a time on which the song plays in Spotify?

slate swan
timber widget
#

Can you tell me how to make a bot like disomegle?

timber widget
# vocal snow I don't know what disomegle is sorry

How to make a bot like when you react to a embed with button then bot opens a new channel

Like two buttons
One is two-on-two chat and second is group chat

So whenever user press those buttons a random channel will get open and how to set a limit so not more than 2 users enter in channel when

terse coyote
# slate swan pycord

You can accomplish this by setting button.disabled to True in your button's callback. Then, you also would need to edit your original message to reflect this change.

slate swan
#

Ayo, can someone tell me how I can put embeds in their own file so that I only have to load them into my main file?

dusk quest
#

new problems await channel.send(embed=embed)
AttributeError: 'NoneType' object has no attribute 'send'
😅

slate swan
dusk quest
#

this was working just a moment ago lol

slate swan
#

channel is None

slate swan
#

like i import it to a var and await them?

#

you don't need to await embeds, do you?

slate swan
slate swan
dusk quest
slate swan
dusk quest
slate swan
#

nope

dusk quest
#

still not recognizing when someone joins the server tho 😦

slate swan
# slate swan can i see the code, it means that you already responded to the interaction once
   super().__init__(timeout=None)
  @discord.ui.button(row=0, label='Seller', style=discord.ButtonStyle.blurple, custom_id="trade_seller", disabled=False)
  async def buyer_callback2(self, button, interaction):
    await interaction.response.send_message(content=f"You have been successfully labelled as the **Seller**!", ephemeral=True)

    db = mysql.connector.connect(
      host="",
      user="",
      passwd="",
      database="")
    mycursor = db.cursor()

    mycursor.execute(f"UPDATE Auto set SellerID = '{interaction.user.id}' WHERE channelID = '{interaction.channel.id}'")
    db.commit()

    embed=discord.Embed(title="Who are you dealing with?",description="Please reply with your traders **Developer ID**",color=0x17A589)
    await interaction.channel.send(embed=embed)

    for child in self.children:
      if isinstance(child, discord.ui.Button):
          child.disabled = True
        # make sure to update the message with the new buttons
    await interaction.response.edit_message(view=self)

        # Prevents on_timeout from being triggered after the buttons are disabled
    self.stop()```
slate swan
# slate swan nope
my_embed.py

import discord

my_embed = discord.Embed(...)
``` ```py
# main.py

from my_file import my_embed

# inside command 
    await ctx.send(embed=my_embed)
dusk quest
#

i like embeds

slate swan
dusk quest
#

they are pretty

slate swan
slate swan
dusk quest
slate swan
#

File "main.py", line 47
@client.command()
^
IndentationError: unexpected unindent

#

!indents

unkempt canyonBOT
#

Indentation

Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.

Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.

Example

def foo():
    bar = 'baz'  # indented one level
    if bar == 'baz':
        print('ham')  # indented two levels
    return bar  # indented one level

The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.

Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines

More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation

eternal fox
#

i can try to help :(

#

i mean :)

dusk quest
eternal fox
#

Okioki i'll take a loik

#

*look

slate swan
dusk quest
#

i have fixed some other issues with it since first post but still does not do anything with on_member_join

slate swan
slate swan
#

all get_* methods check cache and can return None

eternal fox
#

try to use fetch_channel instead

slate swan
#

use a getch

#

Client.get_channel(...) or await Client.fetch_channel(...)

eternal fox
#

yees

slate swan
#

thats not getch

#

?

#

if you act like a weirdo, im not talking to you

paper sluice
slate swan
#

it would be so much better if they read docs🗿

slate swan
paper sluice
slate swan
#

all get methods scream the return type😭

#

most libs do that

#
class View(discord.ui.View): 
    @discord.ui.button(label="Next Meme", style=discord.ButtonStyle.primary, emoji="⏭")

  
@client.command()
async def meme(ctx):
  async with ctx.typing():
    subreddit = reddit.subreddit("indiandankmemes")
    all_subs = []
    hot = subreddit.hot()
    for submission in hot:
        all_subs.append(submission)
        random_sub = random.choice(all_subs)
        url = random_sub.url
        name = random_sub.title
        author = random_sub.author
        upvotes = random_sub.score
        if random_sub.is_reddit_media_domain and not random_sub.is_video:
            em = discord.Embed(title = name)
            em.set_image(url = url)
            em.set_footer(text= f'''from r/indiandankmemes by {author} | {upvotes} upvotes''')
    await ctx.send(embed= em , view=View())
slate swan
slate swan
slate swan
#

async def button_callback(self, button, interaction):
await interaction.response.send_message("You clicked the button!")

dusk quest
#

had someone join my server with the fetch_channel instead, still nothing
if the function was running at all i should atleast get the print statement, instead nothing
im thinking that its not even recognizing the event int the first place

slate swan
#

!intents enable these

unkempt canyonBOT
#

Using intents in discord.py

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

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

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

from discord import Intents
from discord.ext import commands

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

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

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

dusk quest
slate swan
#

he has intents lol

dusk quest
#

i do intentd

slate swan
#

👁️ 👁️

#

where is discord.ui

#

;-;

#

wdym where is it?

#

if its not found you would need 2.0 lol

#

Traceback (most recent call last):
File "main.py", line 4, in <module>
from discord.ui import Buttons
ModuleNotFoundError: No module named 'discord.ui'

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

slate swan
dusk quest
#
print('Hello world!')
#

this makes me happytime

slate swan
#

!e
print('e')

#
class Buttons(discord.ui.View):
    def __init__(self, *, timeout=180):
        super().__init__(timeout=timeout)
    @discord.ui.button(label="Start",style=discord.ButtonStyle.gray)
    async def gray_button(self,button:discord.ui.Button,interaction:discord.Interaction):
        print(interaction.user)

@bot.command()
async def help(ctx):
    embed = discord.Embed(title=f"Auto Middleman", description="Auto MM is a bot which can automate tasks like a normal middleman. You pay the normal fee, and we'll do it for you.", color=0x2f3136)
    embed.add_field(name="How does it work?", value="Like mentioned before, you pay the fee, we only accept BTC payments but please private message Admins for other payment methods. The buyer will then send the amount of what you're selling to a throwaway address generated by us. Then you'd send whatever you're selling to the buyer the details and once the buyer confirms he got it, the money will be sent to a address u specify. Once u confirm u have received the noney, the deal is predicted as completed and the ticket will self destruct.")
    embed.add_field(name="How much is the fee?", value="Nothing more than `0.00013 BTC`")
    embed.add_field(name="How do I start a deal?", value="Simply click the button below and the instructions will be in the ticket you create.")
    await ctx.send(embed=embed)
``` im expecting for it to send the embed but instead it does nothing. nothing prints out in the console when i run btw
dusk quest
#

@client.event
async def on_member_join(member):
  print(f"{member} joined the server!")
  channel = client.get_channel(int(os.environ['WELCOMEMAT']))
  await channel.send(f"{member} has arrived on the coast!")
  #logging new members
  logs = client.fetch_channel(int(os.environ['LOGS']))
  embed = discord.Embed(title=f"{member} has joined the server!")
  await logs.send(embed=embed)

#

this should do something

slate swan
#

and yes you would need git

#

nvm i will use pycord

#

wait

paper sluice
#

you named the slash command group random

#

which overwrites the name of the builtin lib random

slate swan
#
class Buttons(discord.ui.View):
    def __init__(self, *, timeout=180):
        super().__init__(timeout=timeout)
    @discord.ui.button(label="Start",style=discord.ButtonStyle.gray)
    async def gray_button(self,button:discord.ui.Button,interaction:discord.Interaction):
        print(interaction.user)

@bot.command()
async def help(ctx):
    embed = discord.Embed(title=f"Auto Middleman", description="Auto MM is a bot which can automate tasks like a normal middleman. You pay the normal fee, and we'll do it for you.", color=0x2f3136)
    embed.add_field(name="How does it work?", value="Like mentioned before, you pay the fee, we only accept BTC payments but please private message Admins for other payment methods. The buyer will then send the amount of what you're selling to a throwaway address generated by us. Then you'd send whatever you're selling to the buyer the details and once the buyer confirms he got it, the money will be sent to a address u specify. Once u confirm u have received the noney, the deal is predicted as completed and the ticket will self destruct.")
    embed.add_field(name="How much is the fee?", value="Nothing more than `0.00013 BTC`")
    embed.add_field(name="How do I start a deal?", value="Simply click the button below and the instructions will be in the ticket you create.")
    await ctx.send(embed=embed)
``` im expecting for it to send the embed but instead it does nothing. nothing prints out in the console when i run btw
paper sluice
#

you didnt do anything with Buttons

#

you need to make an instance and send it

#

like

view = YourViewClass()
await ctx.send(..., view=view)
slate swan
#

Ah

slate swan
#
import discord
from discord.ext import commands

intents = discord.Intents.default()
bot = commands.Bot(command_prefix='!', description='Auto MM made by xences and floppa', intents=intents)

class Buttons(discord.ui.View):
    def __init__(self, *, timeout=180):
        super().__init__(timeout=timeout)
    @discord.ui.button(label="Start",style=discord.ButtonStyle.gray)
    async def gray_button(self,button:discord.ui.Button,interaction:discord.Interaction):
        print(interaction.user)
        
@bot.event
async def on_ready():
    print('Ready!')

async def help(ctx):
    buttons = Buttons()
    embed = discord.Embed(title=f"Auto Middleman", description="Auto MM is a bot which can automate tasks like a normal middleman. You pay the normal fee, and we'll do it for you.", color=0x2f3136)
    embed.add_field(name="How does it work?", value="Like mentioned before, you pay the fee, we only accept BTC payments but please private message Admins for other payment methods. The buyer will then send the amount of what you're selling to a throwaway address generated by us. Then you'd send whatever you're selling to the buyer the details and once the buyer confirms he got it, the money will be sent to a address u specify. Once u confirm u have received the noney, the deal is predicted as completed and the ticket will self destruct.")
    embed.add_field(name="How much is the fee?", value="Nothing more than `0.00013 BTC`")
    embed.add_field(name="How do I start a deal?", value="Simply click the button below and the instructions will be in the ticket you create.")
    await ctx.send(embed=embed, view=buttons)

bot.run('')
#

@paper sluice

paper sluice
#

you didnt decorate help with bot.command()

lament mesa
#

thats the recommended method

slate swan
#

is it required

lament mesa
#

nope

#

but as far as i know using normal @bot.command() is discouraged for a help command

slate swan
#

how do i subclass it

slate swan
#
import discord
from discord.ext import commands

intents = discord.Intents.default()
bot = commands.Bot(command_prefix='!', description='Auto MM made by xences and floppa', intents=intents)

class Buttons(discord.ui.View):
    def __init__(self, *, timeout=180):
        super().__init__(timeout=timeout)
    @discord.ui.button(label="Start",style=discord.ButtonStyle.gray)
    async def gray_button(self,button:discord.ui.Button,interaction:discord.Interaction):
        print(interaction.user)
        
@bot.event
async def on_ready():
    print('Ready!')
    
@bot.command()
async def baron(ctx):
    buttons = Buttons()
    embed = discord.Embed(title=f"Auto Middleman", description="Auto MM is a bot which can automate tasks like a normal middleman. You pay the normal fee, and we'll do it for you.", color=0x2f3136)
    embed.add_field(name="How does it work?", value="Like mentioned before, you pay the fee, we only accept BTC payments but please private message Admins for other payment methods. The buyer will then send the amount of what you're selling to a throwaway address generated by us. Then you'd send whatever you're selling to the buyer the details and once the buyer confirms he got it, the money will be sent to a address u specify. Once u confirm u have received the noney, the deal is predicted as completed and the ticket will self destruct.")
    embed.add_field(name="How much is the fee?", value="Nothing more than `0.00013 BTC`")
    embed.add_field(name="How do I start a deal?", value="Simply click the button below and the instructions will be in the ticket you create.")
    await ctx.send(embed=embed, view=buttons)

bot.run('xx')
paper sluice
slate swan
#

still doesnt send the embed wehen i run the command

lament mesa
slate swan
paper sluice
slate swan
paper sluice
#

enable message_content intent

slate swan
#
intents = discord.Intents.default()
bot = commands.Bot(command_prefix='!', description='Auto MM made by xences and floppa', intents=intents)
```?
#

its on in the discord developer portal

paper sluice
#

intents.message_content = True
add this

slate swan
#

works now @paper sluice thank u!

#
    print(interaction.user)
AttributeError: 'Button' object has no attribute 'user'
slate swan
#

change the interaction argument to button and the button argument to interaction

thin kelp
#

I want to make a bot that will send a message when a twitch stream started and when the stream went offline

#

What would be the better way to do it than scraping the twitch stream page every couple minutes and checking that way

cloud dawn
#

I mean twitch has an api

#

I'd start there.

timber widget
#

Atleast tell me what it is called when you do a click on button and it opens a channel where two users can only enter once they press the button if more users press it then it makes a new channel for other users but limit is 2 only

timber widget
slate swan
timber widget
# slate swan that's not a disord.py error

Can you please. Tell me. And guide a little. Just a little. I will send you the server where the bot is just guide me a little on how to make it. I didn't me give me the code. I mean guide me a little so I can get a good idea. Plss

#

😔

slate swan
#

mhm im off for now, someone might help you by then else I will but later

shrewd apex
#

convert to rgb before applying filter

dusk quest
#

!intents

unkempt canyonBOT
#

Using intents in discord.py

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

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

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

from discord import Intents
from discord.ext import commands

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

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

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

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

this passes intents to the bot? only on commands? what about @client.event ?

wicked atlas
#

intents are just for the bot to be able to recieve events/data on the gateway

#

client.event can create handlers for these events. the commands module requires message data in order to parse commands.

#

In this case, I asume you mean bot.event

dusk quest
wicked atlas
#

Because above you use bot

#

Or did you just copy that from the embed?

dusk quest
#

im going to test this again

slate swan
#

client = Bot, yes

maiden fable
#

Isn't that the best naming convention?

dusk quest
maiden fable
#

what the

dusk quest
#

did not happen before

maiden fable
#

I never saw that error lol

dusk quest
#

RuntimeWarning: coroutine 'Client.fetch_channel' was never awaited
pass

#

** this **

rain olive
wicked atlas
dusk quest
#
@client.event
async def on_member_join(member):
  print(f"{member} joined the server!")
  channel = client.get_channel(int(os.environ['WELCOMEMAT']))
  await channel.send(f"{member} has arrived on the coast!")
  #logging new members
  logs = client.fetch_channel(int(os.environ['LOGS']))
  embed = discord.Embed(title=f"{member} has joined the server!")
  await logs.send(embed=embed)
wicked atlas
#

fetch_channel needs to be awaited, but that's not where the error is somehow

jagged estuary
#

or logs = client.get

dusk quest
#

using client.get

maiden fable
maiden fable
#

Nice, everyone buying Nitro nowadays cz of the offer

slate swan
#

nitro is overrated

maiden fable
#

Nice, global emojis

slate swan
#
INSERT INTO `nitro_subscription` (user_id, is_active) VALUES (1234567890, true);
```😔
maiden fable
#

Lmao indeed

slate swan
#

@slate swan, I've json files with languages, in there are {}, how do I format them, when I want to get the string?

maiden fable
#

what do u mean by format?

slate swan
#

you mean convert?

#

.format(var)

maiden fable
#

str.format(**json_dict)?

slate swan
#

Some ppl user f"{var}"

#

f strings are betterpithink

maiden fable
#

Not when u gotta unpack dicts

slate swan
slate swan
#

Otherwise it's to much code

#

keyword is just a note

#

eh

#

okay, found it

#

not batters

cold tide
#
async def tiktok(ctx):
  if ctx.channel==1000764912580169778:
    embed=discord.Embed()
    embed=discord.Embed(title=f"{ctx.author} successfully generated tiktok info ✅",description="Check your inbox !",color=0xffff00)
    await ctx.reply(embed=embed)                   ```
 Can someone help tell me the issue???
paper sluice
#

!code please format your code properly and explain what is wrong

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.

cold tide
#

And ive come here to seek help finding the issue.

#

@paper sluice

paper sluice
#

what is wrong pithink, why do you think there is an issue with your code?

vocal snow
cold tide
#

I cannot fimd the issue

#

@vocal snow when i try it never works.

vocal snow
#

so nothing is wrong then

cold tide
#

The command doesnt run.

#

Thats the issue i just cant find whats stopping it.

#

@vocal snow

paper sluice
cold tide
#

No errors show

vocal snow
cold tide
#

okay

#

Ill try that

cold tide
#

It worked ty!

paper sluice
#

they added extra digit to ids now?

maiden fable
#

Yea, another digit

#

The IDs are 19 digit now

paper sluice
#

👍

cold tide
#

is that bc my variable holds nothing??

#
embed2=discord.Embed() embed2=discord.Embed(title="🤖 Reaper Gen",description="Non-Premium Gen !",color=0xffff00)
    embed.add_field(name="Instagram Generated Info:",value=random.choice(ig),inline=True)
    await ctx.author.send(emb2=embed)
bot.run(token) 

can anyone help?? When running cmd it doesnt dm you.

#

@paper sluice

slate swan
#
ImportError: cannot import name 'InvalidArgument' from 'discord' (/home/container/.local/lib/python3.10/site-packages/discord/__init__.py)
hazy oxide
slate swan
#

u did emb2=embed

#

u needa change it to embed=emb2

slate swan
cold tide
#

😭

#

Oh okay

hazy oxide
#

He got 2 embed2 var

slate swan
#

oh right

hazy oxide
slate swan
#

just reove the embed2 = discord.Embed() @cold tide

slate swan
slate swan
#

i have both discord.py and discord.py-slash-command for button components

torn sail
cold tide
#

Still no dm

slate swan
#

i need to get the author of a button interaction

torn sail
hazy oxide
#

discord.ui

keen silo
#

i migrated from discord.py 1.7.3 to discord.py 2.0a
the problem is in terminal it shows "Bot is online" but when i try to run commands it shows :

2022-07-24 20:49:05 ERROR    discord.ext.commands.bot Ignoring exception in command None
discord.ext.commands.errors.CommandNotFound: Command "ping" is not found

any solution ? (note: i alr enabled message content intent)

slate swan
slate swan
keen silo
#

yes

torn sail
keen silo
#

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

torn sail
#

!d discord.app_commands.CommandTree

unkempt canyonBOT
#

class discord.app_commands.CommandTree(client, *, fallback_to_global=True)```
Represents a container that holds application command information.
slate swan
#
    async def on_component(ctx: ComponentContext):
NameError: name 'ComponentContext' is not defined
#
@bot.event
async def on_component(ctx: ComponentContext):
    await ctx.defer(
        ignore=True
    )  # ignore, i.e. don't do anything *with the button* when it's pressed.

    ticket_created_embed = discord.Embed(
        title="Ticket Processed",
        description=f"""Hey {ctx.author.name}! Thanks for opening a ticket with us today. Let's continue""",
    )

    overwrites = {
        guild.default_role: discord.PermissionOverwrite(view_channel=False),
        ctx.author: discord.PermissionOverwrite(view_channel=True),
        guild.me: discord.PermissionOverwrite(view_channel=True),
    }

    ticket = await deals_cog_2.create_text_channel(
        f"{ctx.author.name}-{ctx.author.discriminator}", overwrites=overwrites
    )

    await ticket.send(
        ctx.author.mention, embed=ticket_created_embed
    )  # ping the user who pressed the button, and send the embed
vocal snow
timber widget
#

Hello bro. I made embed bot and send embed. Can you tell me now how can I edit that embed?

vocal snow
#

as far as I know

unkempt canyonBOT
#

await edit(*, content=..., embed=..., embeds=..., attachments=..., suppress=False, delete_after=None, allowed_mentions=..., view=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the message.

The content must be able to be transformed into a string via `str(content)`.

Changed in version 1.3: The `suppress` keyword-only parameter was added.

Changed in version 2.0: Edits are no longer in-place, the newly edited message is returned instead.

Changed in version 2.0: This function will now raise [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.10)") instead of `InvalidArgument`.
vocal snow
#

pass the new embed to it ^

timber widget
#

By putting await edit under it?

#

@vocal snow

vocal snow
#

not sure what you mean

#
message = await ctx.send(embed=embed)
embed.description = "edited description"
await message.edit(embed=embed)
``` is an example
timber widget
#

Without deleting that embed

vocal snow
#

yes

timber widget
#

Ok

timber widget
# vocal snow yes

Also bro I made a embed page so it changes when you press the button. Will it still work if bot is offline?

paper sluice
#

no, it will not

brazen skiff
#
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.musicc' raised an error: CommandRegistrationError: The command leave is already an existing command or alias.
timber widget
brazen skiff
#

I cant add a new cog to my bot

slate swan
#

Is there a way i could make my bot report to discord like something againstTOS ?

paper sluice
cold tide
#
@bot.command()
async def toss(ctx):
  embed2=discord.Embed()
  embed2=discord.Embed(title="Heads or tails ?",description="Flipping coin...",color=0xffff00)
  time.sleep(1.3)
  embed2.add_field(name="It Landed on:",value=random.choice(flip),inline=True)
  await ctx.send(embed2=embed)
bot.run(token)
sleek palm
#

is there a way so the reaction roles would still work after restarting the bot? cause it stops working after i restarted the bot

slate swan
#

Is there a way i could make my bot report to discord like something againstTOS

paper sluice
cold tide
#

Ahhh

brazen skiff
#

oh nvm

cold tide
#

So what should it be??

paper sluice
brazen skiff
paper sluice
vocal snow
slate swan
paper sluice
#

!d discord.Interaction.user

unkempt canyonBOT
vocal snow
slate swan
paper sluice
brazen skiff
sleek palm
paper sluice
vocal snow
paper sluice
#

oh nvm, i think i misunderstood the question

slate swan
#

Is there a way i could make my bot report to discord like something againstTOS?

For exam ple i say
?report
The bot responds with "message link:"
And when i type the message link
The bot responds with "What reason (then like the reasons you report for"
And then sends the report to discord

paper sluice
vocal snow
paper sluice
slate swan
paper sluice
slate swan
#

alr

slate swan
slate swan
#

alr ty

#
    ticket = await deals_cog_2.create_text_channel(
AttributeError: 'NoneType' object has no attribute 'create_text_channel
#

deals_cog_2 is None

slate swan
#

Can someone tell me how this works?! How does bump reminder See it, that I was bumping... I thought you can't read interactions that go to another bot

#

guys can anyone help me

vocal snow
#

and maybe if it's sending an embed and some regex

sly hamlet
#

When making a play command I keep on getting nonetype. Object has no attribute play

    @app_commands.command(name='play',
                       description="Test Play")
    async def play(self, interaction: discord.Interaction):
            server = interaction.guild
            voice_channel = server.voice_client
 
            if not voice_channel: # if client isn't connected to any VCs
                user_vc = interaction.user.voice # get user's voice state
                if not user_vc: # if user isn't connected to any VCs
                    await interaction.response.send_message("You are not connected to a voice channel")
                    return
                destination = user_vc.channel
                await destination.connect()
                audio_source = discord.FFmpegPCMAudio('song.oog')
                voice_channel.play(audio_source)
                await interaction.response.send_message("Playing")```
slate swan
#

So i made a self bot (just for educational purposes) and what it does. when i ,test it will send a specific message to a specific channel , how can i make it send that message to multiple channels until i input something like NO

slate swan
unkempt canyonBOT
#

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

torn sail
#

is on_invite_delete triggered when an invite is deleted only or does it also trigger when an invite expires?

vocal snow
slate swan
#

bc id like to do a lvl system about using bots...

slate swan
vocal snow
slate swan
#

Idk, let's check it

#

How do i make it send message to multiple channels?

vocal snow
slate swan
#

just for a bot Cat_smile

vocal snow
#

id recommend stopping before a mod comes along and notices

slate swan
#

alr

#

homies gonna help me

slate swan
slate swan
unkempt canyonBOT
slate swan
#

and use .user on it

vocal snow
#
await ctx.defer()
``` at the start, then `await ctx.followup.send` instead of ctx.respond
#

im guessing it takes more than 3 sec to generate your imag

#

also uh, you should handle the pillow stuff in a seperate thread probably

humble fog
#

does anyone know how to use Rcon from a minecraft server to interact with a os discord bot?

slate swan
#

?rfdm wait_for()

sick birch
#

Python does have a few libraries for that, worked with a few

#

But this isn’t the right channel for that

humble fog
#

robin u talking to me?

humble fog
sick birch
humble fog
#

which channel is it i wanna ask?

sick birch
#

It’s sort of niche so you’ll wanna open up a help channel

humble fog
#

i did yesterday but noone said anything

#

at this point imma just give up

#

ive been working on this for wayyy too long

#

17 hours a day for 3 days

#

got nowhere

sick birch
#

@humble fog a quick search for “python Minecraft rcon” shows up many results