#discord-bots

1 messages ยท Page 1024 of 1

placid skiff
loud junco
placid skiff
#

this is the baddest spoonfeeding i've ever seen

south brook
loud junco
placid skiff
#

huahauaha yeah i'm still sleepin so

loud junco
#

LOL

#

doing logarithm exercise

#

:/

placid skiff
#

logarithm are simple

vocal plover
loud junco
#

i nvr use '

#

unless im on phone cuz it auto corrects it

#

:D

placid skiff
#

I had studied Laplace transform
(Don't search this if you care about your mental health)

loud junco
loud junco
#

people be coming !ot HEHEHEHE

#

help? @placid skiff

strong vessel
#

...

loud junco
#

:D

south brook
slate swan
#

if len(self.children) > 25:
AttributeError: 'DropdownView' object has no attribute 'children'

#

..

#

help?

strong vessel
#

idk

slate swan
# slate swan show code
class DropdownView(disnake.ui.View):
    def __init__(self,bot:commands.Bot,s : commands.Context,lips):
        self.add_item(Dropdown(bot,s,lips))
#

lips is list

#

i don't see self.childen here

#

..

#
Ignoring exception in view <Ststop timeout=30 children=3> for item <Button style=<ButtonStyle.danger: 4> url=None disabled=False label='Stop' emoji=None row=None>:
Traceback (most recent call last):
  File "C:\Users\hp\AppData\Local\Programs\Python\Python38\lib\site-packages\disnake\ui\view.py", line 370, in _scheduled_task
    await item.callback(interaction)
  File "c:\Users\hp\Desktop\bot\giveaway.py", line 399, in but2
    await interaction.response.send_message("Select one giveaway",view=DropdownView(self.bot,self.contex,list4),ephemeral=True)
  File "c:\Users\hp\Desktop\bot\giveaway.py", line 416, in __init__
    self.add_item(Dropdown(bot,s,lips))
  File "C:\Users\hp\AppData\Local\Programs\Python\Python38\lib\site-packages\disnake\ui\view.py", line 275, in add_item
    if len(self.children) > 25:
AttributeError: 'DropdownView' object has no attribute 'children'
#

and you didn't super().init()

#

oh ye

#

i removed it and forgot to add

#

it worked thanks

#

how to edit message at command?

paper sluice
#

get the message and use discord.Message.edit

slate swan
#

You already got answered @slate swan

slate swan
slate swan
#

How you made it might not be working, and we can't see your screen so we can't see your errors and your code

#

what would the buttons do?

#

thats basically what pagination means

#

changing the embed/content on reaction/interaction

#

yes, sure

#

you would like subclassing discord.ui.View

#

ill get you an example wait, what library are you using?

spring flax
#

bump

slate swan
#

2.0?

jade tartan
#

So how does the code is suppose to look?

slate swan
#

i mean your discord.py version since buttons are available only in 2.0

#

check this example, its disnake but same as discord.py

jade tartan
#
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "c:\Users\thoma\OneDrive\Desktop\discord server bot\cogs\ticket.py", line 17, in createticket
    channel_id = int(format_args[0].strip('<').strip('>').replace('*', ''))
IndexError: list index out of range``` Someone help me
#

?

paper sluice
#

looks like format_args is empty

slate swan
#

thats for reference, the implementation of buttons in discord.py and disnake is similar

#

^

#

ash, how you doing with hikari? ๐Ÿข

slate swan
#

idk why but I'm finding hikari easier to use than disnake

paper sluice
#

anime char

slate swan
#

!pip hikari

unkempt canyonBOT
slate swan
#

a non-fork api wrapper

jade tartan
paper sluice
slate swan
slate swan
slate swan
#
  • rest is awesome
#

agreed

#

and now my slash commands arent showing up for some reason....welp

jade tartan
#

I have written a comment inside this

#

Hello

slate swan
#

i have an api that returns a color code, how would i use it as an embed color. there's an error because i can't add 0x to it

#

You can just convert the color code to an integer and use that

#

But since we don't know how the color code you get looks like, we can't help

#

ff0000

#

like a normal one

#

if its a hex code you can convert it with base 16

#

Just convert to a hex

#

int("ff0000", 16)

#

Yeah ^

#

bet thanks guys

slate swan
#

is that correct

#

yes it is

dull terrace
#

can ephemerals only be used in a response to an interaction?

dull terrace
slate swan
#

ephemeral messages are only limited to slash commands and views

#

discord

stiff gorge
#
        components = [
            Button(style=ButtonStyle.URL,
                   label="Invite",
                   url="https://discord.com")]
        u = "https://discord.com"
        await ctx.send(embed=embed,
                       components=[
                           Button(style=ButtonStyle.URL, label="Invite",
                                  url=u),
                           Button(style=ButtonStyle.URL,
                                  label="Support server",
                                  url="https://discord.com")
                       ])

how do i make them in same row ?

slate swan
stiff gorge
#

yes

slate swan
stiff gorge
#

?

slate swan
#

you said you were using dpy 2.0

#

I referred you the docs

stiff gorge
#

yes but tht was not wrking

slate swan
#

....

stiff gorge
slate swan
#

hi

#

yes?

supple thorn
#

Oh yeah forgot to show something

stiff gorge
#

uhh my bot is not responding and there is no error in console wht can i do ?

uncut portal
#

Your going to have to debug it

stiff gorge
#

how ?

uncut portal
#

You just need to follow the code execution

#

I should be telling you to set break points etc and walk though you code but honestly I would (if you don't have a logging system which I suggest you add) is scatter a bunch of print statements through your code and see what is printing and what you expect to be printed match up and where they differ

slate swan
#

or an on_message event

stiff gorge
#

it is enabled

loud junco
#

how do i make an error handler for rate limite

#

its flooding my console a lot

#

how do i handle this error

slate swan
#

kill 1 in shell

stiff gorge
#

does jishaku work in dyp 2.0 ? im getting a error

#
main.py:195: RuntimeWarning: coroutine 'BotBase.load_extension' was never awaited
  bot.load_extension(f'cogs.{i}')
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
main.py:197: RuntimeWarning: coroutine 'BotBase.load_extension' was never awaited
  bot.load_extension('hangman')
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
main.py:198: RuntimeWarning: coroutine 'BotBase.load_extension' was never awaited
  bot.load_extension('jishaku')
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
loud junco
stiff gorge
#

type tht in shell

loud junco
#

ik

#

but i want an error msg

#

an error handler

slate swan
#

discord is blocking you already

#

how do you think you will handle that error

loud junco
#

hmm ok

paper sluice
spring flax
loud junco
#
@bot.event
async def on_message(message, ctx) :
  if message.channel.id == 970895283250675813 : 
    data = message.content.split(" ")
    user = re.sub("\D", "", data[4])
    print(user)
    userid = bot.get_user(str(user)) or await bot.fetch_user(str(user))
    db[userid + 'cooked_pogchop'] += 50
    db[userid + 'voteCount'] += 1
  await bot.process_commands(message) 

  voteCount = db[userid + 'voteCount']
  if voteCount < 10:
    role = ctx.guild.get_role('<@&971310924478705695>')
    await ctx.author.add_roles(role)
  elif voteCount < 18:
    role = ctx.guild.get_role('<@&971310601668288512>')
    await ctx.author.add_roles(role)
  elif voteCount < 69:
    role = ctx.guild.get_role('<@&971311031555072020>')
    await ctx.author.add_roles(role)
  elif voteCount < 100:
    role = ctx.guild.get_role('<@&971311323658977281>')
    await ctx.author.add_roles(role)
  elif voteCount < 420:
    role = ctx.guild.get_role('<@&971311024051486742>')
    await ctx.author.add_roles(role)
  else:
    role = ctx.guild.get_role('<@&971311028694577162>')
    await ctx.author.add_roles(role)
tidal hawk
#

There's no ctx argument in on_message function

#

remove it

#

And is that command inside of a class? if so then add self as first pos argument

lyric sail
#
for filename in os.listdir('./cogs'):
    if filename.endswith('.py'):
        client.load_extension(f'cogs.{filename[:-3]}')
        print(f'Loaded {filename}')

This code does load all cogs, but it loads the first and second one twice. Any reason why that might happen?

loud junco
lyric sail
#

prints

Loaded chatbot.py
Loaded fun.py
Loaded chatbot.py
Loaded fun.py
Loaded information.py
Loaded moderation.py
Loaded selfroles.py
loud junco
#
@bot.event
async def on_message(message) :
  if message.channel.id == 970895283250675813 :
    data = message.content.split(" ")
    user = re.sub("\D", "", data[4])
    print(user)
    userid = bot.get_user(str(user)) or await bot.fetch_user(str(user))
    db[userid + 'cooked_pogchop'] += 50
    db[userid + 'voteCount'] += 1
  await bot.process_commands(message) 
  
  voteCount = db[userid + 'voteCount']
  if voteCount < 10:
    role = message.guild.get_role('<@&971310924478705695>')
    await message.author.add_roles(role)
  elif voteCount < 18:
    role = message.guild.get_role('<@&971310601668288512>')
    await message.author.add_roles(role)
  elif voteCount < 69:
    role = message.guild.get_role('<@&971311031555072020>')
    await message.author.add_roles(role)
  elif voteCount < 100:
    role = message.guild.get_role('<@&971311323658977281>')
    await message.author.add_roles(role)
  elif voteCount < 420:
    role = message.guild.get_role('<@&971311024051486742>')
    await message.author.add_roles(role)
  else:
    role = message.guild.get_role('<@&971311028694577162>')
    await message.author.add_roles(role)
```bruh why is it not defined
loud junco
loud junco
#

LOL

supple thorn
loud junco
#

userid

#

but i swear to god its right there

supple thorn
loud junco
lyric sail
lyric sail
supple thorn
loud junco
tidal hawk
#

which makes it restart

supple thorn
loud junco
#

?

lyric sail
#

Earlier when there were less it used to repeat one

#

Ill look thru the files and see

supple thorn
#

What if the if statement doesn't trigger?

#

Then userid isn't defined

loud junco
#

hmm

tidal hawk
#

bruv

supple thorn
#

Also replit

#

๐Ÿ˜”

lyric sail
#

I dont see code in any other file doing it

#

Its pretty much fine its just that i have a quick training model that runs in chatbot.py and in the future I dont want it to run multiple times because it slows down startup alot

#

I added a file, and now it loads in order 1, 2, 3, 1, 2, 3, 4, 5, 6- im thinking it might have something to do with file 3 or 4

#

because it keeps restarting at that point

vale wing
#

Do you import one cog from another cog

lyric sail
#

One cog imports from the main bot.py file

#

from bot import get_servercount

#

is that why

supple thorn
#

I just realize how weird your name is

tidal hawk
#

What's weird with feet ๐Ÿ˜‹

lyric sail
#

Got rid of the training so i can see this clearly

vale wing
#

I would recommend bringing the functions several cogs use outside to some "utils" module

lyric sail
#

okay so i deleted the import and it worked normally

lyric sail
#

so does it like repeat the code in main when you import something? weird I wouldn't think that would have happened

vale wing
#

Every python file is a module basically

#

You can import functions from files

lyric sail
#

yeah i can move the function to another file and import to both main and info

#

ill try it after class its about to start lol

vale wing
#

Try to make a file with some print statement and import it from another file - the print will execute

#

So to prevent execution of certain code on import you can do this

if __name__ == "__main__":
    # your code```
heady sluice
vale wing
#

Yes

heady sluice
#

yeah you were faster

flint isle
#

Code

@bot.command(name="lnk")
async def lnk(ctx, link):
    print(ctx.message.content)
  #  assuming url as an url 
    response = requests.get(f'{link}')
    content = response.content()
    open('image.png', 'wb').write(content)

    await ctx.send(file=f'image.png')

Error:

Developed by: David Powell
Starting Bot
Connecting to Discord API.
Please Wait
Loading Developer Features cog
[โœ“][Developer Features Cog] Loading Complete
Connected!
Bot is ready!
Waiting For Commands
$lnk https://cdn.discordapp.com/attachments/798726720181633047/968876223637893210/unknown.png
Ignoring exception in command lnk:
Traceback (most recent call last):
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "<string>", line 105, in lnk
TypeError: 'bytes' object is not callable

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/discord/ext/commands/core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'bytes' object is not callable
lyric sail
#

a

vale wing
#

Bytes

lyric sail
#

okay so i put all code under that

vale wing
flint isle
vale wing
#

Not just filename

#

And yeah f-string without interpolation ๐Ÿ˜ฉ

flint isle
vale wing
#

Also why the hell f'{link}' when you can just link

vale wing
vale wing
flint isle
flint isle
vale wing
#

The fun thing about people who start python from discord bots is they cast strings like this f"{stuff}"

vale wing
#

Could you paste your full traceback to here

#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

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

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

vale wing
#

@lyric sail btw do you use tensorflow or something else for your chatbot AI?

flint isle
vale wing
#

@flint isle you don't need to call response.content

#

And yeah some improvements for your code

loud junco
#

gg error

vale wing
#
  1. Don't use requests for async apps, aiohttp exists

  2. Afaik you can just put bytes to discord.File so you don't have to save it to actual file although I am unsure about this

loud junco
#
@bot.event
async def on_ready():
  activity = discord.Game(name="RPM", type=3)
  await bot.change_presence(status=discord.Status.online, activity=activity)
  print('We have logged in as {0.user}'.format(bot))
bot.remove_command('help')

@bot.event
async def on_message(message) :
  if message.channel.id == 970895283250675813 :
    data = message.content.split(" ")
    user = re.sub("\D", "", data[4])
    userid = bot.get_user(str(user)) or await bot.fetch_user(str(user))
    print(user)
    db[userid + 'cooked_pogchop'] += 50
    db[userid + 'voteCount'] += 1
  await bot.process_commands(message) 

  voteCount = db[userid + 'voteCount']
  if voteCount < 10:
    role = message.guild.get_role('<@&971310924478705695>')
    await message.author.add_roles(role)
  elif voteCount < 18:
    role = message.guild.get_role('<@&971310601668288512>')
    await message.author.add_roles(role)
  elif voteCount < 69:
    role = message.guild.get_role('<@&971311031555072020>')
    await message.author.add_roles(role)
  elif voteCount < 100:
    role = message.guild.get_role('<@&971311323658977281>')
    await message.author.add_roles(role)
  elif voteCount < 420:
    role = message.guild.get_role('<@&971311024051486742>')
    await message.author.add_roles(role)
  else:
    role = message.guild.get_role('<@&971311028694577162>')
    await message.author.add_roles(role)
lyric sail
loud junco
lyric sail
#

neuralintents

vale wing
loud junco
#
  if voteCount < 10:
    role = message.guild.get_role('<@&971310924478705695>')
    await message.author.add_roles(role)
  elif voteCount < 18:
    role = message.guild.get_role('<@&971310601668288512>')
    await message.author.add_roles(role)
  elif voteCount < 69:
    role = message.guild.get_role('<@&971311031555072020>')
    await message.author.add_roles(role)
  elif voteCount < 100:
    role = message.guild.get_role('<@&971311323658977281>')
    await message.author.add_roles(role)
  elif voteCount < 420:
    role = message.guild.get_role('<@&971311024051486742>')
    await message.author.add_roles(role)
  else:
    role = message.guild.get_role('<@&971311028694577162>')
    await message.author.add_roles(role)
```is correct already
vale wing
#

Neural networks with text processing are hard ๐Ÿฅต

heady sluice
lyric sail
#

Yeah it sounds like a problem for future me

loud junco
#

BRUH THATS WHY I ASK

#

wait

vale wing
#

!d discord.Guild.get_role

unkempt canyonBOT
#

get_role(role_id, /)```
Returns a role with the given ID.

Changed in version 2.0: `role_id` parameter is now positional-only.
vale wing
#

It should be int bro

flint isle
vale wing
#

Don't call content

#

And don't ask me to spoonfeed

loud junco
#

what content

vale wing
#

Not you

loud junco
#

:/

vale wing
#

As for you @loud junco what error do you get except all roles are none

flint isle
heady sluice
#

() this is calling a function

#

as you put a () on content

heady sluice
#

you called content even though it isn't a function

flint isle
vale wing
#
def method():
    ...

method()  # calling method

method = 69
print(method)  # variable (in your case attribute)```
heady sluice
flint isle
vale wing
#

You get them by ID as I said above

#

And as docs say

#
guild.get_role(123456789012345678)```
heady sluice
#

and you did make sure it's 18 digits

vale wing
#

Yes ๐Ÿฅถ

heady sluice
vale wing
#

Regex made its impact

loud junco
flint isle
#

The next error I'm getting is name image is not defined

flint isle
vale wing
unkempt canyonBOT
#

ai/analyser.py lines 4 to 7

CHANNEL_REGEX = re.compile(r"<#\d{18}>")
ROLE_REGEX = re.compile(r"<@&\d{18}>")
MENTION_REGEX = re.compile(r"<@!?\d{18}>")
EMOJI_REGEX = re.compile(r"<a?:[A-Za-z0-9_]*:\d{18}>")```
vale wing
#

You didn't even pay attention to my recommendations

await ctx.send(file=discord.File(content))```
This should work although I am unsure, you should try it anyway
loud junco
#
@bot.event
async def on_message(message) :
  if message.channel.id == 970895283250675813 :
    data = message.content.split(" ")
    user = re.sub("\D", "", data[4])
    userid = bot.get_user(str(user)) or await bot.fetch_user(str(user))
    print(user)
    db[userid + 'cooked_pogchop'] += 50
    db[userid + 'voteCount'] += 1
  await bot.process_commands(message) 

  voteCount = db[userid + 'voteCount']
  if voteCount < 10:
    role = message.guild.get_role(971310924478705695)
```idk how to define userid here
#

it should be inside the blank

vale wing
#

why str

#

it is int

loud junco
#

???

vale wing
#

man cmon

loud junco
#

what are u talking about??

#

757508305256972338voteCount

#

its something like this =.=

#

u cant add int to str

vale wing
#

I mean get_user

boreal ravine
#

Don't use JSON, use a proper database

vale wing
#

Also yeah ^

loud junco
#

but how do i define userid here

loud junco
vale wing
#

Your userid is either None or User (in your case always None because you are trying to get User with str)

#

Why are you concatenating it

#

Like it's not a string

loud junco
#

so i remove the str()?

#

userid = str(bot.get_user(user) or await bot.fetch_user(user))

#

like this?

vale wing
#

Tbh I would rewrite that code by myself rn and maybe it would be better for you cause it's too difficult to explain without concrete example

boreal ravine
#

learn a programming language first, then find library you wanna use to make the bot

vale wing
#

Well it would involve much complicated stuff like verbal neural networks

boreal ravine
#

Also what exen just said

#

What

boreal ravine
#

You can't make a bot using raw HTML

vale wing
#

YEAH THE GUY THAT MADE THE BOT WITH HTML

dim tapir
#

yea defo rewrite that

#

do not use json

boreal ravine
#

Why do you need it done today?

vale wing
#

Nice idea

dim tapir
#

ah yes chat bot 1 million dabloons

vale wing
#

Well I am a pure self-learner in python programming

heady sluice
#

same

vale wing
#

And some other langs

#

I only took java classes

loud junco
heady sluice
#

same

loud junco
dim tapir
#

you cant employee people @slate swan

supple thorn
#

What

dim tapir
#

through this server

loud junco
#

wow whats the point of this
just go top.gg
find the bot u wawnt

supple thorn
#

El pupper

heady sluice
#

now he's gonna do it

dim tapir
supple thorn
#

That's worse

heady sluice
#

that he heard this

supple thorn
dim tapir
#

u said my name

vale wing
#

@supple thorn btw aias is open sourced now

supple thorn
vale wing
#

Check its bio

loud junco
#

im trying to earn

boreal ravine
#

you can

#

Most good bots have a patreon/premium system

#

well you could if you owned it

supple thorn
#

If only i can understand machine learning code

boreal ravine
#

Sure

supple thorn
#

Try it

#

I doubt you can

#

Probably

boreal ravine
#

๐Ÿ‘€

velvet compass
#

Most bots are open sourced right? I don't know many anyways

supple thorn
velvet compass
#

Yeah...ours are

supple thorn
#

Just yoinking the source code from it's github and using it

velvet compass
#

.....to click on a github link?

supple thorn
#

You just said you don't have money

supple thorn
#

What

velvet compass
#

Seems like an overall weird conversation, and probably belongs in off-topic

supple thorn
#

Sounds like you're hiring cops

velvet compass
#

What about this is about discord bots?

but i got water that makes your brain change
Also, no, our bots do not send data to the FBI, that is a ridiculous statement.

supple thorn
velvet compass
#

Thats news to me, I'd love to see the source. And again, this is off-topic for this channel.

supple thorn
#

Lmao nevermind

jade tartan
heady sluice
#

codern't donut

jade tartan
#

I have imported the right module

slate swan
#

Have you installed it?

jade tartan
#

I have installed and imported this

slate swan
#

By installing I mean the 'app' itself

#

Not just pip ...

jade tartan
#

Yes

slate swan
jade tartan
#

lol

heady sluice
#

music bots are against ToS

slate swan
#

Untrue

#

Against YouTube's ToS, not Discord

#

And there is nothing music related

#

Not 'just' youtube.

heady sluice
#

and they are grabbing music through URL arg

slate swan
#

Nope

#

Look the code they have

jade tartan
#
Windows builds by BtbN``` Which one i download
slate swan
#

No

heady sluice
#

yes I can see he is in the traceback

slate swan
#

Because it breaches the ToS of YouTube

#

Not their ToS :D

#

Nope untrue

#

Still no

heady sluice
#

so breaching ToS of youtube is ok here

velvet compass
#

Any project that knowingly breaks ToS is not going to get help here, as per rule 5

slate swan
#

Although it can be used on URLs that do allow music playing

#

e.g. their own

heady sluice
#

mmm not like his bot would check if the music played is copyrighted

slate swan
#

Yes

#

Recommended at least

velvet compass
#

Technically you could self host and leave your PC on 24/7, but I'm guessing you want a more robust solution

slate swan
#

Did the message got removed?

heady sluice
#

raspberry pi ๐Ÿ˜‹

slate swan
#

Oh nevermind, take a look at this

heady sluice
#

oh

slate swan
#

Yeah - see above, there is a list

#

None is free

heady sluice
#

nothing's free

slate swan
#

Those who are "free" are largely criticized

velvet compass
#

Nice nice

heady sluice
#

that PC's from 1980

vale wing
#

Samovar server

slate swan
#

Doesn't need to be from 2022 to run a bot

vale wing
#

On intel celeron

velvet compass
#

I have a raspberry pi w that gets the job done, but its not on at the moment since I was just testing a personal bot

vale wing
#

Raspberry pi costs too much here so I just made that thing

slate swan
#

I also used one until it used way too much network bandwidth

velvet compass
#

Also, its a x32 chipset, and there are dependencies in @lament depot / @unkempt canyon that require x64 ๐Ÿ˜”

vale wing
#

From old computer parts

heady sluice
#

buy raspberry pi
only for discord bots

stiff gorge
#
main.py:196: RuntimeWarning: coroutine 'BotBase.load_extension' was never awaited
  bot.load_extension(f'cogs.{i}')
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

how to fix this ?

heady sluice
#

await

vale wing
#

Dpy 2.0 requires asynchronous cogs/extensions management

stiff gorge
#

i dont see any place where i left await

slate swan
vale wing
#

Yeah

heady sluice
slate swan
#

You probably want to take a look at the migration guide for more information

stiff gorge
#

ok ty

buoyant zodiac
#

!d discord.Member.timeout

unkempt canyonBOT
#

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

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

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

can someone explain to me how i use the until

stiff gorge
vale wing
buoyant zodiac
#

i know that but how do i set the until

buoyant zodiac
flint isle
brittle ingot
stiff gorge
flint isle
stiff gorge
#

its not working

slate swan
#

They're using 2.0 which needs it to be awaited

stiff gorge
#
for i in (
  'connect4',
  'dev',
  'Dev',
  'economy',
  'help',
  'profile',
  'utility',
  'info',
  'image',
  'fun',
  'SubredditFetcher',
  'hangman',
  ):
    bot.load_extension(f'cogs.{i}')
flint isle
#

Ignore what I said

brittle ingot
#

make it an async for?

tough lance
#

Isn't that error because they are awaiting a coroutine outside an async function?

slate swan
#

See at # after using async_with

brittle ingot
#

oh duh. makes sense ๐Ÿคฃ been a bit since i've worked with python lmao

tough lance
#

Same

brittle ingot
#

so, off the topic of helping that person. Something appears to be missing here? bot isn't defined

# before
bot.load_extension('my_extension')

# after using setup_hook
class MyBot(commands.Bot):
    async def setup_hook(self):
        await self.load_extension('my_extension')

# after using async_with
async def main():
    async with bot:
        await bot.load_extension('my_extension')
        await bot.start(TOKEN)

asyncio.run(main())
#

would you just do:

async with MyBot as bot:

Like with aiohttp

#

oh im reading it like a working file. its just psuedo. brb lemme wake up first before i confuse people

slate swan
#

It's a migration guide not supposed to be an entirely working bot code.

#

It simply showcases the major differences between both versions, as defining a bot variable has never changed since a long time, it's not needed to add it.

#

So yeah, kind of "pseudo" but it's actual working code when you migrate.

vale wing
#

To use the async with

#

You can use it without those methods but there wouldn't be a point then

boreal ravine
#

Please don't copy code

stiff gorge
# vale wing You would need to define `__aenter__` and `__aexit__` functions of your bot clas...
File "main.py", line 201, in <module>
    asyncio.run(main())
  File "/nix/store/p21fdyxqb3yqflpim7g8s1mymgpnqiv7-python3-3.8.12/lib/python3.8/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/nix/store/p21fdyxqb3yqflpim7g8s1mymgpnqiv7-python3-3.8.12/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "main.py", line 182, in main
    async for i in (
TypeError: 'async for' requires an object with __aiter__ method, got tuple

how do i use those ?
The code is not being executed

brittle ingot
#

Idk what to tell ya. You shouldn't use JSON as a database its easily corruptible.

jade tartan
#
Cogs: 
-----------------------------
cogs.ticket was loaded.โœ…
cogs.music was loaded.โœ…
cogs.helpcmd was loaded.โœ…
Unable able to load cogs.helpcmd1โŒ
Extension 'cogs.helpcmd1' raised an error: AttributeError: module 'discord' has no attribute 'ui'
``` i have installed the module
#

Do i have to import it?

brittle ingot
#

you appear to be using it in the code, so yes you need to import it...

jade tartan
#

is it discord.ui?

slate swan
jade tartan
#

import discord.ui

#

Wdym?

#

So?

heady sluice
stiff gorge
#

type pip install git+https://github.com/Rapptz/discord.py in shell

brittle ingot
#

gotta figure out how to reinstall python on my PC. everytime i install it it never shows in VSC

slate swan
#

install the vscode python extension

#

ctrl+shift+p , select python interpreter

stiff gorge
#
File "main.py", line 201, in <module>
    asyncio.run(main())
  File "/nix/store/p21fdyxqb3yqflpim7g8s1mymgpnqiv7-python3-3.8.12/lib/python3.8/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/nix/store/p21fdyxqb3yqflpim7g8s1mymgpnqiv7-python3-3.8.12/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "main.py", line 182, in main
    async for i in (
TypeError: 'async for' requires an object with __aiter__ method, got tuple

how to fix this ? the code is not being executed

paper sluice
#

Show code

stiff gorge
#
async def main():
    async with bot:
      async for i in (
        'connect4',
        'dev',
        'Dev',
        'economy',
        'help',
        'profile',
        'utility',
        'info',
        'image',
        'fun',
        'SubredditFetcher',
        'hangman',
      ):
        await bot.load_extension(f'cogs.{i}')
        await bot.load_extension('jishaku')
        Token = os.environ['token']
        keep_alive.keep_alive()
        await bot.start(Token)
asyncio.run(main())

stiff gorge
jade tartan
#

I dont know everytime i make the first letter the capital ends up being 2 letters instead of one

stiff gorge
#

discord.ui is in 2.0

jade tartan
#

like what the hell

paper sluice
#

U can't use an async for loop on a tuple

thick basin
#

How do I handle this error

discord.errors.NotFound: 404 Not Found: Unknown interaction
stiff gorge
thick basin
#

isinstance(error, commands. Wtf should i put here)?

paper sluice
stiff gorge
thick basin
#

are you sure its for button interaction?

stiff gorge
slate swan
#

not found and bad request is completely different

slate swan
unkempt canyonBOT
#

exception discord.NotFound(response, message)```
Exception thatโ€™s raised for when status code 404 occurs.

Subclass of [`HTTPException`](https://discordpy.readthedocs.io/en/master/api.html#discord.HTTPException "discord.HTTPException")
lyric sail
#

How do I get the role id from the name

#

ex get 962189798557249597 from 'admin'

slate swan
#

!d discord.utils.get

unkempt canyonBOT
#

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

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

nvm i just had to add .mention lol

slate swan
#

@slate swan ๐Ÿ˜” help, my new slash commands aren't appearing for some reason now

slate swan
loud junco
slate swan
#

also, make sure you used the @lightbulb.implements decorator

#

i often forget that~

slate swan
loud junco
#
class Stats():
  def __init__(self, ctx):
    self.userid = str(ctx.author.id)
    self.helmet = db[self.userid  +'helmet']
    self.chestplate = db[self.userid + 'chestplate' ]
    self.leggings = db[self.userid + 'leggings']
    self.boots = db[self.userid + 'boots']
    self.sword = db[self.userid + 'sword']  
    self.hp = db[self.userid + 'hp']  
    self.level = db[self.userid + 'level']
    self.highestArea = db[self.userid + 'highestArea']
    self.atk = db[self.userid + 'atk']
    self.defend = db[self.userid + 'defend']
    self.xp = db[self.userid + 'xp']
    self.maxxp = self.level * 200
    self.area = db[self.userid + 'area']
slate swan
#

lmao

loud junco
#

what is none

slate swan
#

thats what the error says ยฏ_(ใƒ„)_/ยฏ

loud junco
#

db = None?

slate swan
#

db is None

#

yea..

loud junco
#

what on earth is this error????

slate swan
#

!e ```py
a = None
print(a[0])

unkempt canyonBOT
#

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

001 | Traceback (most recent call last):
002 |   File "<string>", line 2, in <module>
003 | TypeError: 'NoneType' object is not subscriptable
slate swan
#

this is your error.

loud junco
#

u know how to fix it?

#
@bot.event
async def on_message(message) :
  if message.channel.id == 970895283250675813 :
    data = message.content.split(" ")
    user = re.sub("\D", "", data[4])
    hehehe = str(bot.get_user(user) or await bot.fetch_user(user))
    db[hehehe + 'cooked_pogchop'] += 50
    db[hehehe + 'voteCount'] += 1

    voteCount = db[hehehe + 'voteCount']
    if voteCount < 10:
      role = message.guild.get_role(971310924478705695)
    elif voteCount < 18:
      role = message.guild.get_role(971310601668288512)
    elif voteCount < 69:
      role = message.guild.get_role(971311031555072020)
    elif voteCount < 100:
      role = message.guild.get_role(971311323658977281)
    elif voteCount < 420:
      role = message.guild.get_role(971311024051486742)
    elif voteCount >= 420:
      role = message.guild.get_role(971311028694577162)
    else:
      role = message.guild.get_role(905626727005454457)
    await message.author.add_roles(role)
  await bot.process_commands(message) 
```i added this
#

and everything is not working now

slate swan
#

where did you define db

#

ahm makes sense

loud junco
stiff gorge
#
Extension 'cogs.economy' raised an error: TypeError: Command signature requires at least 1 parameter(s)

wht does this mean ?

loud junco
#

the command signature need parameter

#

u are missing something

stiff gorge
#

it was fine till i installed 2.0

loud junco
#

read about what they added?

stiff gorge
#

ohk

loud junco
slate swan
#

yeah

#

thats fixed tho, isnt it>

loud junco
#

then why is it None

slate swan
#

!Paste paste all related code here

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.

loud junco
#

ok

slate swan
#

you already sent a response to that interaction

loud junco
#

u cant do cooldown like this

#

i show u my example

#
@bot.command(name='hunt')
@commands.cooldown(1, 30, commands.BucketType.user)
async def hunt(ctx):
```this is how i do it
slate swan
loud junco
#

huh

#

what else do u want

#

this is the error

heady sluice
#

db is NoneType

#

replit db

slate swan
#

should it be? i havent used it

loud junco
#

=.=

heady sluice
#

it seems to suck

loud junco
#

its working fine until i added

@bot.event
async def on_message(message) :
  if message.channel.id == 970895283250675813 :
    data = message.content.split(" ")
    user = re.sub("\D", "", data[4])
    hehehe = str(bot.get_user(user) or await bot.fetch_user(user))
    db[hehehe + 'cooked_pogchop'] += 50
    db[hehehe + 'voteCount'] += 1

    voteCount = db[hehehe + 'voteCount']
    if voteCount < 10:
      role = message.guild.get_role(971310924478705695)
    elif voteCount < 18:
      role = message.guild.get_role(971310601668288512)
    elif voteCount < 69:
      role = message.guild.get_role(971311031555072020)
    elif voteCount < 100:
      role = message.guild.get_role(971311323658977281)
    elif voteCount < 420:
      role = message.guild.get_role(971311024051486742)
    elif voteCount >= 420:
      role = message.guild.get_role(971311028694577162)
    else:
      role = message.guild.get_role(905626727005454457)
    await message.author.add_roles(role)
  await bot.process_commands(message) 
heady sluice
#

or it's just scoping

loud junco
#

something wrong with this?

loud junco
#

it is in the outest indent

slate swan
#

did you do db=None anywhere in the code

loud junco
#

no

#

i dont do such stupid thing

loud junco
#

easier for u lol

slate swan
#

yea

loud junco
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

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

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

heady sluice
#

self.helmet = db[self.userid +'helmet']

#

where db is None

heady sluice
#

have you tried global db in __init__

loud junco
#

but its working before i added the vote reward thing

#

i think its nothing to do with that

heady sluice
#

the traceback still shows where the error is

loud junco
#

alright

#

wont hurt to try

heady sluice
#

right

loud junco
#

where do i global it

heady sluice
#

start of __init__

loud junco
heady sluice
#

above self.userid = ...

loud junco
#

okok

slate swan
#

that should still raise undefined error, not NoneType
but worth a try

loud junco
#

not working

heady sluice
#
@bot.event
async def on_ready():
  activity = discord.Game(name="RPM", type=3)
  await bot.change_presence(status=discord.Status.online, activity=activity)
  print('We have logged in as {0.user}'.format(bot))
```told u not to do this -_-
loud junco
#

huh

#

then what i do

heady sluice
#

bot = commands.Bot(command_prefix = prefixxx, case_insensitive=True, activity=discord.Game(name="RPM", type=3))

slate swan
#
bot = commands.Bot(...., status=discord.Status.online, activity=activity)``` \:)
heady sluice
#

!d discord.ext.commands.Bot

unkempt canyonBOT
#

class discord.ext.commands.Bot(command_prefix, *, help_command=<default-help-command>, tree_cls=<class 'discord.app_commands.tree.CommandTree'>, description=None, intents, **options)```
Represents a discord bot.

This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") and as a result
anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") you can do with
this bot.

This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality
to manage commands...
loud junco
#

ok

#

replace
bot = commands.Bot(command_prefix = prefixxx, case_insensitive=True)
with
bot = commands.Bot(command_prefix = prefixxx, case_insensitive=True, activity=discord.Game(name="RPM", type=3))

heady sluice
#

docs don't show but it's online on default

loud junco
#

like this?

slate swan
#

!d discord.Client

unkempt canyonBOT
#

class discord.Client(*, intents, **options)```
Represents a client connection that connects to Discord.
This class is used to interact with the Discord WebSocket and API.

A number of options can be passed to the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client").
heady sluice
#

yes and don't change presence on_ready

slate swan
#

its inherited from here

loud junco
#

okok

slate swan
#

the **options

loud junco
#

okok

#

lemme try

slate swan
#

anyways back to the main problem

heady sluice
#

replit's bad

loud junco
#

hmm

#

btw i gtg

#

imma ask again tmr

slate swan
#

okok

loud junco
#

:D

#

byebye goodnight

slate swan
#

gn

heady sluice
atomic wolf
#

So is async to call a function from chat?

stiff gorge
#
Help on AutoShardedBot in module discord.ext.commands.bot object:

class AutoShardedBot(BotBase, discord.shard.AutoShardedClient)
 |  AutoShardedBot(*args, **kwds)
 |  
 |  This is similar to :class:`.Bot` except that it is inherited from
 |  :class:`discord.AutoShardedClient` instead.
 |  
 |  Method resolution order:
 |      AutoShardedBot
 |      BotBase
 |      discord.ext.commands.core.GroupMixin
 |      typing.Generic
 |      discord.shard.AutoShardedClient
 |      discord.client.Client
 |      builtins.object
 |  
--More--

wht is this ?

#

i got this as the error

slate swan
#

I am getting attribute error: button object has no attribute โ€˜userโ€™. When I do if interaction.user.id in my button interaction. This worked in 1.7.3 but now it doesnโ€™t

stiff gorge
cloud dawn
slate swan
#

What is owner only prefix?

slate swan
# cloud dawn 1.7.3 didn't have interaction.

See. Thats where im confused. I have a bot on 1.7.3, and It works perfectly fine with buttons, people were even confused on how I got it to work but somehow I did with the discord.ui package. But I am making a new bot now, using my old bots code as a starter and when I tried to import discord.ui it said I couldnโ€™t and everyone told me to update to 2.0. So I did and now everything is fucked up

#

And I swear to god I have a bot using 1.7.3 and it has buttons, I have been working on it for months

#

Thatโ€™s why Im so pissed I had to update for my new bot

stiff gorge
slate swan
minor totem
slate swan
slate swan
minor totem
#

It didn't work before or after you updated?

slate swan
# minor totem It didn't work before or after you updated?

When I made my new bot I copied all the code exactly. And all of the sudden it said I canโ€™t use discord.ui, even though my old bot did just fine. So everyone here told me to update to 2.0 to use buttons but now the user attribute, when I do if interaction.user.id says it doesnโ€™t exist, even though AGAIN my old bot worked perfectly

#

Can someone just answer my original question on an alternative to interaction.user.id because that dont work anymore

keen mural
#

Import discord

thick basin
#

how do i fetch list of all invite codes for a guild

lyric sail
#
if extension in ['cogs', 'extensions', 'all']:
  await ctx.send('Reloading all cogs...')
  for file in os.listdir('./cogs'):
    if file.endswith('.py'):
      client.unload_extension(f'cogs.{file[:-3]}')
      client.load_extension(f'cogs.{file[:-3]}')
      reloads = ', '.join((file))
  await ctx.send(f'Reloaded {reloads}')

Why does this send Reloaded s, e, l, f, r, o, l, e, s, ., p, y (the last cog) How can I make it send Reloaded cog1.py, cog2.py, cog3.py

thick basin
#

because of the 7th line

lyric sail
#

how do I make it add the file name and not whatever it did

#

wait im dumb i can just add it like '...' + file

slate swan
#

is their a better and updated library other than discord.py?

craggy cloak
#

How can you add that small number in my bot message?

vocal plover
slate swan
vocal plover
slate swan
#

i was using discord.py its quite decent untill it doesn't show me the errors that i'm ment to be getting

cloud dawn
#

Hi alec how are you doing :3

vocal plover
cloud dawn
#

Been awhile since i last saw you here.

cloud dawn
formal basin
#

Does anyone know how to make a whitelist channel command

E.g /whitelist #bot-commands

using json

slate swan
#

So the access_token expires in 7 days right?

cloud dawn
formal basin
slate swan
cloud dawn
#

Why would you need an access token of a user.

slate swan
craggy cloak
slate swan
cloud dawn
slate swan
#

Oh alr Smile

cloud dawn
#

Doesn't state a limit but it does have an example of how to see it.

cloud dawn
#

Maby there is a superscript in python

craggy cloak
#

ok thx

slate swan
#

how can I let my bot auto react faster?

cloud dawn
slate swan
slate swan
cloud dawn
slate swan
#

idk what u mean by "whitelisting command"

late axle
slate swan
#

@cloud dawn

formal basin
# slate swan Like enable command and disable it?

No ok letโ€™s say I enabled anti links it will delete links but what if I donโ€™t want it to Moderate a certain channel I do: โ€œ/whitelist [channel_mention]

But I want to do this using a json file

cloud dawn
#

Use View.

cloud dawn
#

Pass the view in the send, with the embed.

dawn lion
#

Give a link to the event docks

#

Give a link to the event docks

slate swan
cloud dawn
slate swan
cloud dawn
slate swan
formal basin
dawn lion
#

What?

#

!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)`...
cloud dawn
slate swan
#

๐ŸŒ

formal basin
formal basin
cloud dawn
dawn lion
#

Give a link to the event docks

cloud dawn
formal basin
dawn lion
#

event

cloud dawn
formal basin
cloud dawn
unkempt canyonBOT
#

@event```
A decorator that registers an event to listen to.

