#discord-bots

1 messages Β· Page 1053 of 1

potent spear
#

you should check out how commands work, on_message isn't the way to do it

sick birch
#

We don't help with music bots unfortunately, as it's in violation of TOS

potent spear
#

check out tasks in the documentation, there are basic examples

#

well, please don't through YT

hexed pagoda
potent spear
#

you need to set some goals first
instantly starting with a music bot is a steep learning curve

#

learn how to make a decent command with arguments etc first

hexed pagoda
#

i am focusing on 1 type of project cus im better in learning by doing
on the other hand i started a base base python class, but its only a programmer at the company that try to give us some knowledge :S

potent spear
formal basin
#

It’s tasks.loop

dense coral
#

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

formal basin
#

Instead of loop

potent spear
hexed pagoda
#

it should not be a music bot, it should be only an extra function in a bacis bot and i failed at some point and try to figure out but oki, i will try somewhere else
thanks anyway πŸ™‚

formal basin
potent spear
potent spear
#

send me the link as proof

potent spear
#

alright, as you can see, there's clearly a .start() method

potent spear
formal basin
#

I see a .start

#

Do I do my_loop.start()

potent spear
#

there are just people here that don't want to learn (they just want a solution to copy paste)
I'm not referring to anyone currently
I don't spoonfeed

potent spear
formal basin
#

my_loop.start()

formal basin
#

The error

#

Why won’t it send?

potent spear
#

basically, the bot's cache isn't loaded yet and you're trying to get a channel from it => this obviously results in it being None, which is why you can't send anything to it

shadow crystal
#

If u know how to make discord bots with apis dm me right now.

modern fiber
#

Dude why am I keep getting this

MessageContentPrefixWarning: Message Content intent is not enabled and a prefix is configured. This may cause limited functionality for prefix commands. If you want prefix commands, pass an intents object with message_content set to True. If you don't need any prefix functionality, consider using InteractionBot instead. Alternatively, set prefix to disnake.ext.commands.when_mentioned to silence this warning.
client = commands.Bot(intents=intents)

#

Dude anybody?

#

dude?

#

.

maiden fable
unkempt canyonBOT
maiden fable
#

Also enable it from ddevs portal

slate swan
#

How can i fix this?

maiden fable
slate swan
#

so how could i fix it?

maiden fable
#

Can u print weatherjson?

slate swan
#

1 sec

regal pulsar
#

!d disnake.ext.commands.slash_command

unkempt canyonBOT
#

@disnake.ext.commands.slash_command(*, name=None, description=None, dm_permission=None, default_member_permissions=None, options=None, guild_ids=None, connectors=None, auto_sync=None, extras=None, **kwargs)```
A decorator that builds a slash command.
slate swan
maiden fable
#

I said to print weatherjson...

slate swan
maiden fable
#

Not able to see anything, paste the output here

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
#

thats the whole output

maiden fable
#

oikay

#

Ah I got the issue

#

do weatherjson[0]["location"]

slate swan
scarlet sorrel
#

how do you make one of those buttons that does stuff when you click it?

unkempt canyonBOT
#

class discord.ui.Button(*, style=<ButtonStyle.secondary: 2>, label=None, disabled=False, custom_id=None, url=None, emoji=None, row=None)```
Represents a UI button.

New in version 2.0.
slate swan
#

I have another problem πŸ’€ Any ideas how to fix it?

#

tkinter decides to die when using discord.py, can anyone help?

scarlet sorrel
sick birch
scarlet sorrel
#

@sick birch can you give me a small example of how to add that button to a message?

sick birch
#

Look on the github examples folder

#

there are a bunch

slate swan
sick birch
#

Ah threading

scarlet sorrel
sick birch
scarlet sorrel
#

no button in that

slate swan
#

tbh i have 0 idea of dealing with threads in python but i guess i'll search?

potent spear
#

we need the FULL error traceback and also relevant code

#

.

bleak atlas
#

I need ideas for a name for a discord bot πŸ™‚

scarlet sorrel
#

@sick birch how in the world do you get a button to create a text channel, because i cant see a way to pass guild to inside the interaction

scarlet sorrel
#

i tried doing this but then realized idk how to get guild into the class

sick birch
#

use interaction

scarlet sorrel
#

arnt i?

scarlet sorrel
#

i have no clue lol

slate swan
#
import tkinter
from tkinter import messagebox
import threading
import customtkinter
from tkinter import *
import discord
from discord.ext import commands
customtkinter.set_appearance_mode("System")
customtkinter.set_default_color_theme("blue")
bot = commands.Bot(command_prefix='!')
root_tk = customtkinter.CTk()
root_tk.geometry("400x240")


async def open():
    root_tk.mainloop()

@bot.event
async def on_ready():
    messagebox.showinfo("Successfuly ran the bot!", f"{bot.user} Should be running now!")

def run():
    token = "no"
    bot.run(token)
button = customtkinter.CTkButton(master=root_tk, text="RunBot", command=run)
button.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER)
bot.loop.create_task(open())


quaint epoch
#

no not really

#

you can set a timeout tho, if no one interacts for 30 seconds lets say, edit the message, and disable the buttons

scarlet sorrel
#

how do i get the names of the guilds the client is part of?

left crater
#

isnt it discord.ButtonStyle.green

#

i dont get it

#

ur making a website but u need discord button styles?

iron sorrel
#

guys how do i use the pypresence library to give myself a custom presence?
it doesnt seem to be working for me

slate swan
#

not really something related to discord bot, you can claim a help channel maybe

#

!pip pypresence

unkempt canyonBOT
slate swan
#

did you do all the stuff mention in the example/

scarlet sorrel
#

can you get the bot to generate an invite to a sever its in?

iron sorrel
slate swan
unkempt canyonBOT
#

await create_invite(*, reason=None, max_age=0, max_uses=0, temporary=False, unique=True, target_type=None, target_user=None, target_application_id=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Creates an instant invite from a text or voice channel.

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

get any channel of that server , and create invite

scarlet sorrel
#

if you run the command from outside the server

slate swan
unkempt canyonBOT
scarlet sorrel
#

but that gives them all

slate swan
#

it returns a list

#

choose any item

iron sorrel
#

do you have just one server?

#

do you want to have a button inside ur bot to allow ppl to join ur bots server?

#

something like this

flat solstice
#

So I've got to the point in my bots code where I have a whole load of events so I was thinking about splitting the different type out into different files but keeping them grouped together in a events folder.

Should I:
A) make a folder within in my main dir (same level as my cogs folder) to store my events files
or
B) make a events subfolder in my cogs folder

