#discord-bots

1 messages · Page 985 of 1

torn sail
#

Anyways so just create an async function with the code to post guild count and use self.loop.create_task in the setup_hook to run it

#

Try that

sly hamlet
#

We have already tried that

torn sail
#

Was it the “loop cannot be accessed outside an async function” error?

sly hamlet
#

Yep

#

Everything is throwing the same error right now

torn sail
#

Well then the topgg library is not working with discord.py 2.0 probably

sly hamlet
#

ok

frozen patio
#

Ok

final iron
#

Ok

olive osprey
#

Ok

slate swan
#

Why don't you just make a normal request to the api instead of usne that wrapper?
It's not at all hard

sly hamlet
abstract kindle
#

Hey guys! How would I change the duration of a task.loop every time it is run?

#

I want to make it a random number of minutes between 30 and 60, but when the task is started, it just picks a random number between 30 and 60, sets it as its minutes to loop, and doesn't change (since it's not being rerun)

#

How would I fix this?

vital whale
#

Hello, could anyone point me in the right direction to learn how to turn discord commands (i.e !playmovie night of the living dead) into context dependent commands? (in this case [client.playMedia(night of the living dead])

loud junco
#

💥

#

2 seconds later :

vocal walrus
# loud junco

well that happens sometimes when hosting on replit

loud junco
vocal walrus
#

"sometimes"

#

more like every 10 seconds of running a bot

torn sail
#

!d discord.ext.commands.Cog.cog_check

unkempt canyonBOT
#

cog_check(ctx)```
A special method that registers as a [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") for every command and subcommand in this cog.

This function **can** be a coroutine and must take a sole parameter, `ctx`, to represent the [`Context`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Context "discord.ext.commands.Context").
torn sail
#

And check the guild id

sick birch
#

If you're talking about extensions, I don't believe so

#

Maybe in your setup() you could conditionally load a cog

#

Nevermind that wouldn't work

#

With a cog check it'd work

torn sail
#

yeah define it within the cog class

abstract kindle
#

Heyo, anyone familiar with task loops

torn sail
shell dune
#

best python interpreter version for discord bot?? Is there a go to version for discord.py?

gaunt ice
#

nvm

#

idk

#

i suck at python

slate swan
shell dune
abstract kindle
#

Sorry @torn sail. Forgot to come back to this. I need help changing the duration of the loop on loop

#

Is that possible?

vale wing
#

cog_check is a method of commands.Cog you override

vale wing
#

Also why do this when you can just os.listdir your cogs folder

unkempt canyonBOT
#

setup.py line 82

python_requires='>=3.8.0',```
slate swan
#

¯_(ツ)_/¯

vale wing
#

@slate swan

slate swan
#

mhmmm

#

well idk maybe they havent updated the setup file since they havent released to pypi

vale wing
#

Yeah probably

swift crane
#

oh my....

#

I can't connect github to haroku

junior verge
#

Maybe heroku issues

swift crane
#

oki

slate swan
#

👋

jade tartan
#

Hi i am making a leveling system and stoing the xp and level into a database. i got this error. how do i fix it?

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\OneDrive\Desktop\discord server bot\leveling system.py", line 21, in on_message
    if message.author.client:
AttributeError: 'Member' object has no attribute 'client'
bleak karma
#

help

def check(message):
    return message.content == f"{password}"

  messg = await bot.wait_for('message', check=check, timeout=30)
  cntent = int(messg.content)

  if cntent != password:
    await member.send("**Wrong answer.** Please try again.")
  else:
    await member.send("**Correct answer.** Access granted.")

idk if its bc its sent in a dm but it doesnt respond and it doesnt show any error

supple thorn
#

Just code 10 commands

jade tartan
#

Yes

supple thorn
#

Wdym how

jade tartan
#

I just said that

supple thorn
#

Learn how to make commands

#

Then make commands

jade tartan
#

ohh ok sorry

bleak karma
supple thorn
supple thorn
#

Since the error says that

jade tartan
#

Yeah i knew it

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\OneDrive\Desktop\discord server bot\leveling system.py", line 24, in on_message
    await cursor.execute("SELECT xp FROM levels WHERE user = ? AND guild = ?", (author.id, guild.id,))
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\aiosqlite\cursor.py", line 37, in execute     
    await self._execute(self._cursor.execute, sql, parameters)
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\aiosqlite\cursor.py", line 31, in _execute    
    return await self._conn._execute(fn, *args, **kwargs)
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\aiosqlite\core.py", line 129, in _execute     
    return await future
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\aiosqlite\core.py", line 102, in run
    result = function()
sqlite3.OperationalError: no such column: xp```
supple thorn
#

no

slate swan
#

sure, what should it do?

supple thorn
#

God damn it

slate swan
#

sure

supple thorn
#

Not another spoonfeeder

slate swan
jade tartan
#

You code your own bot use YouTube to help

supple thorn
#

Use the docs

#

Just look at the docs

jade tartan
jade tartan
bleak karma
#

u only have level, user and guild

#

iirc

jade tartan
#

I do tho wdym?

jade tartan
bleak karma
jade tartan
#

Ohh that okay so I have have do integer?

#

Xp

bleak karma
#

yeah

bleak karma
# supple thorn What's the full code
  @bot.event
  async def on_member_join(member):
    font = ImageFont.truetype("Bigwhale.otf", 100)
    img = Image.open("shinobu.png")
    y, x = (318, 163)

    draw = ImageDraw.Draw(img)
    draw.text((y, x), passwords, (255, 255, 255), font=font)
    img.save("verifypw.png")

    with open("verifypw.png", "rb") as f:
      img = File(f)
  
    b = discord.Embed()
    b.title = "**VERIFICATION PROCESS!**"
    b.description = "please input the numbers presented above to access the rest of the channels in shinobu. You have 30 seconds to answer."
    b.colour = 0xa7c997
    await member.send(embed=b, file=img)

    def check(message):
      return message.content == f"{passwords}"

    hh = await bot.wait_for('integer', check=check, timeout=30)
    att = int(hh.content)

    if att != passwords:
      await member.send("**Wrong answer.** Please try again.")
    else:
      await member.send("**Correct answer.** Access granted.")
jade tartan
#

Well guess what?

#

Its still the same error

bleak karma
#

delete ur db

#

ur current db

supple thorn
bleak karma
supple thorn
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 the Members and Presences intents, which are needed for events such as on_member 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.

supple thorn
jade tartan
supple thorn
#

Just to be sure it even triggers

bleak karma
jade tartan
#

Delete my db?

bleak karma
#

if u updated that

bleak karma
supple thorn
#

You should have message for the event inside bot.wait_for

bleak karma
#

bc it didnt work on 'message'

supple thorn
bleak karma
#

hold on

bleak karma
supple thorn
slate swan
#

Should be "message"

bleak karma
slate swan
#

oh oki

slate swan
bleak karma
supple thorn
# bleak karma ^^

Why are you checking if message.content is the password when you're checking later

slate swan
#

whats the passwords variable

slate swan
#

you are checking if the message content is == str(passwords)

supple thorn
#

And probably channel

#

Yeah channel too

bleak karma
#

i see

bleak karma
# slate swan whats the passwords variable
  password1 = f"{random.randint(1, 10)}"
  password2 = f"{random.randint(1, 10)}"
  password3 = f"{random.randint(1, 10)}"
  password4 = f"{random.randint(1, 10)}"
  password5 = f"{random.randint(1, 10)}"
  password6 = f"{random.randint(1, 10)}"

  passwords = password1+password2+password3+password4+password5+password6
supple thorn
supple thorn
#

😔

#

You should also check if it's in dms

bleak karma
supple thorn
# bleak karma i know

You're making the message content an integer then comparing the password which is a string to it

jade tartan
#

code

bleak karma
#
return message.author.id == member.id and message.guild is None

is it?

supple thorn
supple thorn
#

Since i don't do shit in bot's dms

bleak karma
#
  @bot.event
  async def on_member_join(member):

    password1 = random.randint(1, 10)
    password2 = random.randint(1, 10)
    password3 = random.randint(1, 10)
    password4 = random.randint(1, 10)
    password5 = random.randint(1, 10)
    password6 = random.randint(1, 10)

    passwords = password1+password2+password3+password4+password5+password6
    channel = bot.get_channel(965325309945729094)
    font = ImageFont.truetype("Bigwhale.otf", 100)
    img = Image.open("shinobu.png")
    y, x = (318, 163)

    draw = ImageDraw.Draw(img)
    draw.text((y, x), f"{passwords}", (255, 255, 255), font=font)
    img.save("verifypw.png")

    with open("verifypw.png", "rb") as f:
      img = File(f)
  
    b = discord.Embed()
    b.title = "**VERIFICATION PROCESS!**"
    b.description = "please input the numbers presented above to access the rest of the channels in shinobu. You have 30 seconds to answer."
    b.colour = 0xa7c997
    await member.send(embed=b, file=img)

    def check(message):
      return message.author.id == member.id and message.guild is None

    hh = await bot.wait_for('message', check=check, timeout=30)
    att = int(hh.content)

    if att != passwords:
      await member.send("**Wrong answer.** Please try again.")
    else:
      await member.send("**Correct answer.** Access granted.")
bleak karma
supple thorn
bleak karma
#

tyty

supple thorn
#

Coolio

cedar stream
keen dust
#

Where do u get API's stored in json format online?

jade tartan
keen dust
#

I'm looking for a meme generating API to be specific

keen dust
jade tartan
keen dust
#

yes

supple thorn
#

😔

vale wing
#

Man random.randint(100000, 999999) exists like wtf

#

By summarising those 6 "password" vars you will just get a number from 6 to 600

#

Cause they're int and not strings

vale wing
bleak karma
#

well i clearly didnt think of that thank you ig

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\OneDrive\Desktop\discord server bot\leveling system.py", line 31, in on_message
    await bot.commit()
AttributeError: 'Bot' object has no attribute 'commit'
#

I need help fixing this

vale wing
#

Seems like you were using old version of your own table

vale wing
jade tartan
#

That was just posted

#

Just recently

vale wing
#

You know python right?

#

I hope you ain't just copying code

jade tartan
#

Yes

#

Nope

jade tartan
#

@vale wing plz

vale wing
#

I will tell you about it more when I get home

#

In like 30 mins ok

jade tartan
#

ok

#

You know i mean i am using sqlite to do this i am just gonna use json

#

Better

stiff nexus
#

anyone know how to combine 2 view class and send in one msg?

supple thorn
keen dust
jade tartan
lofty pecan
#

@jade tartan have a look at that

vale wing
vale wing
#

You typically google them

keen dust
jade tartan
#

Can someone help me with this?

stiff nexus
jade tartan
#

minutes

#

?

#

like for how long the member can go afk for

vale wing
# stiff nexus example pls??
new_view = disnake.ui.View()
for v in (view1, view2):
    for child in v.children:
        new_view.add_item(child)```
I never tried but this is what I am guessing
jade tartan
keen dust
#

can u give me some API sites which don't require an API key?

keen dust
#

nvm I got it

boreal ravine
terse blade
#

ERROR: Error [WinError 2] The system cannot find the file specified while executing command git version
ERROR: Cannot find command 'git' - do you have 'git' installed and in your PATH?

#

saying this but i have git installed?

placid skiff
dim tapir
terse blade
#

it bugged

#

had to restart my pc and it worked

surreal sierra
#

hi I havent coded for like 2 months now and just got back to it and I see I have this error in one of my projects of 2 arguments missing but but I look at the code I see those exact arguments are right there.
Its probably something small and dumb that I cant see

scarlet aurora
#

when making a command how can I put a space in the command name? for example !help animations

slate swan
#

make a command group

maiden fable
#

@slate swan heard about discord.py hybrid commands?

#

They do be copying Hikari haha

scarlet aurora
slate swan
dim tapir
maiden fable
maiden fable
placid skiff
#

There was a way to execute a command without invoking it? I remember something like execute_command or command.execute was i drunk or something?

dim tapir
# scarlet aurora wdym
@bot.group(pass_context=True)
async def help(self, ctx):
  pass

@help.group(pass_context=True)
async def animations(self, ctx):
  pass
scarlet aurora
#

oh k ty

maiden fable
unkempt canyonBOT
#
Nah.

No documentation found for the requested symbol.

regal pulsar
#
@commands.command()
    async def kill(self, ctx: commands.Context, member: disnake.Member):
        embed = disnake.Embed(
            title="BAM!", description=f"{ctx.author.mention} {random.choice(death_links)} {member.mention}", color=ORANGE
        )
        embed.set_image(url=random.choice(death_options))
        await ctx.channel.send(embed=embed)
maiden fable
#

!d discord.ext.commands.Context.invoke *

unkempt canyonBOT
#

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

Calls a command with the arguments given.

This is useful if you want to just call the callback that a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") holds internally.

Note

This does not handle converters, checks, cooldowns, pre-invoke, or after-invoke hooks in any matter. It calls the internal callback directly as-if it was a regular function.

You must take care in passing the proper arguments when using this function...
regal pulsar
#

the desc looks like this for some reason

#

why is that

slate swan
placid skiff
placid skiff
#

it needs a context tho

supple thorn
#

Bro i'm struggling on spelling help

placid skiff
#

uhm, could find a use of it anyway

maiden fable
unkempt canyonBOT
#
NEGATORY.

No documentation found for the requested symbol.

maiden fable
#

!d discord.ext.commands.Bot.get_context

unkempt canyonBOT
#

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

Returns the invocation context from the message or interaction.

This is a more low-level counter-part for [`process_commands()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.process_commands "discord.ext.commands.Bot.process_commands") to allow users more fine grained control over the processing.

The returned context is not guaranteed to be a valid invocation context, [`Context.valid`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Context.valid "discord.ext.commands.Context.valid") must be checked to make sure it is. If the context is not valid then it is not a valid candidate to be invoked under [`invoke()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke").

Note

In order for the custom context to be used inside an interaction-based context (such as [`HybridCommand`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.HybridCommand "discord.ext.commands.HybridCommand")) then this method must be overridden to return that class...
supple thorn
#

Can't spell depecrated

slate swan
#

Command.invoke can also be used , its just not documented

supple thorn
#

Help

slate swan
#

But it still needs a context

maiden fable
#

Depreciated

placid skiff
#

time to read the source code then

supple thorn
placid skiff
#

it is used to remove group command from the command you want to invoke

boreal ravine
boreal ravine
supple thorn
boreal ravine
#

oh

#

@supple thorn Wrong

supple thorn
#

Back to struggline how to parse images from a api

boreal ravine
supple thorn
supple thorn
#

And the one you showed in the image

boreal ravine
supple thorn
placid skiff
supple thorn
#

That's why i said i spelt it correctly

slate swan
#

deprecated and depreciated are both correct...

supple thorn
slate swan
#

Oh ok

#

😔why does that matter tho lmao

supple thorn
boreal ravine
maiden fable
boreal ravine
#

it would

maiden fable
#

!d discord.ext.commands.Command

unkempt canyonBOT
#

class discord.ext.commands.Command(*args, **kwargs)```
A class that implements the protocol for a bot text command.

These are not created manually, instead they are created via the decorator or functional interface.
maiden fable
#

Wait

boreal ravine
maiden fable
#

Nvm I thought u were calling the class

boreal ravine
#

Lol

maiden fable
#

My bad. Forgot Command had a call method impl

slate swan
slate swan
spring verge
#

Anyone here who has tried pydroid3 before for developing bots?

brave forge
#

@supple thorn pls help

supple thorn
brave forge
#

@supple thorn do you know how to make the user's profile show how much time he spent in voice channels ?

supple thorn
#

You can't change a users profile

#

Only they can

brave forge
#

@supple thorn That's not what I mean. And the fact that a person prescribes a command and the command shows how much time he spent in the voice channel

brave forge
#

I looked at the documentation but nothing is clear there

boreal ravine
#

just store the time and then fetch it when you wanna use it

boreal ravine
supple thorn
supple thorn
#

Well i have about 13727 right now

supple thorn
brave forge
boreal ravine
brave forge
#

well, at least there was an example

jade tartan
vocal plover
#

for themselves

supple thorn
#

I'm still surprised my name doesn't break the rules

boreal ravine
#

cocaine doesn't break the rules

supple thorn
#

I thought it would

maiden fable
#

Brad here

velvet compass
#

We would probably ask you to change your username so it isn't a recreational drug

#

Since we are a learning server and all

#

But @supple thorn you are clearly a cane of Coca Cola

jade tartan
#

Can any one help me plz

supple thorn
velvet compass
#

I'm not that bad am I?

vocal plover
#

You do have to wonder why you'd keep a name if you explicitly thought it breaks the rules Thonk

brave forge
supple thorn
maiden fable
maiden fable
supple thorn
#

👍

velvet compass
#

!u

vocal plover
unkempt canyonBOT
#
brad90four#1463
User information

Created: <t:1586551853:R>
Profile: @velvet compass
ID: 698273827448291379

Member information

Joined: <t:1622294818:R>
Roles: <@&267629731250176001>, <@&831776746206265384>, <@&787816728474288181>, <@&267630620367257601>, <@&764802720779337729>, <@&463658397560995840>, <@&542431903886606399>

Activity

Messages: 27,242
Activity blocks: 6,274

Infractions

Total: 17
Active: 0

vocal plover
#

but I see how you could confuse them

maiden fable
velvet compass
#

Mods never joke infract each other

#

(its all the time)

maiden fable
#

Totally not, yes

unkempt canyonBOT
#

You are not allowed to use that command here. Please use the #bot-commands channel instead.

boreal ravine
stone beacon
#

🗿

brave forge
supple thorn
velvet compass
#

For sure

vocal plover
boreal ravine
velvet compass
#

I have a general question, what discord bots do you find the most impressive in terms of features, code style and fun interacting with?

supple thorn
#

Always drank the high fructose sugar kind

vocal plover
#

and it's source available

#

soon™️ will be EPL-2

supple thorn
vocal plover
#

:)

boreal ravine
supple thorn
#

I was thinking this entire time "damn this goose is good"

#

Was going through your messages

boreal ravine
#

Lmao

supple thorn
#

I was about to ask you how are geeses superior to ducks

vocal plover
#

mee6 doesnt actually have their current code available

#

it was open once upon a time but not anymore

#

the original repo was under coookie's account iirc

supple thorn
brave forge
#

@velvet compass do you have a bot or at least just a team that counts all the time that the user spent in the voice channel and summarizes it ?

supple thorn
#

Tried to read it's source code but got sad since it's in js

vocal plover
#

I though dank memer was java/kotlin

velvet compass
supple thorn
vocal plover
brave forge
#

@velvet compass we would at least just see the part of the code that is responsible for how the bot counts the amount of time in the voice and writes it to a variable

velvet compass
#

Is that a question or a statement?

supple thorn
brave forge
velvet compass
#

Alrighty. I'm not sure of the implementation details but if you have an idea you could open an issue and see if a core dev thinks it is valuable to add

supple thorn
#

He wants code for when a member joins a vc and put that exact datetime into a database and fetch that data when a command gets used

boreal ravine
velvet compass
supple thorn
#

He not doing a PR for a bot here

supple thorn
#

He's russian so he's using a google translate to answer

brave forge
supple thorn
#

So it sounds kinda weird

brave forge
velvet compass
# brave forge for myself

I'm not great with discord bots, but I would imagine a timer function would work. Just start the timer when a user's ctx.member.voice changes to True, and end the timer when it is False. Then take the difference and add it to some sort of database entry for the user's time in voice chat

supple thorn
velvet compass
#

Right, that would be the timer function

supple thorn
#

Oh

#

I thought you were literally telling penguin to do a timer function

velvet compass
#

That is essentially what it would be though. A timer that starts and ends when a user joins and leaves voice chat, then adds that value to a database entry to track the time spent in VC

brave forge
#

thanks for the help. But it's useless to explain in words because until you start the code, everything is clear, but as soon as you started. It is no longer clear what and how

velvet compass
#

That is part of learning though. Taking "pseudo code" that is written out in plain language and changing it into code written in a specific programming language

brave forge
#

@livid hinge

#

2 line from the bottom

austere solstice
brave forge
#

@livid hinge
голосовой онлайн - voice online
226h 24m

brave forge
slate swan
slate swan
#

i do it

velvet compass
slate swan
#

i mainly do it to keep a vision on what i want

slate swan
slate swan
#

same thing

#

its 8am and im tired already

#

😔

#

sleep

#

im in school

#

so i cant😔

#

shut yourself up in the locker, easy

#

we dont have lockers......

#

sad

#

😔

#

then you know where to go

#

😳

brave forge
#

@maiden fable help

maiden fable
#

With

slate swan
#

pliz laf

maiden fable
#

Lmao

slate swan
#

tysm

gaunt ice
#

hm

slate swan
#

How can I remove a reaction inside a on_raw_reaction_add function?

worldly garnet
#

guys anyone got a clue as to what docs i gotta refer to when i want my bot to do smth like this(i made help command for it to make it easier for people to understand):

#

basically wanna do like
.get IT w21
it then retrieves the IT November 2021 pastpaper

boreal ravine
#

you didn't return somewhere

brave forge
slate swan
#

How can I remove a users reaction inside a on_raw_reaction_add function with discord.py?

slate swan
frozen patio
slate swan
stray solar
#

hello

stray solar
#

Can anyone give me tempban command

vale wing
#

Nobody gives code for you to copy it

#

Only resources

frozen patio
#

I am not gonna give you a whole command

stray solar
#

reason ?

frozen patio
#

You would not be learning anything.

slate swan
stray solar
vale wing
#

Use a database to store unban times and tasks.loop() to periodically check if there are users to unban

vale wing
#

!d discord.ext.tasks.loop

unkempt canyonBOT
#

discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
frozen patio
stray solar
#

If I could create something, do you think I would be on this server?

slate swan
stray solar
#

I do not know as much as you do

slate swan
slate swan
#

is there anyway i can make a "only you can see this message" message?

#

example:

slate swan
slate swan
# slate swan example:

yes ofcourse, its called an ephemeral response which can be created only with an interaction like button click/ component usage / slash commands or any other user commands

frozen patio
#

and set it to ephemeral = True

stray solar
frozen patio
#

If I spelled it wrong apologies

slate swan
#

......?

slate swan
stray solar
#

There are many sites where you can see codes

slate swan
#

whaaaaaaaaaaaaaaaaat

unkempt canyonBOT
#
Resources

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

slate swan
#

there are many good "free" resources for learning python

#

Why do I have to use buttons and slash commands to use it?

slate swan
#

Can I use it with a reaction?

#

alternatively, if you want only 1 user to see the message, dms exist

#

Nope, not a reaction

dense swallow
#

can someone give me an example of a custom check in events?
if i want automod to be disabled, the event should be disabled guild wide, so how would that look like

slate swan
#

.

slate swan
#

I cant understand

#

what do you not understand? your own difficulty level or the type of resource you want?

#

Type of resource

boreal ravine
slate swan
#

At right u see

#

Where i can learn python there :/

slate swan
#

Ok python history now

slate swan
#

Ok

#

Tbh i cant even find how tf i print stuff

#

the print function?

#

Ye

#

!e print("Hello World!")

unkempt canyonBOT
#

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

Hello World!
slate swan
#

Bruh

#

I know python

#

Im talking as an begginer

#

ah

#

That is new to python

#

its just a tree full of courses it depends on the courses

#

!d

unkempt canyonBOT
velvet haven
#
intents = discord.Intents.default()
intents.members = True
client = commands.Bot(command_prefix=get_prefix, case_insensitive=True, owner_id=id, intents = intents)```
slate swan
#

?

velvet haven
slate swan
#

How do u know

#

Any error?

#

@velvet haven

#

..

slate swan
#

^^^

slate swan
#

..

#

Hi ash and hunter

maiden fable
maiden fable
slate swan
maiden fable
#

Nah, school and other shit

slate swan
slate swan
maiden fable
unkempt canyonBOT
#

The user IDs that owns the bot. This is similar to owner_id. If this is not set and the application is team based, then it is fetched automatically using application_info(). For performance reasons it is recommended to use a set for the collection. You cannot set both owner_id and owner_ids.

New in version 1.3.

slate swan
#

U know what :( today in my school a vaccination camp was there

slate swan
maiden fable
#

I already got the two vaccines

slate swan
slate swan
#

And it pains now where the 💉 hit

slate swan
#

No.

#

welp

#

!ot

unkempt canyonBOT
slate swan
unkempt canyonBOT
#

7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.

slate swan
#

your point?

slate swan
slate swan
#

cool

slate swan
#

Why this chat is ded ;-;

paper sluice
#

sad

slate swan
swift crane
slate swan
#

Yo

swift crane
#

yo

maiden fable
# swift crane

Prolly a heroku issue. There was a data breach a few days back and a few GitHub (Heroku issued) keys were stolen

swift crane
#

So i have problem

#

right?

maiden fable
#

Prolly

swift crane
#

and what can I do?

swift crane
maiden fable
#

?

swift crane
#

sorry for ping...

maiden fable
swift crane
#

what can i do about my stream key

vale wing
#
if message.channel.type == discord.ChannelType.private:
    return```
#

Eg

maiden fable
#

?

placid skiff
#

well i'm disnake side so D_D

vale wing
#

Disnake good

dense swallow
vale wing
#

I wrote ai antispam bot with disnake

vale wing
#

Decorators are possible as well ofc

wicked kindle
#

Hey guys. I'm a newb in python and I'm currently undertaking a course on udemy.

#

But i want to start early with my own project.

#

I have searched around to see the source code for a discord bot that message when NFT's are listed

#

any idea where can I find one?

maiden fable
#

I don't think u will find one

#

Your usecase is quite specific

vocal plover
opal cosmos
#

can i make my bot change its pfp every so often?

slate swan
#

anay wy to make an eval command?

#

i tried most things like eval() and exec but the return error like unexpeced in non quoted string

#

or smthing

#

Can you show your code?

slate swan
opal cosmos
slate swan
#

well, just like normal user avatar update, that has ratelimits too if im not wrong

opal cosmos
#

ok

quaint epoch
slate swan
quaint epoch
#

never used it myself tho

slate swan
quaint epoch
#

huh

slate swan
quaint epoch
#

!e

unkempt canyonBOT
#
Missing required argument

code

#
Command Help

!eval <code>
Can also use: e

*Run Python code and get the results.

This command supports multiple lines of code, including code wrapped inside a formatted code block. Code can be re-evaluated by editing the original message within 10 seconds and clicking the reaction that subsequently appears.

We've done our best to make this sandboxed, but do let us know if you manage to find an issue with it!*

quaint epoch
#

hmmm

slate swan
#

i want it to do that

#

but it doesnt et me

quaint epoch
slate swan
#

and its source code is too complex lol

slate swan
quaint epoch
#

compile() does what?

slate swan
#

!d compile

unkempt canyonBOT
#

compile(source, filename, mode, flags=0, dont_inherit=False, optimize=- 1)```
Compile the *source* into a code or AST object. Code objects can be executed by [`exec()`](https://docs.python.org/3/library/functions.html#exec "exec") or [`eval()`](https://docs.python.org/3/library/functions.html#eval "eval"). *source* can either be a normal string, a byte string, or an AST object. Refer to the [`ast`](https://docs.python.org/3/library/ast.html#module-ast "ast: Abstract Syntax Tree classes and manipulation.") module documentation for information on how to work with AST objects.

The *filename* argument should give the file from which the code was read; pass some recognizable value if it wasn’t read from a file (`'<string>'` is commonly used).
slate swan
#
@bot.command()
async def ev(ctx,*, msg):
    await ctx.send(eval(msg))```
quaint epoch
#

ooh okay

slate swan
#

stil doesnt work

#

What happen

#

im trying to make an eval command

#

Oh.

#

but it doesnt work

#

Error?

vocal plover
#

is it meant to be a public eval command?

slate swan
#

raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 50006): Cannot send an empty message

slate swan
#

Show how u type the command

#
@bot.command()
async def ev(ctx,*, msg):
    await ctx.send(eval(msg))```
#

if you dont want to go thru the pain of making an eval command just use jishaku

#

I mean how u did the command

vocal plover
#

looking at a module like jishaku may be a good idea then

slate swan
#

though its recommended to make one by your own

slate swan
vocal plover
slate swan
#

Nvmd

#

raise BadArgument('Converting to "{}" failed for parameter "{}".'.format(name, param.name)) from exc
discord.ext.commands.errors.BadArgument: Converting to "int" failed for parameter "msg".

slate swan
vocal plover
#

for something with such potential for remote code execution by others and the ability to cause such damage, unless your intent is to learn how eval commands work I don't think making your own is a great idea

#

I've seen so many bots where people made their own eval commands which are broken in some way that allows for malicious use, so unless you have a good reason for doing it yourself there isn't really a point

slate swan
#

well @commands.is_owner() is always an option

slate swan
#

print("hi")

slate swan
#

For your own good, don't just copy the code, you will go nowhere.

#

timtoy

#

But knowing how dpy users are, people will copy it.

#

bro no cat pfp😔

#

I'm sad, my pfp is reflecting that

#

i see that😔

#

Or I guess, the lack thereof

slate swan
slate swan
# slate swan Alr

Do you want me to break it down? I can do so for you if you find it hard to understand

slate swan
#

What u want

#

To print the executed command

#

So in this case it should send hi

#

?

#

Stop referring to code or functions as commands lol

#

You're disregarding common terminology

#

No I mean just generic code

#

yeah

slate swan
#

i think add_command is to bound a function to the bot right?

#

They're not talking about dpy commands

#

ik im just wondering

scarlet rune
#

should i use cogs in main file?

slate swan
#

If you want to

#

you can but it doesnt mean you should

vocal plover
#

Generally no, it's a good idea to have a multi-file structure for your bot

slate swan
#

Cogs are used to split up application logic and organize stuff.

scarlet rune
#

i did, but this

def setup(bot):
    bot.add_cog(_cogname_(bot))
#

doesnt work?

slate swan
#

cogs are just extension/containers that have listeners and commands

scarlet rune
#

or bot.add_cog

#

or get_cog

slate swan
#

You can pair them with the "extensions" feature that dpy provides, where you can load/unload/hot reload python modules at runtime

scarlet rune
#

i just want to organize the stuff in my main file

slate swan
scarlet rune
#

the other extensions are other things

slate swan
#

Just use multiple files 🤷‍♂️

#

that just makes more messy classes in a file

scarlet rune
#

eeeeh

#

alr then

slate swan
#

plus why make cogs in the main file?

#

"This doesn't work so what should I do?" Doesn't work. If you can't debug it, at least provide us with info to debug it for you.

#

categories?

scarlet rune
slate swan
#

Are you blind

#

theres really no difference?

scarlet rune
#

ik

#

im just wondering if it could work

cloud dawn
scarlet rune
#

cause it doesn't

slate swan
#

I'm out

blissful lagoon
#

@slate swan you've already been warned about being rude. Let this be the last warning you need.

opal cosmos
#

so im tryin to make a command and have the bot react to its own message, and when the user reacts with the same emoji it deletes the message. everything works fine except it wont delete the message. theres no error either, pls help me w this, heres code:

@bot.command()
async def test(ctx):
  msg = await ctx.send("React below to delete this message.")
  icon = await msg.add_reaction("❌")

  def check(m):
    return m.reaction == icon and m.message == msg

  await bot.wait_for("reaction", check=check)

  await msg.delete
lyric apex
#

How to do this?

cloud dawn
#

!e ```py
print(import("datetime").datetime.now().timestamp())

unkempt canyonBOT
#

@cloud dawn :white_check_mark: Your eval job has completed with return code 0.

1650387313.052786
lyric apex
#

Format

#

Like can i show there that the user was created 2-3 years ago

cloud dawn
#

<t:1650387313:R>

lyric apex
#

Yes like this

#

How?

cloud dawn
#

<t:1650387313:R>

opal cosmos
cloud dawn
#

<t:1650387313:F>

cloud dawn
lyric apex
#

There must be more formats?

opal cosmos
lyric apex
#

Ty

cloud dawn
opal cosmos
velvet haven
#

I get runtime error when I enable intents = true

#

How to fix this

cloud dawn
#

!d discord.Intents

unkempt canyonBOT
#

class discord.Intents(**kwargs)```
Wraps up a Discord gateway intent flag.

Similar to [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions"), the properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools.

To construct an object you can pass keyword arguments denoting the flags to enable or disable.

This is used to disable certain gateway features that are unnecessary to run your bot. To make use of this, it is passed to the `intents` keyword argument of [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client").

New in version 1.5...
cloud dawn
velvet haven
#

is it okay now

#

nvm i got it fixed

opal cosmos
#

@cloud dawn

velvet haven
#
channel = self.client.get_channel(id)
await channel.send(embed=embed)```
cloud dawn
velvet haven
#

getting attribute error

#

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

cloud dawn
opal cosmos
cloud dawn
opal cosmos
slate swan
opal cosmos
#

why

slate swan
#

Use ctx.delete()

#

I think

opal cosmos
#

that would delete the users message tho right?

slate swan
#

await ctx.message.delete()

slate swan
opal cosmos
slate swan
#

Hang on I almost got it

#

delete_after=int

#

So you have ctx.send

#

In that add delete_after=6 or some number

opal cosmos
#

but i dont want it to delete after a specific amount of time i want it to delete after the reaction is added

#
@bot.command()
async def test(ctx):
  msg = await ctx.send("React below to delete this message.")
  icon = await msg.add_reaction("❌")

  def check(m):
    return m.reaction == icon and m.message == msg

  await bot.wait_for("reaction", check=check)

  await msg.delete()
slate swan
cloud dawn
opal cosmos
velvet haven
#

TypeError: coroutine.send() takes no keyword arguments

slate swan
velvet haven
slate swan
cloud dawn
slate swan
opal cosmos
velvet haven
slate swan
cloud dawn
velvet haven
#

RuntimeWarning: coroutine 'Client.fetch_channel' was never awaited
await self.on_error(event_name, *args, **kwargs)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

opal cosmos
#

so im working on a help command but i want to make the page argument optional, i thought i knew how this worked but its not working. heres my code:

@bot.command()
async def help(ctx, page=Optional):
  if page == "mod":
    await ctx.send("'''yaml\nModeration Commands:\n\n+warn [user] [reason]\n\n+kick [user] [reason]\n\n+ban [user] [reason]\n\n+purge [number]''')
  if page == "util":
    await ctx.send('''yaml\nUtility Commands:'''")
  if page == "fun":
    await ctx.send('''yaml\nFun Commands:'''")
  if page == None:
    await ctx.send("Please format the command like this:\n\nc:help [specify **mod**, **util**, or **fun**]")
#

no error

sick birch
#

You shouldn’t be making help commands that way

#

Rather you should subclass help command for more customizability

opal cosmos
#

cogs?

#

@sick birch

#

hello?

velvet haven
#
@commands.Cog.listener()
    async def on_member_remove(self, member):
        channel = await self.client.fetch_channel(964209152798904343)
        embed = discord.Embed(description='Goodbye from all of us..', color=random.choice(self.client.colors))
        embed.set_thumbnail(url=member.avatar_url)
        embed.set_author(name=member.name, icon_url=member.avatar_url)
        embed.set_footer(text=member.guild, icon_url=member.guild.icon_url)
        embed.timestamp = datetime.datetime.utcnow()

        await channel.send(embed=embed)```
is it correct
frozen patio
#

Do you guys have any idea for a anti nuke system

opal cosmos
frozen patio
#

I want to make a rate limit where if you kick/ban too many people in a certain amount of ttime

#

you get your role removed

#

But I have no idea where to start

opal cosmos
slate swan
frozen patio
uncut zephyr
#

Is it possible to get the message.id directly from a " await channel.send() " function?

little ivy
#

How do i make this with a member and not a role?

#

await channel.set_permissions(guild.get_role(961982510340923484), send_messages=True, read_messages=True)

slate swan
# frozen patio Yeah I could definitely use some ideas
  1. Check if a Member joined a Server
  2. Check if the Member is a Bot Account
  3. Get the Role object of a role with specific permissions that would qualify as a mod/staff role
  4. Ask for confirmation from Two or more Members with the required Role for letting the bot access all the Channels in the Server. Else Kick it
frozen patio
#

I just want to make where if a Moderator kicks/bans 10 people within a minute they lose their mod role

silent ridge
#

hey, which hosting do you guys use for discord bots?

frozen patio
uncut zephyr
slate swan
#

😭

vale wing
slate swan
#

or if youre on 3.10 use pipes

#

!pep 604

unkempt canyonBOT
#
**PEP 604 - Allow writing union types as ``X | Y``**
Status

Accepted

Python-Version

3.10

Created

28-Aug-2019

Type

Standards Track

slate swan
# frozen patio Maybe, I just do not know how to make one

you could make a dictionary

bot.bans = {}

@event
async def on_member_remove(member):
      "check if the member was banned and if then by whom and make a key in the dictionary (bot.bans) if it already doesnt exist else update it"

@ext.tasks.loop(seconds=5)
async def _t():
    "iterate through bot.bans and check if a value of a key is > 10 and do the *stuff*"

'''Create another task for cleaning the dictionary'''```
warm tulip
#

hey yo i have a question
can someone come in a vc and teach me evrething about creating dicord bot with pyton?

frozen patio
#

There is docs for that

vale wing
#

Personally I can't and I doubt anybody would

warm tulip
#

but im iranian my us lunguge is not really good for reading docs

vale wing
#

Well knowing english will help you a lot in programming

warm tulip
vale wing
#

I am not native english speaker either tho

slate swan
#

most languages use english keywords so you need to know a bit of english

warm tulip
vale wing
#

I think it teaches about events

warm tulip
#

😐

vale wing
#

And you can find events in events reference in docs or ask us

slate swan
#

i wouldnt recommend that tutorial anymore

slate swan
slate swan
warm tulip
#

can someone give me a link so i can make a bot like mee6 or probot ??

slate swan
#

but thats a good idea ash 😳

slate swan
vale wing
slate swan
vale wing
slate swan
#

and iirc that tutorial is in 1.7.3

#

you wont find code for mee6 lmao

#

it uses a custom wrapper

vale wing
#

mee69

slate swan
#

bro

warm tulip
slate swan
velvet haven
#
intent = discord.Intents(members=True)
client = commands.Bot(command_prefix=get_prefix, case_insensitive=True, owner_id=862374422749249556, intent=intent)```
slate swan
#

discord.py is an advance lib which you need to know what youre doing

vale wing
#

Clearly best bot

velvet haven
warm tulip
slate swan
vale wing
#

Wondering how did he write it with html

slate swan
vale wing
slate swan
#

!d discord.Intents

unkempt canyonBOT
#

class discord.Intents(**kwargs)```
Wraps up a Discord gateway intent flag.

Similar to [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions"), the properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools.

To construct an object you can pass keyword arguments denoting the flags to enable or disable.

This is used to disable certain gateway features that are unnecessary to run your bot. To make use of this, it is passed to the `intents` keyword argument of [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client").

New in version 1.5...
slate swan
#

wait yeah you can

slate swan
#

i doubt it would break for passing kwargs into its params

velvet haven
#

bruh

vale wing
#

Anyways gonna go learn docker volumes cya

slate swan
#

bai bai take care

#

html is pretty easy but css is just something else

vocal plover
#

that is the new one lol

unkempt canyonBOT
#

7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.

vale wing
#

CSS is all about finding out the attributes and what they do

slate swan
vocal plover
#

that said, the actual domain is tutorial.vcokltfre.dev, vcokltfre.dev wont redirect forever

slate swan
#

lol

#

vco how much domains do you have

vocal plover
#

22

slate swan
#

bro

dense swallow
#

must be expensive

slate swan
#

how much do you pay for all of them like 100 dollars a month?

vocal plover
#

nah it equals out to something like $20/mo

slate swan
#

namecheap?

vocal plover
#

because they're yearly but half of them are short-lived shitposts I don't renew

dense swallow
#

$240/- a year 👀

vocal plover
#

it costs a hell of a lot less each year to do the domains than I spend ice skating

slate swan
#

lmao

#

what about hosting the webpages?

vocal plover
#

cloudflare pages

slate swan
#

nice

vocal plover
#

its all free

slate swan
#

noice

vocal plover
#

some stuff uses my server but I need my server anyway

#

that's a little more expensive lol

slate swan
#

vco

#

make an api that distributes goose pictures

#

or an http status goose api

#

why does my bot not work when i put it in pycharm

frozen patio
#

did you define it?

sick birch
warm tulip
#

can someone giv eme python creating discord bot doc link?

vocal plover
#

Like library docs or a tutorial?

slate swan
warm tulip
#

tutorial

vocal plover
warm tulip
#

at first i have to type import discord?

#

dude what this link is

#

i know how to create bots

#

how i can code it with python

#

??

#

i never cant make discord bots emoji_107

opal cosmos
opal cosmos
#

yeah

#

up next to the repl name does it say just python?

proper inlet
opal cosmos
#

@warm tulip can u send me fr so we can dm

warm tulip
opal cosmos
#

i cant until u do that

warm tulip
#

i adedd u

proper inlet
#

@warm tulip learn the basics of programming first (if don't know already )

frozen patio
#

I need to make a loop to go through the roles of the server, and remove them all then give the Visitor role, But I do not know how to add a loop in an event

wheat prawn
#

also you need not to do .key()

frozen patio
#

Then is the user is kicking/banning 10 members within 60 members it will remove all of its roles and give it the visitor role

unkempt canyonBOT
#

property roles```
Returns a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of the guild’s roles in hierarchy order.

The first element of this list will be the lowest role in the hierarchy.
slate swan
#

it returns a list just iterate through it

frozen patio
slate swan
#

what

slate swan
#

it returns a list? which a list is an iterable?

#

ah its for a member

#

!d discord.Member.roles

unkempt canyonBOT
#

property roles```
A [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") that the member belongs to. Note that the first element of this list is always the default [‘@everyone](mailto:'%40everyone)’ role.

These roles are sorted by their position in the role hierarchy.
slate swan
#

this is the right property

frozen patio
#

Okay

#

Now how would I put that in my event, then remove their roles and give them 1

slate swan
#

im using discord-py-interactions how would i set someone's nickname

frozen patio
#

VS Code

pure sparrow
#

oh ok that’s only the theme i didn’t know

frozen patio
#

That is the seconds count

#

from config import TOKEN

pure sparrow
#

My bad I misunderstood your question

#

For what reason you need config ?

#

yeah but what the command you want to code ?

swift crane
#

hello

pure sparrow
#

Oh I see

#

Hi nikita

swift crane
#

do you know any free host?

#

for the bot

sick birch
#

Oracle has an excellent free tier however

swift crane
#

so i don't have money

#

and i can't keep my pc 24/7 on

vocal plover
swift crane
#

so free host is only option

#

morals?

vocal plover
#

oracle isn't exactly known for being an ethical company

pure sparrow
opal cosmos
pure sparrow
#

You just have to keep your token safe

#

It’s free bro

#

you just need replit and the website

swift crane
slate swan
#

replit is not a host~

pure sparrow
#

Totally agree

pure sparrow
cloud dawn
#

If you are only planning to have the bot in 1 or 2 guilds Heroku us prob the best option since you don't need a credit card for that. As for repl.it I don't recommend using that since then you also share your IP.

slate swan
vocal plover
#

Have you considered that needing to ping a website all the time with an uptime checker doesn't make something a good host perhaps

#

A website which is, i might add, not a bot obviously

pure sparrow
slate swan
#

which you can do yourself by opening the repl in every 30 seconds or a minute

pure sparrow
#

you creat a code to keep alive your bot

vocal plover
#

No you can

vocal plover
pure sparrow
#

then you run it

cloud dawn
#

Everything regarding hosting please go to the dedicated thread.

vocal plover
#

I wonder sometimes how many of uptimerobot's checked sites are Discord bots on Replit