You can find more info about the events on the [documentation below](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events).

The events must be a [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine "(in Python v3.10)"), if not, [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.10)") is raised.

Example...
cloud dawn
spring verge
#

ik this is not coding related ques but I am trying to introduce a premium system but not sure if I should make it patreon based or based on something else in my discord bot

#

like anyone if having experience on this

#

then def would like to know

formal basin
dawn lion
#

exapmle on_guild_channel_create(

formal basin
dawn lion
#

thank you

cloud dawn
slate swan
#

Hello ๐Ÿ‘‹

spring verge
#

but I wanna know what do discord bots dev prefer

#

cuz there def would be a reason behind it

formal basin
slate swan
spring verge
#

json is so easy to access

slate swan
#

Ye

cloud dawn
spring verge
#

I can explain the perks

cloud dawn
spring verge
stiff gorge
#

my bot is online but its not responding to any cmnd and there is no error in console how can i fix this ??

slate swan
#

#bot-commands

cloud dawn
slate swan
#

How to fetch a role?
and get role object

cloud dawn
#

!d discord.Guild.fetch_roles

unkempt canyonBOT
#

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

Retrieves all [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") that the guild has...
slate swan
#

thanks

spring verge
paper sluice
#

what is so addictive about it ๐Ÿ˜ณ

spring verge
#

cuz if it has api etc then it should be worth it I guess :)

cloud dawn
#

!e print(3*0.95-0.15)

unkempt canyonBOT
#

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

2.6999999999999997
cloud dawn
#

And 3.4% and 0.35 for 3 euro or up.

#

!e print(10*0.966-0.35)

unkempt canyonBOT
#

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

9.31
cloud dawn
#

For 10 euro you'd keep 9.31 not including local taxes.

slate swan
cloud dawn
spring verge
#

I mean I am fine cuz at starting I wanna try with one basic only

cloud dawn
#

idk never setted this up

spring verge
#

ah

slate swan
#

Yo, does anyone know any api to get welcome cards?
Like images when someone joins.

cloud dawn
#

No everyone makes them themselves since it's specific processes heavy.

slate swan
#

How do you make them?

#

@cloud dawn

#

!e print ("lol")

unkempt canyonBOT
#

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

lol
slate swan
#

basically im making a marketplace andi wanna make a gig bot so when u do /post (name of the post) (what is it about) (price) and once u click enter it would send that infomation to a channel where people
can see it

#

how do i maake tht

slate swan
full lily
#

Do you know how to make a command?

slate swan
full lily
#

Do you have a bot set up?

slate swan
#

i tried hiring people but there all busy

slate swan
slate swan
#

i just dont know where to start

full lily
#

What discord wrapper are you using? D.py?

slate swan
full lily
slate swan
#

yh

full lily
#

I'm not sure if they have slash commands yet

hardy yoke
#

They do

cloud dawn
unkempt canyonBOT
#

@listen(name=None)```
A decorator that registers another function as an external
event listener. Basically this allows you to listen to multiple
events from different places e.g. such as [`on_ready()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_ready "discord.on_ready")