zealous jay
#

How do I ask for input with discord.py slash commands?

#

Like this

#

I made that bot but I used another library, back when d.py was dead

zealous jay
visual echo
zealous jay
#

yes

slate swan
visual echo
#

are you referring to discord-py-slash-commands, which is its own library, or discord.py

zealous jay
#

@flat solstice

from pathlib import Path

target_dir = Path.cwd() / "cogs"
for cog in target_dir.rglob("*.py"):
  await self.load_extension(f"cogs.{cog.parent.name}.{cog.stem}")

This loads all .py files from all folders inside "cogs"

slate swan
unkempt canyonBOT
#

class discord.app_commands.CommandTree(client, *, fallback_to_global=True)```
Represents a container that holds application command information.
zealous jay
#

I used to use discord-py-slash-commands but with discord.py working again its better to use it

slate swan
#

ive used dislash and then used the disnake fork

#

but am kinda bored with dpy , so i use hikari now.

zealous jay
#

idk my first contact with programming was discord.py so im used to it

#

please add py at the beginning of your message

warped mirage
#

ok one sec

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.

warped mirage
#
async def on_message(message):
    if message.author.client:
        return
    author = message.author
    guild = message.guild
    async with client.db.cursor() as cursor:
       await cursor.execute("SELECT xp FROM levels WHERE user = ? AND guild = ?", (author.id, guild.id,))
       xp = await cursor.fetchone()
       await cursor.execute("SELECT xp FROM levels WHERE user = ? AND guild = ?", (author.id, guild.id,))
       level = await cursor.fetchone()

    if not xp or not level:
        await cursor.execute("INSERT INTO levels (level, xp, user, guild) VALUES (?, ?, ?, ?)", (0, 0, author.id, guild.id,))
        await client.commit()

        try: 
            xp = xp[0]
            level = level[0]
        except TypeError:
            xp = 0
            level = 0
            
        if level < 5:
            xp = random.randint(1, 3)
            await cursor.execute("UPDATE levels SET xp = ? WHERE user = ? AND guild = ?", (xp, author.id, guild.id,))
        else:
            rand = random.randint(1, (level//4))
            if rand == 1:
              xp = random.randint(1, 3)
              await cursor.execute("UPDATE levels SET xp = ? WHERE user = ? AND guild = ?", (xp, author.id, guild.id,))
        if xp >= 100:
            level += 1
            await cursor.execute("UPDATE levels SET level = ? WHERE user = ? AND guild = ?", (level, author.id, guild.id,))
            await cursor.execute("UPDATE levels SET xp = ? WHERE user = ? AND guild = ?", (0, author.id, guild.id,))
            await message.channel.send(f"{author.mention} has leveled up to level **{level}**!")
        await client.commit()```
#

my error is something to do with this if message.author.client:
return

#

an attribute error

zealous jay
#

message.author

warped mirage
#
Traceback (most recent call last):
  File "C:\Users\Dom\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\Dom\Desktop\cluckz\main.py", line 27, in on_message
    if message.author.client:
AttributeError: 'Member' object has no attribute 'client'```
#

its for my leveling system

glad cradle
#

i think it's
if message.author.id == client.user.id: return

#

you don't want that the bot trigger itself

warped mirage
#

yes

zealous jay
#

the thing is

#

message.author.client is not a thing

warped mirage
#

what about message.author.bot

zealous jay
#

no

zealous jay
#

what do you want to get

#

user's id? name?

warped mirage
#

so i dont want the bot to get levels basically if it makes sense

warped mirage
#

ok ima try it

zealous jay
#

client represents the bot

warped mirage
#

yes

zealous jay
#

so that should work

warped mirage
#

ima try

#
Traceback (most recent call last):
  File "C:\Users\Dom\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\Dom\Desktop\cluckz\main.py", line 38, in on_message
    await cursor.execute("INSERT INTO levels (level, xp, user, guild) VALUES (?, ?, ?, ?)", (0, 0, author.id, guild.id,))
  File "C:\Users\Dom\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\Dom\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\Dom\AppData\Local\Programs\Python\Python310\lib\site-packages\aiosqlite\core.py", line 129, in _execute
    return await future
  File "C:\Users\Dom\AppData\Local\Programs\Python\Python310\lib\site-packages\aiosqlite\core.py", line 102, in run
    result = function()
sqlite3.ProgrammingError: Cannot operate on a closed cursor.```
#

current error

glad cradle
#

not a dpy related error

zealous jay
#

yeah

warped mirage
#

i obvs know the error lol , idk how to fix it tho

glad cradle
warped mirage
#

ok

potent spear
#

make sure the cursor isn't closed when doing an execution..?

warped mirage
#

so u guys sure my code is fine ?

#

just the database

glad cradle
#

you are using your cursor after the "async with"

#

that's the problem

potent spear
#

let me show you

cursor = connection.cursor()
conn.execute(...)
cursor.fetchone()
cursor.close()

# executing again will ofc result in this error
cursor.fetchone()```
exotic maple
#

Why does this not get rounded?

warped mirage
glad cradle
glad cradle
warped mirage
potent spear
#

we need to see your code ofc, we can't smell yours

glad cradle
exotic maple
potent spear
#

<t:1652995200:R>

warped mirage
potent spear
warped mirage
#

I said

#

Line 38

potent spear
#

I don't see any lines ofc

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.

potent spear
#

there's no such thing as client.commit

#

it's client.db.commit()

warped mirage
#

Oh

#

Should I add client.db.commit for all my executions

#

I have a few

potent spear
#

yessir

#

don't forget the await

warped mirage
#

Ye I just gotta edit

#

I also forgot that new dpy updates

#

So codes change often

potent spear
#

that's not new

warped mirage
#

Weird

potent spear
green bluff
warped mirage
#

xD it still shows the error

#

Should I show my entire code on the web and paste link

potent spear
#

correct

warped mirage
#

Ok

green bluff
potent spear
warped mirage
#

what should i replace it with?

potent spear
#

can you look very closely at line 18 for me?

warped mirage
#

ok

#

if not xp or not level:

potent spear
#

as you can see, your if statement isn't in the context manager of the async with anymore

#

so anything starting from that line doesn't have an open cursor anymore

warped mirage
#

so how do i fix it?

potent spear
#

exactly the same issue with line 54

#

you just make sure everything's in the async with

warped mirage
#

so async with not xp or not level: ?

#

@potent spear

potent spear
#

hell no

#
async with ...:
  #shit
if ...:
  # some stuff with cursor```

fix:
```py
async with ...:
  #shit
  if ...:
    # some stuff with cursor```