The functions being listened to must be a [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine "(in Python v3.10)").

Example...
cloud dawn
slate swan
#

can yall help me make this bot

hardy yoke
#

ppl aren't going to write a bot for you unless you pay decently enough. Learning python is your best option otherwise

slate swan
#

because i have no clue what im doing ๐Ÿ˜‚

slate swan
full lily
#

I've not done slash commands before

slate swan
#

when i use lightbulb for / commands for my discord bot, how would i make the lightbulb.option in order?

maiden fable
#

@slate swan hikari help

slate swan
#

soo what should i do then

cloud dawn
forest grotto
#

Timestamps are broken

cloud dawn
forest grotto
#

LOL

maiden fable
#

no

slate swan
#

im not gonna learn a whole language this why i dont like coming into this server

cloud dawn
forest grotto
#
import datetime

timenow = datetime.datetime.utcnow()

print(timenow)
maiden fable
#

use now() not utcnow()

cloud dawn
forest grotto
#

ah

slate swan
forest grotto
#

Thanks

slate swan
#

nobody said that all i said is can somebody help me code it not write the whole thing for me and specially when people tell u to say "learn python" is not useful

cloud dawn
slate swan
#

basically im making a marketplace and i wanna make a gig bot so when u do /post (name of the post) (what is it about) (price) and once u click enter it would send that infomation to a channel where people
can see it

#

that type of that ^^

cloud dawn
cloud dawn
slate swan
#

anyone know why my LightBulb/Hikari argument option is not in order?

#
import os

import discord
from dotenv import load_dotenv

load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')

client = discord.Client()

@client.event
async def on_ready():
    print(f'{client.user} has connected to Discord!')

client.run(TOKEN)
cloud dawn
#

@slate swan

slate swan
#

that what i got so far

cloud dawn
#

I really need to get into hikari.

slate swan
#

so yeah what should i do next? make a /command?

cloud dawn
#

What dpy version do you got installed? To see pip show discord.py

slate swan
#

who me?

cloud dawn
#

Yes

slate swan
flint isle
slate swan
#

im using replit

cloud dawn
cloud dawn
slate swan
flint isle
slate swan
slate swan
#

i did

#

its still the same for some reason

flint isle
slate swan
cloud dawn
#

Does Hikari have slash?

slate swan
slate swan
flint isle
slate swan
#

print(discord._version_)

slate swan
flint isle
slate swan
maiden fable
slate swan
slate swan
#

read the error before posting my g

#

replit has a configuration file called .replit

#

i think the default one is hidden

#

you can press the 3 dots on the file tree to show hidden files

#

and edit the .replit file to run bot.py

#

or just rename your source file