warped mirage
#

so if moves forward

potent spear
#

it needs to be INSIDE the context manager

warped mirage
#

ok

potent spear
#

also, what db library are you using?

warped mirage
#

aiosqlite i think

flat solstice
potent spear
#

I think
bruh, it's your code

flat solstice
warped mirage
potent spear
#

Path.cwd() is very varying, you might wanna use Path(__file__) (the path of the current file ) and then move on from there

potent spear
flat solstice
#

how do i disconnect a member from a VC? and to do that do I need pynacl discord[voice] support?

warped mirage
potent spear
warped mirage
#

Yes

flat solstice
potent spear
warped mirage
potent spear
flat solstice
warped mirage
potent spear
warped mirage
#

Well nah I coded this like 2 weeks ago I checked the docs but I gave up ,

#

So I’m trying to fix it rn

potent spear
#

well, let me show you one difference

warped mirage
#

Ok

potent spear
#

your code
await cursor.execute("SELECT * FROM shit)

vs an aiosqlite example https://aiosqlite.omnilib.dev/en/stable/
cursor = await db.execute("SELECT * FROM shit")
let's play the game, spot the differences

warped mirage
potent spear
warped mirage
#

Lol I forgot one thing in coding is that things will be updated

potent spear
#

I added a link...

#

you should first learn how to use a db before implementing it in a command tbh

wet crystal
#

Hey,
Does anybody know how to create text like this in a discord bot?

rare saddle
#

How to display a list of missing bot rights, only without square brackets?

potent spear
wet crystal
potent spear
potent spear
torn sail
torn sail
#

Oh

rare saddle
warped mirage
#

@potent spear db is not defined

potent spear
#

in your case, it's client.db ofc

warped mirage
#

So client.db.execute?

potent spear
#

correct asf

cloud dawn
#

If db is the cursor that is...if it is then it's pretty bad naming.

potent spear
#

it's not, it's the connection

#

client.db = <connection>
at least, that's what I expect

warped mirage
#

something aint right

wet crystal
warped mirage
#

the crsor is like dark

#

as u can see

potent spear
warped mirage
#

bruh what then

potent spear
potent spear
warped mirage
#

async with aiosqlite.connect(...) as db:

#

@potent spear it still doesnt work i need help xd

potent spear
# wet crystal alr thanks

If you want the most basic example, I'll give you that

em = discord.Embed(title="yes", description="yes", url="https://google.com", timestamp=ctx.message.created_at)
em.add_field(name"bruh", value="k")
em.set_thumbnail(url="valid url")
em.set_image(url="valid url")
em.set_author(name="lol", icon_url="valid url")
em.set_footer(text="lol", icon_url="valid url")

await ctx.send(embed=em)```
#

most of these fields aren't even required

potent spear
warped mirage
#

bruh

#

can u help a man out xD

potent spear
#

try to implement it outside of discord py first, you're moving too fast
#databases
just check out the example and start from there

warped mirage
#

man im almost done

#

ill learn later but help me fix this

#

current code

potent spear
#

No, I can't write the code for you
you first of all need to learn how to do basic CRUD operations (CREATE READ UPDATE DELETE) with aiosqlite outside of dpy
AFTERWARDS you can implement it in your bot

warped mirage
#

bruh but idk whats wrong in my code

#

tell me what i need to fix

potent spear
#

you spotted the differences already...

warped mirage
#

and i fixed them

#

....

potent spear
#

you didn't

#

line 15 is EXACTLY the same as it was before

warped mirage
#

async with client.db.cursor() as cursor:

potent spear
#

you should actually make helper functions, wouldn't that be nicer in your case?

warped mirage
#

lmfao all i need help with is fixing my code

potent spear
#

so a helper functions which selects
(takes the following args)
select_from_db(db_connection, query, argument_tuple)

#

alright, if you want to keep it simple but not optimized, remove the async with

warped mirage
#

so just client.db() as cursor: ?

potent spear
#

and then just after fetching with the cursor, close it via await cursor.close()

drifting arrow
#

What's the package that makes it 'easier' to use buttons?

potent spear
#

do that for every execute thing

warped mirage
#

then it gibes error for my code

#

now this xd

potent spear
#

async with db.execute('SELECT * FROM some_table') as cursor:

warped mirage
#

level = await cursor.fetchone()

#

now this gives error

potent spear
warped mirage
#

wait

#

for async with db.execute i add client.db.execute ye?

potent spear
# warped mirage

remove the shitty client.db.cursor() as cursor line and never use it in your life ever again

warped mirage
potent spear
#

the rest is just simple indentation

async with db.execute('SELECT * FROM some_table') as cursor:
result = await cursor.fetchone()

obviously becomes

async with db.execute('SELECT * FROM some_table') as cursor:
  result = await cursor.fetchone()
warped mirage
#

Wait I have to add result = ?

potent spear
#

when fetching something, that's quite obvious

#

result or xp or whatever your thing is

warped mirage
#

Ah so xp = and level = they just need indent

slate swan
#

Which variable is responsible for deleting text in a text file?

warped mirage
#

Ye ?

potent spear
potent spear
warped mirage
#

And I remove that , indent and my entire level system will work

#

Correct ?

slate swan
austere vale
#
async def level_up(message, user):
  with open("users.json", "r") as f:
    loadJson = json.load(f)

  start_lvl = loadJson[str(user)]['level']
  end_lvl = int(loadJson[str(user)]['xp']*(1/10))
  if start_lvl < end_lvl:
    loadJson[str(user)]['level'] += 1
    loadJson[str(user)]['xp'] = 0
    loadJson[str(user)]['ssc'] += 1
    await message.channel.send(f"Oh, {message.author.mention} has leveled up to level {loadJson[str(user)]['level']}!")
  with open('users.json', "w") as f:
    json.dump(loadJson, f, sort_keys=True,indent=4, ensure_ascii=False)

anyone have an idea why sometimes my members level up to the same level multiple times?

potent spear
#

a json isn't a database

drifting arrow
#

Why are talking about databases here? ;-;

#

I wont complain if someone guides me to the right discord thing to use buttons

potent spear
drifting arrow
#

In the original one?

drifting arrow
#

in discordpy?

potent spear
#

yup

drifting arrow
#

Oh

#

i remember people saying they used a different package for buttons.

#

didnt know discordpy used buttons

potent spear
#

in the master version, they do

sick birch
#

Also most of the newer features like slash commands, modals, context menus etc

drifting arrow
#

I may need to update my discord py then πŸ€”

potent spear
#

be aware, it has breaking changes and will require a rewrite

drifting arrow
#

Thank you for the responses. Time to slap on my favorite music and figure this stuff out!

slate swan
drifting arrow
#

Yeah it broke a lot

#

hhmm

digital mason
#

Is self botting possible and is it against tos and can my account get banned if i do that

cloud dawn
#

Yes, yes, yes

digital mason
#

Does self botting mean controlling your main discord

cloud dawn
#

Yes

digital mason
#

Can it do all the things a regular bot does

#

Like on_message event and stuff

cloud dawn
#

Yes

digital mason
#

I have to find sth that's a no πŸ˜‚

cloud dawn
#

Yes

digital mason
#

Okay

#

Can i make my bot join a global server by invite link

cloud dawn
#

No

digital mason
#

Can i join that server with my main account and act like a bot

cloud dawn
#

Yes

drifting arrow
#

aahh

#

i cant figure this button shit out lol ;-;

drifting arrow
cloud dawn
digital mason
#

If i get banned does it mean i cant doscord anymore on that account

cloud dawn
#

Yes

digital mason
#

Can I delete and recreate account and do it again

drifting arrow
cloud dawn
digital mason
#

Really ?

cloud dawn
drifting arrow
#

there are examples?

cloud dawn
# digital mason Really ?

If you get banned on an account and remake one on a different name yeah, then you are avoiding the ban.

drifting arrow
#

oooo

digital mason
#

When a discord account is banned does it mean the name and discriminator cant be used anymore

cloud dawn
#

No it just means the account is unavailable.

digital mason
#

And if I delete the account can I make another one with the same name and id

drifting arrow
sick birch
digital mason
cloud dawn
drifting arrow
#

Don't get your account(s) banned.

digital mason
#

I'm not stupid lol

cloud dawn
digital mason
#

I would make an alt but not this one, I'm already too popular in many servers πŸ˜…

digital mason
sick birch
#

I'm gonna give you the benifit of the doubt and assume you meant to say you aren't planning on doing anything

drifting arrow
cloud dawn
#

lmao

rare saddle
#

How to get message.content not in on_message event

sick birch
digital mason
cloud dawn
#

I'm only popular because I give answers.

#

Otherwise ppl don't talk to me

sick birch
#

That's a good thing to be popular for

drifting arrow
cloud dawn
digital mason
drifting arrow
sick birch
#

It's better if you think about it as a learning opportunity rather than trying to get a bot out for people to use

digital mason
cloud dawn
rare saddle
#

How to get message.content not in on_message event

sick birch
drifting arrow
cloud dawn
sick birch
#

hilarious

cloud dawn
#

😏

rare saddle
sick birch
#

that sounds like something you'd wanna do in on_message

digital mason
rare saddle
cloud dawn
unkempt canyonBOT
#

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

Waits for a WebSocket event to be dispatched.

This could be used to wait for a user to reply to a message,
or to react to a message, or to edit a message in a self-contained
way...
cloud dawn
#

speed

sick birch
cloud dawn
#

Why would you ever need a yt url..?

rare saddle
digital mason
#

I have a question

cloud dawn
sick birch
#
def has_link(message: discord.Message) -> bool:
  # Use regex or something else to check for a link here
  return False

@bot.command()
async def command_name(ctx: commands.Context, ...):
  has_link = has_link()
  if has_link:
    # do something
  else:
    # do something else
digital mason
#

is it possible to ask a question and get many answers at the same time without blocking

cloud dawn
sick birch
#

i find it readable Β―_(ツ)_/Β―

unkempt canyonBOT
#

Concurrency in Python

Python provides the ability to run multiple tasks and coroutines simultaneously with the use of the asyncio library, which is included in the Python standard library.

This works by running these coroutines in an event loop, where the context of the running coroutine switches periodically to allow all other coroutines to run, thus giving the appearance of running at the same time. This is different to using threads or processes in that all code runs in the main process and thread, although it is possible to run coroutines in other threads.

To call an async function we can either await it, or run it in an event loop which we get from asyncio.

To create a coroutine that can be used with asyncio we need to define a function using the async keyword:

async def main():
    await something_awaitable()

Which means we can call await something_awaitable() directly from within the function. If this were a non-async function, it would raise the exception SyntaxError: 'await' outside async function

To run the top level async function from outside the event loop we need to use asyncio.run(), like this:

import asyncio

async def main():
    await something_awaitable()

asyncio.run(main())

Note that in the asyncio.run(), where we appear to be calling main(), this does not execute the code in main. Rather, it creates and returns a new coroutine object (i.e main() is not main()) which is then handled and run by the event loop via asyncio.run().

To learn more about asyncio and its use, see the asyncio documentation.

sick birch
#

if you wanna remove it go ahead

digital mason
#

For example I ask many riddles and whenever someone answers correctly their score is incremented

cloud dawn
digital mason
#

wait_for is blocking

heavy shard
#

java or javascript?

cloud dawn
sick birch
cloud dawn
digital mason
#

I want to make a riddle command for my bot

sick birch
#

Java forces you into OOP design patterns way more than any other language

cloud dawn
#

android studio's IDE is super sweet.

heavy shard
#

i'm procrastinating learning kotlin and android stuff for a long time now πŸ™‚

digital mason
#

With a timeout for each riddle if no one answers

#

How would you implement it

sick birch
#

!d discord.Client.wait_for

unkempt canyonBOT
#

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

Waits for a WebSocket event to be dispatched.

This could be used to wait for a user to reply to a message,
or to react to a message, or to edit a message in a self-contained
way...
cloud dawn
#

Kotlin syntax kinda threw me off, I chose java since it looks a lot like c# (i wonder why).

sick birch
#

Isn't Kotlin suggested for this sort of thing?

digital mason
sick birch
#

Pass in the timeout= kwarg

digital mason
#

The problem is that I want multiple users to play

sick birch
#
await bot.wait_for(..., timeout=60) # sets a timeout of 60 seconds
cloud dawn
digital mason
cloud dawn
digital mason
cloud dawn
#

Or a button with participate.

#

Anything works really.

digital mason
#

There was a trivia bot

#

Asks many riddles and if no one answers right after a minute it moves to the next riddle

cloud dawn
#

wait_for catches all messages.

digital mason
#

A while loop ?

cloud dawn
#

Hmm I think I would solve this using a whole lot of OOP.

digital mason
#

It's difficult you see

cloud dawn
heavy shard
#

Pandabweer: have you seen java's "Hello World Enterprise Edition"? google it, it's hilarious πŸ™‚ it's a gag code

cloud dawn
#

I got into java 2 days ago

digital mason
cloud dawn
digital mason
#

Cog ?

cloud dawn
#

You should use cogs anyhow..

digital mason
#

But how can I integrate the listener inside the command

scarlet sorrel
#

how do i do something like

for guil in bot.Guilds:
    for chan in guil.channels:
        var = chan
    invlink = await var.create_invite(xkcd=True, max_age=0, max_uses=0)
    print(invlink)

but without the 2nd loop?

cloud dawn
cloud dawn
scarlet sorrel
#

bruh

#

trying to make invites to servers?

cloud dawn
#

This has been discussed before and is inappropriate enough to not be allowed here.

cloud dawn
scarlet sorrel
#

ye

digital mason
#

Does it fall within tos too

scarlet sorrel
#

ofc it does

#

discord built it in

digital mason
#

But it's not something a server owner wants you to do

cloud dawn
# digital mason Does it fall within tos too

It doesn't break ToS since people gave permission to create invites to the bot. But it has been discussed by the regulars of this channel and staff to be deemed inappropriate due to privacy.

scarlet sorrel
#

thats kinda insane but ok

#

god forbid, public servers are public!!!

digital mason
#

True, private servers would not be private anymore

cloud dawn
scarlet sorrel
digital mason
#

What if I make an invite link on a private server my bot is in

scarlet sorrel
slate swan
#

how to make a bot delete a certain line in a txt file?

scarlet sorrel
#

if the server is private the bot cant make the link

digital mason
#

Are you sure

cloud dawn
scarlet sorrel
#

yes

slate swan
cloud dawn
sick birch
# scarlet sorrel thats kinda insane but ok

According to Discord's Developer policy,

process Discord Data in a way that surprises or violates Discord users’ expectations.
and mass-creating invites of every server your bot is in is definitely surprising, not to mention it's a very poor way to handle discord/user's data

scarlet sorrel
#

server invites are not user data

zealous jay
#

Can someone help me asking for input with a slash command using discord.py

cloud dawn
scarlet sorrel
#

and its not exactly a surprising thing to do considering that im asking

scarlet sorrel
sick birch
#

To your users, not us

digital mason
#

if I have a server and a bot sends an invite link to everyone in another server I will be mad

scarlet sorrel
#

thats not what it does at all

cloud dawn
scarlet sorrel
#

obviously...

digital mason
#

That's definitely against tos imo

cloud dawn
#

And that is exactly what we're trying to avoid.

slate swan
scarlet sorrel
digital mason
#

My bot is in 56 servers, and everyone knows me, they'll be surprised if just join their servers without their consent

slate swan
#

need help w this code

@commands.has_role('MAGIC')
async def gendaily(ctx):
    chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
    key = 'DAILY'
    for x in range(20):
      key += random.choice(chars)
    await ctx.send(key)```
i want when user doesn't have a role that it says contact the owner
```do i do it like this orr
@bot.command()
@commands.has_role('MAGIC')
async def genweek_error(ctx, error):
        if isinstance(error, commands.MissingRole):
                    await ctx.send("Error has occured please contact the owner!")```
scarlet sorrel
#

some friends

cloud dawn
digital mason
#

I am

#

I have a command that lists all servers my bot is in

#

Is it against tos

cloud dawn
#

No.

slate swan
#

thats not against the tos

digital mason
#

Ok

#

Guild name plus owner ?

#

Like knowing who made the server

slate swan
#

nope

#

i started working on discord.py today and im stuck on same problem for 5h

cloud dawn
#

It's more of when a bot just displays information like what guilds it's in or the bot giving it's owner more privileges where I would never invite those kind of bots.

slate swan
#

Can someone actually help me?

cloud dawn
digital mason
#

I dont think the command will run if you dont have the role, so your check wont trigger

cloud dawn
#

!d discord.ext.commands.Command.error

unkempt canyonBOT
#

@error```
A decorator that registers a coroutine as a local error handler.

A local error handler is an [`on_command_error()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") event limited to
a single command. However, the [`on_command_error()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") is still
invoked afterwards as the catch-all.

Changed in version 2.0: `coro` parameter is now positional-only.
wheat ether
cloud dawn
scarlet sorrel
delicate wedge
#

what the hell is happening?
whenever i run this code:

import discord
client = discord.Client()



@client.event
async def background():
   await client.wait_until_ready()
   channel = client.get_channel(CHANNEL ID))
   await channel.send("Test")

client.loop.create_task(background())


client.run(TOKEN)```

I get this error:

```sh

/usr/bin/python3 "/Users/davidspieler/Library/Mobile Documents/com~apple~CloudDocs/Docum
ents/bot.py"
Task exception was never retrieved
future: <Task finished name='Task-1' coro=<background() done, defined at /Users/davidspieler/Library/Mobile Documents/com~apple~CloudDocs/Documents/bot.py:25> exception=Forbidden('403 Forbidden (error code: 50001): Missing Access')>
Traceback (most recent call last):
  File "/Users/davidspieler/Library/Mobile Documents/com~apple~CloudDocs/Documents/bot.py", line 29, in background
    await channel.send("Test")
  File "/Users/davidspieler/Library/Python/3.8/lib/python/site-packages/discord/abc.py", line 1065, in send
    data = await state.http.send_message(channel.id, content, tts=tts, embed=embed,
  File "/Users/davidspieler/Library/Python/3.8/lib/python/site-packages/discord/http.py", line 248, in request
    raise Forbidden(r, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access

please help. i have no idea whats happening

keen mural
#

!d list

unkempt canyonBOT
#

class list([iterable])```
Lists may be constructed in several ways:

β€’ Using a pair of square brackets to denote the empty list: `[]`

β€’ Using square brackets, separating items with commas: `[a]`, `[a, b, c]`

β€’ Using a list comprehension: `[x for x in iterable]`

β€’ Using the type constructor: `list()` or `list(iterable)`...
slate swan
#

!h

slate swan
delicate wedge
#

i know I'm missing perms but i've double checked and triple checked and it doesn't look like i'm missing anything on discord's side.

slate swan
#

How do I get the bot ID?

delicate wedge
#

which one? the bot token?

slate swan
#

Yeah.

slate swan
delicate wedge
#

which is fixed by...... doing...... what exactly? sorry I have little to no experiance with making discord bots

slate swan
#

are you sure CHANNEL ID is a valid channel id

delicate wedge
#

no i just didn't want to display it to the server

slate swan
#

yes

#

import channel id

#

what do you even want to do?

#

Also are here any experts with databases and discord.py?

delicate wedge
#

i'm working on a bot that periodically sends a message to a specific channel in a server. im just working on the bot itself at the moment

delicate wedge
#

yes but first i have to make it send a message at all

#

which as you can see is whhere the problem lies

slate swan
#

you are doing it all wrong

delicate wedge
#

oh thank god

#

i was worried it was something else causing the problem. You mean the code is wrong?

slate swan
#

yeah...

#

learn the basics first

delicate wedge
#

are there any sources you recommend? it seems the one i was using is- well not working out.

lyric apex
#

How can i add *, to 2 arguements

#

It is giving erros when i do itshipit

slate swan
#

start with basics man

lyric apex
#

@slate swan

slate swan
#

send it here

lyric apex
#
@commands.has_permissions(manage_channels=True)
    async def addbutton(self, ctx, messageid:int, channel:discord.TextChannel, emoji: discord.Emoji, emojii: discord.Emoji, *, mg, *, msg):```
slate swan
#

so what exactly you trying to do

#

!e

    async def addbutton(self, ctx, messageid:int, channel:discord.TextChannel, emoji: discord.Emoji, emojii: discord.Emoji, *, mg, *, msg):```
unkempt canyonBOT
#

@slate swan :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 2
002 |     async def addbutton(self, ctx, messageid:int, channel:discord.TextChannel, emoji: discord.Emoji, emojii: discord.Emoji, *, mg, *, msg):
003 | IndentationError: unexpected indent
slate swan
#

u didnt indent

lyric apex
#

I want that the mg and msg get all arguements that is puted using

lyric apex
torn sail
lyric apex
torn sail
#

You can’t

#

Because how can 2 arguments consume all of the remaining text

lyric apex
#

With , we can separate?

slate swan
#
@commands.has_role('MAGIC')
async def genweek(ctx):
    chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
    key = 'WEEK'
    for x in range(20):
      key += random.choice(chars)
    await ctx.send(key)```
i want when i generate key using this command sends the key to database unused collum
#

but when user does

#

.redeem it removes key from that collum

keen mural
#

Hello

ctx.author.avatar_url```
would work right
slate swan
#

and after they used key it has time when it expires

sick birch
sick birch
#

But prior to that version, yes you are correct

keen mural
#

ok

slate swan
#

so lets say

keen mural
slate swan
#

makes key>>>>sends key into db collum

#

when user uses key the key expires in 1 day

cunning osprey
#

Which is the best library for discord bots? Discord.py seems so bad compared to other options such as Pycord

keen mural
#

how would i use if someone has a role or not

if ctx.author.role == "role id thing":
```?
keen mural
slate swan
#

can someone help me with dbs and discord py?

keen mural
#
mutedRole = discord.utils.get(ctx.guild.roles, name="Muted")```?
slate swan
keen mural
slate swan
#

try that

keen mural
#

from a specific guild

slate swan
#

try copying the guild id and putting it instead of the name

#

How can i manage my info using dbs

#

When i generate key using command that key goes to database

slate swan
#

Can someone help me or nah?

keen mural
#
@client.command()
async def redeem(ctx):
  guild = ctx.guild
  booster_role = discord.utils.get(guild.roles, name = 'Server Boosterγƒ»β‚ŠΛšβ€§')
  if ctx.author.role(booster_role):
    await ctx.reply("yo!")
    return
  else:
    await ctx.reply("You are not a booster my man")```
can anyone help its saying member object has no attribute role
livid hinge
slate swan
livid hinge
#

you have the table created ?

slate swan
azure nest
#

what website do i write the code in

azure nest
#

i have the bot but what platform do i execute the code in

slate swan
#

that when user redeem code

#

expires in 24h

livid hinge
#

then you would store a row with the datetime .it was created

slate swan
#

when it was used

livid hinge
#

and then if they try to use it, check that current time is no more than 24h after the creation time

slate swan
#

no no you dont get me

#

.redeem keyasgagsagsgas

keen mural
slate swan
#

key has been redeemed

azure nest
#

what website do u guys use to write the code for the bot??

slate swan
sick birch
slate swan
azure nest
slate swan
#

than they have 24h top use premium of the bor

#

bot

livid hinge
#

so what do you want to do, kick the bot ?

keen mural
#
@client.command()
async def redeem(ctx):
  guild = ctx.guild
  booster_role = discord.utils.get(guild.roles, name = 'Server Boosterγƒ»β‚ŠΛšβ€§')
  if ctx.author.role(booster_role):
    await ctx.reply("yo!")
    return
  else:
    await ctx.reply("You are not a booster my man")```
can anyone help its saying member object has no attribute role
slate swan
#

lemem explain it

#

when key has been redemmed

#

they get specific role

livid hinge
slate swan
#

and features of premium bot

azure nest
sick birch
livid hinge
#

so when the feature is used, check at that point ?

keen mural
azure nest
slate swan
#

let me explain better

#

when they redemm key

sick birch
slate swan
#

they do.role and roles are added

keen mural
slate swan
#

after 24h those roles are removed

#

or they get removed from dbs with thier ids stored

azure nest
livid hinge
keen mural
slate swan
slate swan
#

so lets make it clear,they get key,they redeem key and thier user id gets stored in db

keen mural
#

idk

slate swan
#

and if thier user id is in db they can do .role and get thier role

keen mural
#

maybe in the redeem command make the code sleep for 24h then remove role

slate swan
#

thier user id gets removed from db

keen mural
azure nest
keen mural
#

but u need more than that first

slate swan
#

@livid hinge can you help me w that?

keen mural
#

watch a yt tutorial

azure nest
keen mural
livid hinge
slate swan
#

OMFG LET ME MAKE IT CLEAR

livid hinge
#

no its ok

slate swan
#

i haven't done anything just connected db

#

They get the key

#

do .redemm key

#

and when they redeemed key thier user id gets stored in db collum

keen mural
#

await asyncio sleep?

slate swan
#

after 24h thier user id gets removed from db clooum

keen mural
slate swan
#

i don't know

keen mural
#

in the cmd where they get the role

slate swan
#

cause i have Daily,Weekly,Monthly,Lifetime key

keen mural
#

give them the role and whatever then sleep for 24h or whatever then make it remove role

slate swan
#

The role must stay

#

but thier user id needs to be removed from db

keen mural
#

ok then do that

slate swan
#

so they can't use the bot untill they renew premium feature\

#

@livid hinge is it clear rn?

#

@keen mural you got any idea how woudl i do it i'm stuck here for 3h lol

keen mural
#

u want to wait 24h then perform another action

slate swan
#

no no no no no no no no

#

Let me make it clear

#

they redeem key and they have 24h to use premium features of the bot after those 24h thier premium version of bot expires untill they get new key

stoic scarab
#

Sup guys

#
from discord.ext import commands 
bot = commands.Bot(command_prefix="!")

@bot.event 
async def on_ready():
  print("we are alive")
@bot.command()
async def hi(ctx):
  await ctx.send("bye")
  bot.run("PTY1LDU1NjImMzkxNMDQw.GlrLme.I_qLkmbLmMN8xM3wtkeTySBDCTyc75vocJ89")```
#

Does my code look ok. Also not my real token lol

keen mural
#

the concept of that

lyric apex
stoic scarab
#
from discord.ext import commands 
bot = commands.Bot(command_prefix="!")

@bot.event 
async def on_ready():
  print("we are alive")
@bot.command()
async def hi(ctx):
  await ctx.send("bye")
  bot.run("PTY1LDU1NjImMzkxNMDQw.GlrLme.I_qLkmbLmMN8xM3wtkeTySBDCTyc75vocJ89")```
lyric apex
slate swan
#

but key must be one i generated

lyric apex
#

Getting this error

stoic scarab
#

Guys is my code ok?

lyric apex
#

How do i fix itshipit

livid hinge
#

"sleep 24 hr and then remove them" is exactly the same as "wait 24h then do another action" which you said was wrong fyi

#

you either do something after 24 hours to "expire" the features (e.g. removing roles) or you don't

livid hinge
#

unless it's a fake one

slate swan
#

it removes user from db thier user id

livid hinge
stoic scarab
#

Will it work tho?

slate swan
#

but after 24h they get removed from db

livid hinge
#

it looks about right

slate swan
#

so how woudl i make that work?

livid hinge
#

i know you are frustrated but thats no reason to shout at us

stoic scarab
#

That’s tough

#

I’m just trying to make a simple bot lol

slate swan
stoic scarab
#

Anyone wanna help.

slate swan
#

and i didn't move from db connection
like i have 0 ideas

stoic scarab
#

I’ve been stuck for past 20 min

#

😫

livid hinge
#

did you try it @stoic scarab ? did it not work

stoic scarab
keen mural
#

how could i make a cooldown on a command to only certain ppl

livid hinge
#

i think you're missing something about intents probably

stoic scarab
#

Can u check idk what I’m doing tbh

slate swan
#

@livid hinge Can you help me with my problem?

stoic scarab
#
from discord.ext import commands 
bot = commands.Bot(command_prefix="!")

@bot.event 
async def on_ready():
  print("we are alive")
@bot.command()
async def hi(ctx):
  await ctx.send("bye")
  bot.run("PTY1LDU1NjImMzkxNMDQw.GlrLme.I_qLkmbLmMN8xM3wtkeTySBDCTyc75vocJ89")```
livid hinge
#

it's a non-slash command , right?

stoic scarab
stoic scarab
slate swan
stoic scarab
slate swan
#

Yeah and?

stoic scarab
#

Failing so far lol

livid hinge
#

i dont think they give you message read access by default anymore ?

slate swan
#

Whats output error

stoic scarab
#

Wanna know why it’s taking forever to load

slate swan
#

wym

#

to load ur bot to the serevr ?

stoic scarab
stoic scarab
slate swan
stoic scarab
#

Yea

#

It’s replit too

#

All I need is import discord

slate swan
#

i'ma break something rn

stoic scarab
#

Huh

stoic scarab
slate swan
stoic scarab
#

Pls pls pls pls pls pls

slate swan
#

i dont use repl

stoic scarab
#

It’s a ide not a whole new language lol

slate swan
#

@livid hinge Wanan help me or nah ?

stoic scarab
#

Help meeeee pls @slate swan

slate swan
#

whats your problem

keen mural
#

instead of yelling at people on discord

slate swan
stoic scarab
#
from discord.ext import commands 
bot = commands.Bot(command_prefix="!")

@bot.event 
async def on_ready():
  print("we are alive")
@bot.command()
async def hi(ctx):
  await ctx.send("bye")
  bot.run("PTY1LDU1NjImMzkxNMDQw.GlrLme.I_qLkmbLmMN8xM3wtkeTySBDCTyc75vocJ89")```
slate swan
stoic scarab
slate swan
stoic scarab
#

Oof

livid hinge
livid hinge
#

what output are you seeing tho

stoic scarab
stoic scarab
slate swan
stoic scarab
#

Like no out put or error

livid hinge
#

whats the actual output b/c i am not familiar with this description

keen mural
stoic scarab
#

Literally no output

#

Like none

keen mural
#

search up examples of it and learning courses

livid hinge
#

screenshot ?

stoic scarab
#

Program won’t get to that point

#

Ok wait

slate swan
stoic scarab
#

It’s been running for 3min now

slate swan
#

its repl it error

stoic scarab
#

Bruhhhhhhhhhhhhhhghhhhhhnnj

livid hinge
#

thats pretty normal I'm afraid

stoic scarab
slate swan
stoic scarab
#

Oof I saw with selenium lol

livid hinge
#

poetry slow on replit

stoic scarab
#

How’d I correct it?

#

Hold up imma use another ide then

livid hinge
keen mural
#

whats the best hosting

livid hinge
#

i edit the .replit file to disable poetry lol

keen mural
#

for small bot

slate swan
keen mural
#

do vps's ever go down

slate swan
#

yeah

#

bruhh i still haven't started on this

#

i know how to send stuff to db

livid hinge
#

speaking of which i just ran out of space on my vps today and have no idea why, i deleted tons of stuff and its still at 94% used

slate swan
#

but idk what next to do

livid hinge
#
udev              364212        0    364212   0% /dev
tmpfs              75060     5428     69632   8% /run
/dev/vda1       11582072 10316104    659884  94% /
tmpfs             375288        0    375288   0% /dev/shm
tmpfs               5120        0      5120   0% /run/lock
tmpfs             375288        0    375288   0% /sys/fs/cgroup
tmpfs              75056        0     75056   0% /run/user/0```
slate swan
#

idk how yo make that the key expires in 24h thats the problem

keen mural
#

in the command that generates the key sleep for 24h then remove the key from the database

slate swan
#

that will hold key for 24h

keen mural
#

?

#

you said a key that expires after 24h

#

do you mean on use of the key it lasts 24h

slate swan
#

yeah

#

each key must last 24h

#

i will hve multiple users using premium version of the bot

#

so i will need more than one key

#

@keen mural

keen mural
#

ok

slate swan
#

i have no idea how i woudl make that :/

#

Can someone please help me...

zealous jay
#

just in case

slate swan
#

I still have 0 ideas how woudl i make that work can someone help me or not lmao?

heavy shard
#

MagicRay: set expiration date on each key

#

and run sweeping script that every hour removes expired keys

livid hinge
#

i guess that's why the bot didn't catch it

#

looks almost real tho

heavy shard
#

it's a bit complex problem ... persistency and expiration

heavy shard
livid hinge
#

gotta admit i am curious why they would go to all the trouble of faking one instead of just writing TOKEN lol

slate swan
#

Hey greyblue

livid hinge
slate swan
heavy shard
winter meadow
#

Thanks for help me :D, i forgot give you thanks, thank you so much

#

Thanks for help me too, i also forgot give you thanks

slate swan
#

after user redeemed

#

what are you trying to make?

slate swan
#

what you define premium as can have multiple other things

slate swan
#

but it must use key system

stiff gorge
#
          now = datetime.utc.now()
          embed.set_footer(text=(datetime.now(timezone("Asia/Kolkata")).strftime('%H:%M:%S')), icon_url=self.bot.user.avatar.url)
          await channel.send(embed=embed)
ord/client.py", line 375, in _run_event
    await coro(*args, **kwargs)
  File "/home/runner/mv/cogs/dev.py", line 65, in on_command
AttributeError: module 'datetime' has no attribute 'utc'
slate swan
#

Why are you using keys, that just complicates things more. you could just add the premium users ID's to a database then check if the person running the command is in that database

slate swan
#

I see

#

and i don't want to do it all manually it woudl take time

#

i can jsut restock keys

livid hinge
#

would be cool to know that

slate swan
heavy shard
slate swan
#

Well all i want to do is

heavy shard
#

bad solution explanation: you need to maintain processes/variables that count time, and renew them at bot restart

slate swan
#

if user redeems key for 24h thier user id is 24hrs in db

slate swan
#

after 24h thier user id gets removed aand they cant use bot untill they buy a subscription

heavy shard
#

i just get brief idea of the logic of code, i have not much experience with databases...

slate swan
#

i need somehow to make key last for 24h

heavy shard
#

maybe we can figure something out... may i pm you?

slate swan
minor oriole
#

Nonetype object has no attribute

#

well this is in nextcord so can someone help me get the datetime object?

slate swan
minor oriole
#

Here comes

slate swan
torn sail
# minor oriole

Well I’m assuming that’s a slash command so the message hasn’t actually been sent yet. Use nextcord.utils.utcnow()

slate swan
keen mural
#

for py @commands.has_role("<@&926240974928228352>") how would i make it the id

dusky pine
#

just specify it

#

@commands.has_role(926240974928228352)

#

it takes a string or an int

#

if it's string, it checks name
if it's int, it checks id

#

@keen mural

keen mural
#

oh ok thx

#

πŸ˜…

upbeat vigil
#

how to i make a bots prescense dnd?

maiden fable
unkempt canyonBOT
#

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

Changes the client’s presence.

Example...
maiden fable
#

Use the status kwarg and do status=discord.Status.dnd

slate swan
#

!d discord.Status.dnd

unkempt canyonBOT
maiden fable
#

Or that, yea

sacred gull
#

is there anyone in here who can help me transform my whole help, cog help and group help command to something specific that i have in mind?

#

would be very much appreciated

sacred gull
half gale
#

How do I get channel id in py-cord? Why is discord.TextChannel not having id attribute?

azure scroll
#

code```python
def get_command_signature(self, command):
return '{0.clean_prefix}{1.qualified_name} {1.signature}'.format(self, command)

async def send_bot_help(self, mapping):
embed = discord.Embed(title="Help")
for cog, commands in mapping.items():
command_signatures = [self.get_command_signature(c) for c in commands]
if command_signatures:
cog_name = getattr(cog, "qualified_name", "No Category")
embed.add_field(name=cog_name, value="\n".join(command_signatures), inline=False)

error ```AttributeError: 'NoteBoyHelpCommand' object has no attribute 'clean_prefix'```
unkempt canyonBOT
half gale
maiden fable
vale wing
#

Why yall using format like f-strings exist

#

They are more readable imho

#

clean_prefix doesn't exist (at least I couldn't find)

#

Where would you bring it from

#

@azure scroll

#

Is it some fork

stray carbon
#

mb

warped mirage
#

can someone help me?

placid skiff
#

oh wait i read clean_params, my bad

slate swan
unkempt canyonBOT
#
Naw.

No documentation found for the requested symbol.

maiden fable
#

I knew I read that somewhere

slate swan
#

its clean_prefix

maiden fable
#

Yea

slate swan
#

πŸ’€ i don't really see its usage tho

maiden fable
#

Huh

#

Lmao

slate swan
maiden fable
#

Acc to me, isn't it literally message.content.replace("<@id>", "@name")

slate swan
#

indeed

maiden fable
#

πŸ‘€ with regex prolly

slate swan
placid skiff
#

uhm tbh Command.name retrieves the name of the command without the prefix D_D

maiden fable
#

!d discord.ext.commands.Context.clean_prefix @slate swan

unkempt canyonBOT
maiden fable
#

Weird that it isn't a method

slate swan
maiden fable
#

Hm

spring flax
#

how do I get the first, say, 100 members who joined the server?

slate swan
#
import json
import tkinter
from tkinter import messagebox
import threading
import customtkinter
from tkinter import *
import discord
from discord.ext import commands
def getprefix():
   prefix = entry2.get()
   with open('config.json', 'r') as f:
       prefixes = json.load(f)

   prefixes[str("Prefix")] = prefix

   with open('config.json', 'w') as f:  # writes the new prefix into the .json
       json.dump(prefixes, f, indent=4)

config = json.load(open('config.json'))
preshix = config.get('Prefix')
bot = commands.Bot(command_prefix=preshix)


root_tk = Tk()
root_tk.geometry("400x240")


async def open_window():
    root_tk.mainloop()

@bot.event
async def on_ready():
    print("ready")
@bot.command()
async def gay(ctx):
    await ctx.send("You are the gay")


token = "ew"

entry2 = Entry(width=25)
entry2.pack()
button2 = Button(root_tk, text="Set prefix", command=getprefix)
button2.pack()
bot.loop.create_task(open_window())
bot.run(token)``` maybe there's a way i can run both of them ?
sleek grail
#

how do you m ake a discord bot with python

unkempt canyonBOT
#

In order to work with the library and the Discord API in general, we must first create a Discord Bot account.

Creating a Bot account is a pretty straightforward process.