#

this to hard ima just hire somebody to make the bot for me

#

ยฏ_(ใƒ„)_/ยฏ

slate swan
flint isle
flint isle
slate swan
slate swan
#

although i'd urge you to just use something else

#

disnake has slash commands on stable

#

UI stuff too

#

A complete guide on How To Make Handlers for Slash Commands, Events, and Functions, for a Discord Bot in Discord.JS v13. This tutorial goes over how to make handlers, with explanation so new Discord.JS coders are able to learn!

Run this command to install the packages needed:
npm install @discordjs/rest discord-api-types @discordjs/builders

๐Ÿ”—...

โ–ถ Play video
#

this guy gonna teach me i have no idea what he syaing but ima just copy his code and wish for the best

#

then i have to figure out how to make a output oml ๐Ÿ˜ญ

slate swan
flint isle
slate swan
#

we only deal with python code here, but the folks over at discord.gg/djs can help

slate swan
# flint isle Hmm?

as i said, disnake has slash commands and other features rolling on stable

#

!pypi disnake

unkempt canyonBOT
slate swan
#

@cloud dawn - the first thing that comes in my mind is the codebase, hikari is better typed

  • raw hikari is about 3-4 times faster than discord.py ( for the same operations ofcourse )
  • better cache and you have full control over it
  • RESTClient ( class dealing with requests made to discord ) is completely exposed and is usable freely without breaking changes in updates. its not documented in discord.py/forks and is updated often with breaking changes
  • choice between command handlers, you can use raw hikari or choose between command handlers ( lightbulb & tanjaun being the most famous ones )
#

How to edit an embed?

slate swan
slate swan
flint isle
slate swan
slate swan
unkempt canyonBOT
#

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

Edits the message.

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

^

slate swan
#

and i suppose you're familiar with ui.View already?

slate swan
#

shit can ephemeral messages be edited? i dont remember

slate swan
#

what r u talking bout

#

well i guess you're not using ephemeral interactions if you don't know what that is

#

whatever, just create a new embed object and pass that to message.edit

#

okay let me try

#

how can i use multiple / commands in one code so that every / command is available to use?

#

wdym? just use another decorator

#

i don't understand your question

flint isle
slate swan
#

for a while discord.py got discontinued and archived

#

so multiple forks of the codebase were created and disnake is one of those

#

it's a full replacement for discord.py, you'll have to refactor some code

#

but it's basically the same thing with improvements

slate swan
# slate swan i don't understand your question

@slash.slash(name=...)
async def demandware(ctx:SlashCommand):
embed = discord.Embed()

@slash.slash(name=...)
async def ftl(ctx:SlashCommand):
embed = discord.Embed

so I just copy and paste it among themselves but I cant use the third or fourth ... / command

flint isle
#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

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

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

slate swan
#

everything should work fine

flint isle
slate swan
#

you gotta try though

#

replace all of your imports and calls to "disnake" instead of discord

#

i.e py from disnake.ext import commands

flint isle
#

i will let you know if it has issues lol. May my code be bg free

slate swan
#

@slate swan

@client.command()
async def test(ctx):
    em = discord.Embed()
    em.add_field(name='embed', value='this is an embed')
    newem = discord.Embed()
    newem.add_field(name='new embed', value='this is an new embed')
    but = Button(label='click me', style=discord.ButtonStyle.blurple)
    async def but_interaction(interaction):
        await discord.Message.edit(newem)

    view = View()
    view.add_item(but)
    but.callback = but_interaction
    await ctx.send(embed=em, view=view)

I used this but it isn't working

flint isle
slate swan
#

disnake will understand "discord" imports and forward that to the disnake class

flint isle
#

oh so then i dont need to change them

slate swan
#

however, i just recommend you to make the change so it's easy to identify

slate swan
#

but if you choose to just leave it as "discord"

flint isle
#

ok that makes sense

slate swan
#

@slash.slash(name=...)
async def demandware(ctx:SlashCommand):
embed = discord.Embed()

@slash.slash(name=...)
async def ftl(ctx:SlashCommand):
embed = discord.Embed

@slash.slash(name=...)
async def csac(ctx:SlashCommand):
embed = discord.Embed

so I just copy and paste it among themselves but I cant use the third or fourth ... / command

#

make sure you uninstall discord.py, otherwise it will conflict

flint isle
#

k

unkempt canyonBOT
#

Here's how to format Python code on Discord:

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

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

slate swan
slate swan
#

you need to store the message you sent in a variable

flint isle
slate swan
#
message = await ctx.send('thing')
await message.edit('thing 2')```
slate swan
#

secondly, unless you have the test_guilds kwarg set

#

slash commands take a while to register in discord

#

usually 30-60 minutes

#

@slate swan Thank you! It worked.

slate swan
#

What is owner only prefix?

slate swan
# flint isle please format the code
async def demandware(ctx:SlashCommand):
     embed = discord.Embed()

@slash.slash(name=...)
async def ftl(ctx:SlashCommand):
     embed = discord.Embed(
        title='Guide',
        color=6411722,
        description=''
        
         
        ) 
     embed.add_field(
          name="Snipes/Solebox/Onygo:",
          value="",
          inline=False)

@slash.slash(name=...)
async def csac(ctx:SlashCommand):
     embed = discord.Embed
#

Hello

slate swan
#

or, if you have set "owner_ids" on the bot's setup, only the users with id matching those can run the command

#

Like eval and Jishaku

#

Jishaku already uses the is_owner decorator

#

How do i get USER ID using hikari?

#

if you have your own eval function you need to add it in

#
@commands.command(name = 'eval')
@commands.is_owner()```
#
def is_owner(ctx):
    return ctx.message.author.id == ctx.guild.owner.id or ctx.message.author.id == "878892818863644693"
``` like this?
#

is_owner refers to the user that owns the application in the developer panel

#

if you want to make a special check so that server owners can run specific commands

#

that's something else

#

Ohh

slate swan
slate swan
#

what

#

Something else?

#

nothing, just use commands.check() with your own function that returns true or false

slate swan
slate swan
#

doesn't work

slate swan
slate swan
slate swan
#

or ctx.channel_id

#

Alright thanks.

#

I have this for an embed with 2 buttons, but until I press the first button, the second one doesn't work, what can I do?

    interaction1 = await bot.wait_for("button_click", check = lambda i: i.custom_id == "button1")
    await interaction1.send(embed=embed1, ephemeral=True)
    interaction2 = await bot.wait_for("button_click", check = lambda i: i.custom_id == "button2")
    await interaction2.send(embed=embed2, ephemeral=True)
slate swan
#

and how can I make only 1 with the 2 buttons?

#

just create 1 wait_for

#

I know, but how do I put it? because depending on the wait_for it sends one embed or another

south tree
#

for the webhook how i can edit an embed message?

slate swan
#

when i use guild.fetch.ban it says Guild has no attribute 'fetch'

#

its fetch_ban

#

!d discord.Guild.fetch_ban

unkempt canyonBOT
#

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

Retrieves the [`BanEntry`](https://discordpy.readthedocs.io/en/master/api.html#discord.BanEntry "discord.BanEntry") for a user.

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

oooh ty

keen mural
#

How do i make buttons gray out after clicked

slate swan
#

use that button's callback and disable the button

#

wdym by animated counting?

#

like a backwards counting ?

slate swan