#discord-bots

1 messages · Page 953 of 1

hard trail
#
@unban.error
@commands.has_permissions(ban_members=True)
async def unbanerror(ctx, error):
  if isinstance(error, commands.MissingRequiredArgument):
    embed3 = nextcord.Embed(title="Missing User Requirement", description="**Next time mention the user or say their ID.**\nExample:\n$unban @viral verge for only telling people the rules", color = nextcord.Color.red())
    await ctx.send(embed=embed3)
   
  elif isinstance(error, commands.BadArgument):
    embed2 = nextcord.Embed(title="Invalid User", description="**Next time mention the user or say their ID.**\nExample:\n$unban @viral verge for only telling people the rules", color = nextcord.Color.red())
    await ctx.send(embed=embed2)
slate swan
#

Wym i dont get it

glad cradle
#

how could I make a dynamic menu with two buttons 'previous' and 'next' with callback, I would have to edit the webhook 10 times and it should go back and forth, how can I do this?

hard trail
#

It keeps giving me the Invalid user ERROR

gilded zephyr
light night
#

https://mystb.in/LectureGibsonNurse.python
I am having an issue with this as it's only editing 2 buttons and not all 3, I plan on adding selects later on, so I must remove the buttons only on this and not touch the selects

for the print

<class 'discord.ui.button.Button'>
<class 'discord.ui.button.Button'>

dpy master btw

gilded zephyr
#

Thanks

slate swan
hard trail
#

I need assistance if anybody could help

lone hare
#

doing

quaint epoch
#

nope

#

but you can just await ctx.message.delete(seconds)

#

(in on_command_error)

quaint epoch
slate swan
#

just use the delete_after kwarg

quaint epoch
#

!d disnake.Message.delete

unkempt canyonBOT
#

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

Deletes the message.

Your own messages could be deleted without any proper permissions. However to delete other people’s messages, you need the [`manage_messages`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.manage_messages "disnake.Permissions.manage_messages") permission.

Changed in version 1.1: Added the new `delay` keyword-only parameter.
slate swan
#

bro

slate swan
vale wing
#

I would done it in a more elegant way

Let's put your roles in a tuple in ascending order

roles = (nor, hc, gm)```
Then iterate through that tuple and do a simple check
```py
for i, role in enumerate(roles):
    if role in roles and role != gm:
        await user.remove_roles(role)
        await user.add_roles(roles[i+1])```
slate swan
quaint epoch
#

sorry

vale wing
#

This should work fine without those complicated condtitions

hard trail
#

Need urgent assistance here

slate swan
#

!d discord.TextChannel.send

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

Sends a message to the destination with the content given.

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

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

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

lmao

slate swan
#

mutating the children 💀

hushed galleon
light night
#
children = self.children
for child in children:
            if isinstance(child, discord.ui.Button):
                self.remove_item(child)

this?

hushed galleon
#

no that doesnt copy the list of children

#

but you can store a separate list of the buttons you're planning to remove

light night
#

🤔 but that's the list of children.

hushed galleon
#

no, itd be a separate list

slate swan
#

i wonder why the list of components are called children and not components

sly hamlet
#

So I keep on getting that queued songs are not defined but I have them globally defined

hushed galleon
#

for example py def __init__(self, ...): self.buttons = (self.secretMessage, self.dmMessage, self.denied) # when you want to remove them, iterate through this instead

light night
#

this is literatetly the same thing

hushed galleon
#

no it isnt, self.children is modified by the View superclass directly

#

so when you call remove_item while looping through children you are mutating that list at the same time

light night
hard trail
#

Why the hell is it not responding???

@bot.command(help="Moderator/Admin Command")
async def unban(ctx, user: nextcord.Member=None, *, reason=None):
  guild = ctx.guild
  myEmbed3 = nextcord.Embed(title='User Succesfully Unbanned', description = f"**{user}** has been unbanned!")
  myEmbed4 = nextcord.Embed(title=f'Unban Information for {user}', description = f"**{user.mention}** has been unbanned by Admin/Moderator: **{ctx.author.mention}** because **{reason}**")
  myEmbed4.set_footer(text=f'User ID: {user.id}')
  myEmbed5 = nextcord.Embed(title=f'Your Unban from {guild}', description = f"You were unbanned from {guild} because **{reason}**", timestamp = datetime.datetime.utcnow())
  myEmbed5.set_footer(text=f'You were unbanned by Admin/Moderator: {ctx.author}')
  if user is None:
    embed3 = nextcord.Embed(title="Missing User Requirement", description="**Next time mention the user or say their ID.**\nExample:\n$unban @viral verge for only telling people the rules", color = nextcord.Color.red())
    await ctx.reply(embed=embed3)
    
  else: 
    if ctx.author.guild_permissions.ban_members and user is not None:
      await ctx.send(embed=myEmbed3)
      await guild.unban(user=user)
      log_channel = bot.get_channel(879095317771997246)
      await log_channel.send(embed=myEmbed4)
      await user.send(embed=myEmbed5)
hushed galleon
#

assigning the list to a variable doesnt copy the list object

slate swan
#

yeah it just makes an instance of the list

#

you could do

[1, 2].copy()

or

[1, 2][:]
slim ibex
#

^

hushed galleon
#

i would still recommend explicitly defining which buttons you want to remove, offers more flexibility in the future

twin flower
#

I'm having problems with my balance command, apparently it's saying that "Result" does not have attribute "execute" and I don't know where the error's happening.

twin flower
#

I don't see where it does that tho

light night
#

I only want to remove buttons without needing to define them earlier

hushed galleon
#

well its probably on one of the lines where you write .execute inside your balance command, but preferably you should have your handler print the traceback somewhere too

twin flower
echo wasp
#

hey, yall i have a question i have a class that isn't showing up in the help command if i don't remove it why? i can add another class and it pops up just fine

slate swan
#

!d discord.Role.members

unkempt canyonBOT
lone hare
#

anyone knows how to use railway hosting

somber sky
#

what this mean

wide thunder
#

what's the recommended discord.py fork with slash commands

lone hare
#

cant run discord bot

wide thunder
#

show code

vocal plover
wide thunder
#

we can't answer without it

#

;-;

lone hare
wide thunder
#

no

lone hare
#

will send you soon sorry got something urgent right now

wide thunder
#

send here

lone hare
light night
wide thunder
#

no?

#

it doesn't have afaik

#

oh wait

#

wasn't the repo archived

somber sky
abstract kindle
#

can you reload cogs from different computers

#

or from a computer that the code is not hosted on I mean

boreal ravine
#

just use jsk to reload it

abstract kindle
#

Hmm

#

forgot I was using that. Jk, what is it?

#

JS Kabylie soccer club?

torn sail
boreal ravine
#

then do the following: ```
!jsk py await _bot.reload_extension("extension")

wide thunder
torn sail
wide thunder
#

how to use them

abstract kindle
#

wait, can I use jsk to edit code from a different computer????

abstract kindle
#

:////

wide thunder
#

btw why self.loop not working in 2.0

abstract kindle
#

I really want to run my code on my pc that's always on and edit it on my laptop

wide thunder
#

loop attribute cannot be accessed in non-async contexts...

boreal ravine
wide thunder
#

can't use async in __init__

thorn field
#

File "D:\Coding\DiscordBot\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "D:\Coding\Discord BOT\BOT.py", line 259, in warnings
warns = warns_check(member)
File "D:\Coding\Discord BOT\BOT.py", line 245, in warns_check
warns[str(member.id)]
KeyError: '772977714360483861'

thorn field
boreal ravine
#

the string isn't in the dictionary

wide thunder
boreal ravine
wide thunder
abstract kindle
#

@boreal ravine what is the difference between jsk and my own reload command?

sly hamlet
#

So I have this embed description here how can I when it is putting all the titles have them on separate lines because right now it is putting them all on one line also is it at all possible to get rid of the [] as I also show up in the final result and don't look the best?

description=f"{[x.title for x in queued_songs]}"```
thorn field
#

ret = await coro(*args, **kwargs)
File "D:\Coding\Discord BOT\BOT.py", line 259, in warnings
warns = warns_check(member)
File "D:\Coding\Discord BOT\BOT.py", line 245, in warns_check
warns[str(member.id)]
TypeError: 'int' object is not subscriptable

wide thunder
#

warns is int

feral lichen
#
@bot.command()
@commands.has_role("Franchise Owner")
async def Promote(ctx, user: discord.Member):
    guild = ctx.guild

    GM = discord.utils.get(guild.roles, name="General Manager")
    HC = discord.utils.get(guild.roles, name="Head Coach")
    Nor = discord.utils.get(guild.roles, name="Houston Texans")

    if Nor in user.roles and not HC or GM:
        await user.add_roles(HC)
        await ctx.send("Promoted to Head Coach!")

    elif HC in user.roles:   
        await user.remove_roles(HC)
        await user.add_roles(GM)
        await ctx.send("Promoted to General Manager!")

    elif GM in user.roles:
        await ctx.send("Cannot go any higher than General Manager!")
  ``` Hey I have a problem with my code if anybody can help. When I do ~Promote @ user it promotes them to head coach and its good right, but when I do it again instead of promoting to general manager it sends "Promoted to Head coach!" again and doesnt do anything. Any help?
boreal ravine
feral lichen
#

elif can only be underneath a first if statement

#

im quite sure

boreal ravine
#

change elif to if

feral lichen
boreal ravine
unkempt canyonBOT
#

Return Statement

When calling a function, you'll often want it to give you a value back. In order to do that, you must return it. The reason for this is because functions have their own scope. Any values defined within the function body are inaccessible outside of that function.

For more information about scope, see !tags scope

Consider the following function:

def square(n):
    return n*n

If we wanted to store 5 squared in a variable called x, we could do that like so:
x = square(5). x would now equal 25.

Common Mistakes

>>> def square(n):
...     n*n  # calculates then throws away, returns None
...
>>> x = square(5)
>>> print(x)
None
>>> def square(n):
...     print(n*n)  # calculates and prints, then throws away and returns None
...
>>> x = square(5)
25
>>> print(x)
None

Things to note
print() and return do not accomplish the same thing. print() will only print the value, it will not be accessible outside of the function afterwards.
• A function will return None if it ends without reaching an explicit return statement.
• When you want to print a value calculated in a function, instead of printing inside the function, it is often better to return the value and print the function call instead.
Official documentation for return

feral lichen
boreal ravine
#
async def main(ctx user):
    if condition:
        return await ctx.send("promoted to ...")

    elif HC in user.roles:
        return await ctx.send("promoted  to general manager")
``` and so on
feral lichen
slate swan
#

How is it possible to make such a welcome message?

#

!d discord.on_guild_join

unkempt canyonBOT
#

discord.on_guild_join(guild)```
Called when a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild") is either created by the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") or when the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") joins a guild.

This requires [`Intents.guilds`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.guilds "discord.Intents.guilds") to be enabled.
slate swan
#
**Hello everyone!
If you need help with command type** `!help` **to see the
command list!
Support server** `!support`

thats the format of the message if you would like to know

#

thanks

lethal bloom
#

hi

slate swan
gilded zephyr
#

Is there a way to add 'Bot is typing...' before it sends it's answer? One of my commands takes a few seconds to process

lethal bloom
#

hello, I need my bot to grant a role when they select a button but I still can't find the code error

Button = []

@bot.command()
async def button(ctx):
    await ctx.channel.send(components = [
            Button(type=2, style=ButtonStyle.1, label="Button 1")
        ])


    res = await bot.wait_for("button_click")
    if res.channel == ctx.channel:
        role = discord.utils.get(ctx.guild.roles, id = 960275258923970590)
        await res.author.add_roles(role)
        await res.respond(
            type=4,
            content=f"{res.component.label} has been clicked! This is button 1"
        )
slate swan
unkempt canyonBOT
#

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

Triggers a *typing* indicator to the destination.

*Typing* indicator will go away after 10 seconds, or after a message is sent.
gilded zephyr
#

Thanks!

lethal bloom
slate swan
#

just use main if youre using dpy

lethal bloom
#

would you tell me how?

slate swan
#

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

lethal bloom
#

ok

slate swan
lethal bloom
slate swan
lethal bloom
slate swan
#

the event only takes guilds

slate swan
lethal bloom
slate swan
#

on_guild_join is a event not a command

lethal bloom
#

a lol

slate swan
#

Clyde — Today at 7:41 PM
you pass me the command

#

its an event lmfao

lethal bloom
#

xd

slate swan
#

why even create a dm and then send a message just dm the member it will automatically make one?

#

Then this should be right or am I wrong?

#

see not a method

lethal bloom
slate swan
lethal bloom
#

?

slate swan
slate swan
#

the answer is no

slate swan
slate swan
slate swan
#

!d discord.ui.View

unkempt canyonBOT
#

class discord.ui.View(*, timeout=180.0)```
Represents a UI view.

This object must be inherited to create a UI within Discord.

New in version 2.0.
slate swan
#

just subclass this

#

theres examples on the repo

slate swan
#

!d discord.TextChannel.send

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

Sends a message to the destination with the content given.

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

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

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

is it ok for bot with 1200+ server to take more time(5 to 10 min) in start?

desert halo
#

cringe

desert halo
#

I think it should take about 40-50 seconds

#

Wellp, it depends on your database, algorithms idk

#

@lethal bloom join official discord py server to check new docs with buttons mate

#

if you want to see examples

keen lynx
desert halo
#

I understand that man

#

But I think its not okay for your bot

#

start in 10 minutes

desert halo
#

official discord py server

keen lynx
desert halo
#

you can write a formula to your bot and find out how to short your starup

lone hare
#

hi

keen lynx
lone hare
#

anyone knows how to host discord bot for free

#

?

keen lynx
lone hare
slate swan
#

no

keen lynx
#

both r bad not recommended for bot hosting

slate swan
#

replit has shared ips and heroku isnt for hosting bots

lone hare
keen lynx
lone hare
#

it ends after 10 days i guess

slate swan
keen lynx
#

its a personal bot and its fine to host small bot on platform like heroku or relpit

slate swan
#

how much guilds and members?

keen lynx
#

1 and 1

lone hare
#

i mean free trial ended e

slate swan
keen lynx
lone hare
keen lynx
#

yeah but its cheap and 6 month free if u r using gcp for first time

slate swan
#

nothing in life is freeshrug

paper sluice
slate swan
echo wasp
#

can a bot use a bot?

echo wasp
#

and how would i make an event where it listens for a message sent by bot?

#

!d discord.on_message

unkempt canyonBOT
#

discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") is created and sent.

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

Warning

Your bot’s own messages and private messages are sent through this event. This can lead cases of ‘recursion’ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
supple thorn
echo wasp
supple thorn
#

Hold on

slate swan
#

!d discord.Member.bot

unkempt canyonBOT
#

property bot```
Equivalent to [`User.bot`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.bot "discord.User.bot")
slate swan
#

returns bool just check if its true

#
if message.author.bot:
    ...
echo wasp
#
@bot.event()
async def on_message(message):
  if message.author.bot:
code```
#

something like that or bot.event

slate swan
#

no need for else just return

slate swan
supple thorn
#

😔

echo wasp
slate swan
echo wasp
slate swan
#

it would probably override the status of the instance that was runned after the other instance

silent ermine
#

How do I get all the users with a specific role? like with the role unverified

#

and does it return a list ?

slate swan
unkempt canyonBOT
silent ermine
#

ty

slate swan
#

and yes the property returns a list

echo wasp
silent ermine
slate swan
silent ermine
silent ermine
echo wasp
slate swan
#

why exactly?

echo wasp
#

and idk toml python language

slate swan
#

not a python language its a file ext

echo wasp
#

do you know how toml file works?

slate swan
#

a bit im not quite familiar

echo wasp
#

may i have the hastebin link

slate swan
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

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

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

echo wasp
supple thorn
slate swan
supple thorn
#

Damn confidence

#

Curses

slate swan
#

😔

echo wasp
#

in the toml file

slate swan
#

not really

echo wasp
#

do you know where i can find docs?

#

looks like disnake

#

@slate swan because i found this file and looks kinda like it

#

but i have no clue

slate swan
echo wasp
echo wasp
#

i din't even know if it is python all i know is it works like python with the \n thing

#

new line command

slate swan
#

How can my bot get the Hex and RGB of a given color?

sick birch
slate swan
cursive barn
# slate swan like -color red

There are a lot of shades of red each with their own hex code, do you maybe want to try giving the bot an image or reference to determine it from instead? Otherwise you have a million and one possibilities

slate swan
#

maybe try using an api that accepts names and returns hex and rgb codes

sick birch
#

If you want to do that you can define color to hex mappings

#

for example, off the top of my head, red would be FF0000

#

green, 00FF00, blue 0000FF

#

(i hope that's right)

slate swan
#

yeah you could but an api that uses a database could have way more hexcodes and color shades etc but it depends if he wants specific colors etc

#

i think im gonna try making an api with flask that uses a database

sick birch
final iron
#

ORMs?

slate swan
#

Hey

supple thorn
sick birch
supple thorn
#

i never dabbled with making APIs before but it sounds fun

sick birch
# final iron ORMs?

object relational mappings. They let you interact with databases without writing nasty SQL queries, and present returned data in nice formats

slate swan
#

horribly explained btw!

supple thorn
#

i'm not learning js today

slate swan
supple thorn
sick birch
#

For example, you might create a record in a users table in Prisma like so:

await prisma.users.create({
  first_name: "John",
  last_name: "Doe",
  age: 42,
  occupation: "database engineer"
]);
#

Much easier than writing an sql query

slate swan
#

yeah

supple thorn
sick birch
#

flask docs are good

supple thorn
#

oh god

slate swan
#

yeah just read their docs

supple thorn
#

docs my weakness

slate swan
#

its quite easy

sick birch
#

Though generally speaking javascript's paradigm is good for APIs

pliant gulch
#

Well javascript is a multi paradigm langauge

slate swan
sick birch
#

Very generally speaking of course

pliant gulch
#

Sure, depends mostly on the function of the API although

slate swan
pliant gulch
#

Like, there would be no reason to have an emitter & subscriber function or whatever, for an API that just returns random numbers

#

It would make sense however, to use emitters & subscribers for a chat based API

sick birch
#

That's a fair assesment

pliant gulch
final iron
pliant gulch
#

Yes, there is a prisma driver in python

#

!pypi prisma

unkempt canyonBOT
#

Prisma Client Python is an auto-generated and fully type-safe database client

final iron
#

Looks cool

#

I'm probably too lazy to do it

slate swan
#

did you even checked its docs💀

final iron
#

And I don't really think it would be worth it for me on such a small scale

final iron
final iron
#

It would probably be more useful on a larger scale

slate swan
supple thorn
#

🗿

slate swan
#

i mostly use html templates and load them which it kinda sucks because the debugger cant detect changes on templates but this is my page not the home one its an endpoint @supple thorn

echo wasp
#

i'm doing it rn

gilded zephyr
#

What is this error called: Converting to "float" failed for parameter "amount".

#

At first I thought it was ConversionError, but apparently not...

gilded zephyr
#

self, ctx, amount: float = 1

slate swan
gilded zephyr
#

It raises when someone inputs something thats not a number

echo wasp
#

@slate swan I did this py @bot.event async def on_message(ctx, message):
and it doesn't like ctx or message because it only takes 1 not 2 but how do i send a responce

supple thorn
#

remove ctx

echo wasp
slate swan
gilded zephyr
slate swan
supple thorn
slate swan
#

Where??

#

YT!

supple thorn
#

which channel

slate swan
#

Goto profile

#

its in my about me

gilded zephyr
slate swan
#

1 day

supple thorn
slate swan
verbal breach
#

First day in discord. Im trying to make a discord bot. Nothing is happening in the help channels i try. Through sifting on the internet i have a basic structure but its not working properly

slate swan
#

1 stream 1 day ago

slate swan
#

voice revel

slate swan
slate swan
verbal breach
#

Thank you okimii. Ill check it out.

slate swan
#

No sound stream

#

theres sound

supple thorn
#

where the hell did you find it

slate swan
#

Profile

slate swan
supple thorn
#

i just see ily in okimii's bio

slate swan
slate swan
#

Promotion

pliant gulch
#

I should stream some coding stuff too 😳

supple thorn
#

why don't i see that

pliant gulch
#

But knowing me I'd be procrastinating

supple thorn
slate swan
#

Streaming coding is useless

slate swan
#

his streams are fun to watch

slate swan
supple thorn
#

sadge i can't see the connections

pliant gulch
#

You can watch me code cursecord live

slate swan
#

that would be lovely to watch

sick birch
#

Where do you stream, andy?

slate swan
#

send link andy

pliant gulch
#

I'll probably screenshare in the rin discord

slate swan
#

we can just join from your rich status

pliant gulch
#

Youtube is evil

sick birch
#

Lmao, streaming coding on twitch "coding n chill"

supple thorn
#

why

slate swan
pliant gulch
# supple thorn why

Because I totally want to give google all my information just so I can watch cute cat videos

slate swan
#

mr proton mail smh

pliant gulch
#

I use a cli program for youtube

slate swan
#

but yes its true yt takes allot of info

#

i was looking for domains and i keep getting ads to buy domainsgopher

supple thorn
#

make false information

echo wasp
#

ok so the bot is doing it weird py @bot.event async def on_message(message): if message.author.bot: if message == "BSG Server stopped": print('Successfull') await message.channel.send('worked') and the message matches the check why is it still failing the if check

slate swan
#

illegal

slate swan
supple thorn
#

brainmon only if you're caught

echo wasp
slate swan
unkempt canyonBOT
slate swan
#

returns a string

pliant gulch
supple thorn
#

flask is fun

#

well for now

slate swan
supple thorn
#

i'll probably won't understand anything but i'll still watch

echo wasp
supple thorn
slate swan
echo wasp
#

oh

#

so compare message.content with the str

slate swan
#

yes youre comparing a string with another string

echo wasp
# slate swan yes youre comparing a string with another string

they are not kidding "Your bot’s own messages and private messages are sent through this event. This can lead cases of ‘recursion’ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that Bot does not have this problem." it is good to make 2 minute spam lol

final iron
slate swan
#

well yes? member.Bot returns bool and only checks if the account is a bot account

slate swan
gilded zephyr
#

How do I raise an error like this raise(commands.BadArgument) and add the arguments to it?

echo wasp
slate swan
slate swan
gilded zephyr
echo wasp
slate swan
gilded zephyr
#

Yeah, but then it makes it difficult to tell the user whats wrong

slate swan
#

the function has such a weird dir

final iron
#

!d discord.discord.ext.commands.on_command_error

unkempt canyonBOT
#

discord.ext.commands.on_command_error(ctx, error)```
An error handler that is called when an error is raised inside a command either through user input error, check failure, or an error in your own code.

A default one is provided ([`Bot.on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.on_command_error "discord.ext.commands.Bot.on_command_error")).
final iron
#

🗿

slate swan
final iron
gilded zephyr
#

Thats true

slate swan
slate swan
#

i know you have😳

slate swan
#

pretty simple

gilded zephyr
#

Ahhhhh

final iron
slate swan
gilded zephyr
#

I have all this for my on_command_error:

@commands.Cog.listener()
    async def on_command_error(self, ctx: commands.Context, error: commands.CommandError):
        await ctx.trigger_typing()

        if isinstance(error, commands.CommandNotFound): # CommandNotFound
            return

        elif isinstance(error, commands.CommandOnCooldown): # CommandOnCooldown
            errorName = "Command Cooldown"
            errorMessage = f"Try again in {round(error.retry_after, 1)} seconds."

        elif isinstance(error, commands.MissingRequiredArgument): # MissingRequiredArgument
            errorName = "Missing Argument"
            errorMessage = f"Argument `<{error.param}>` is missing."

        elif isinstance(error, commands.BadArgument): # BadArgument
            params = error.args[0].split('"')
            errorName = "Invalid Argument"
            errorMessage = f"Argument `<{params[3]}>` is invalid."

        else: # Unexpected
            errorName = "Unknown Error"
            errorMessage = "An unexpected error occured."
            warn(f"[!] {error}")

        errorEmbed = discord.Embed(title = errorName, description = errorMessage, color = 0xff0000)
        await ctx.reply(embed = errorEmbed, mention_author = False, delete_after = 10)
        await ctx.message.delete(delay = 10)
slate swan
final iron
slate swan
final iron
#

Check my message in akeno 🗿

slate swan
#

i didrooMonkaS

abstract kindle
#

@pliant gulch You around? I'm curious about the advice you gave me yesterday

#
class Database:
    def __init__(self, client: AsyncIOMotorClient):
        self.client = client

    async def find_one(self, collection: str, **params):
        return await self.client['discordbot'][collection].find_one(params)

I made this class so that I could have my MotorClient as a class with it's own methods so I didn't have to copy and paste the same line around everywhere to search through my DB.

#

I've added find_one, update_one, and find as methods for this class. However, if I wanted to just use one of the basic methods from the MotorClient itself, I can't anymore because I've made the client a Database object. Would I have to make all of the client methods into class methods?

#

For example, I can no longer do this

await self.bot.mongo_client['discordbot']['users'].update_many({}, {"$set": {str(field): value}})

because self.bot.mongo_client is now a Database object and doesn't have .update_many()

#

Whereas the regular motor client does have it. Would I just make a second instance of the client that's not a Database object? I don't know if that's a good idea..

verbal breach
#

my thing finally works. Holy input praise the lord it works.

slate swan
abstract kindle
#

Before I was running lines of code like this to access my DB:

await self.bot.mongo_client['discordbot']['users'].update_many({}, {"$set": {str(field): value}})
#

But it was a pain to have to put in

self.bot.mongo_client['discordbot']['users']

every time I had to access the db

#

So I wanted to do something like

db = self.bot.mongo_client['discordbot']['users']

but andy suggested I make a database class for that

pliant gulch
slate swan
#

yes its a good idea

abstract kindle
#

I see...

#

So for one off lines that won't be replicated often I just do that

#

but for everything else, I should make class methods?

slate swan
#

why would you have a classmethod to return a db object?

abstract kindle
#

I'm not the best at python, but here's what I've got so far

#
class Database:
    def __init__(self, client: AsyncIOMotorClient):
        self.client = client

    async def find_one(self, collection: str, **params):
        return await self.client['discordbot'][collection].find_one(params)

    async def update_one(self, collection: str, search_key, search_value, mode, **params):
        return await self.client['discordbot'][collection].update_one({search_key: search_value}, {mode: params})

    async def find(self, collection: str, value: str, sort_order, limit: int):
        if sort_order == "descending":
            return self.client['discordbot'][collection].find().sort(value, pymongo.DESCENDING).limit(limit)
        elif sort_order == "ascending":
            return self.client['discordbot'][collection].find().sort(value, pymongo.ASCENDING).limit(limit)
#

This is my Database class, and I have that because I use those often

slate swan
#

ok

abstract kindle
#

It's been a bit of a hassle tbh

#

Cause like these are basically the default MotorClient methods, I just have them as class methods so I don't have to type the ['discordbots']['users'] every time. Should I be doing something different?

#

At the end of the day, I want to code efficiently

slate swan
#

i see no classmethods in your Database class

abstract kindle
#

I'm probably using the wrong word

slate swan
#

yeah because classmethods is a method that affects the class and not instances

abstract kindle
#

I'm just a freshman in college, I've been teaching myself python

#

I see. Then those would just be methods?

slate swan
#

im a freshmen in highschool lol

abstract kindle
#

Welp

#

Everyone has their journey

slate swan
abstract kindle
#

Either way. Is what I'm doing efficient?

slate swan
sick birch
#

I don't see anything inherently wrong with it.

abstract kindle
#

Just so I don't have to keep writing ['discordbots']['users'] every time

slate swan
#

ah

abstract kindle
#

I'd rather just store that as a variable

#

Instead of making an entire class for it

sick birch
abstract kindle
#

If I have code that runs a simple game and I update a value in the database many times, should I just use the basic method that comes with the Client?

#

Because those can get quite lengthy

sick birch
#

What basic methods are we talking about?

abstract kindle
#

Sorry for my terminology

#

But stuff like this

await self.bot.mongo_client['discordbot']['users'].update_many({}, {"$set": {str(field): value}})
sick birch
#

Ah. I'm guessing you made mongo_client a bot var yourself?

pliant gulch
#

You could make a low-level method as well

abstract kindle
#

yes

#
async def main():
    with open('./data.json', 'r') as file:
        data = json.load(file)

    async def hook():
        bot.mongo_client = Database(AsyncIOMotorClient(data['mongo_url']))

    bot.setup_hook = hook
pliant gulch
#
class Foo:
    db: AsyncIOMotorClient

    async def query(self, col: str, function: str, **kwargs: Any) -> None:
        function = getattr(self.db[col], function)
        await function(kwargs)
```some pseudo-code
sick birch
pliant gulch
#

Would basically mean, ```py
await Foo().query("users", "update_many", foo=bar)

#

Actually, that doesn't make it much better

abstract kindle
#

Not sure, that was recommended to me to solve my problem, I'm still new to code.

sick birch
#

And yeah, I see you made a custom class wrapping motor

pliant gulch
#

Probably shouldn't do that

sick birch
abstract kindle
#

Issue is the **kwargs thing. I would have a hard time figuring out how to query the database with parameters

pliant gulch
#

Hell, if you only want to just shorten accessing the column couldn't you just do bot.mongo_client = AsyncIOMotorClient["discordbot"]?

abstract kindle
#
await self.bot.mongo_client['discordbot']['users'].update_many({}, {"$set": {str(field): value}})

in this, it's much easier for me to write out {"$set": {str(field): value}} than it is for me to try and do that with parameters

abstract kindle
abstract kindle
#

Like I can edit them but it asks me if I really want to first lol

slate swan
sick birch
#
class MyBot(commands.Bot):
  def __init__(...):
    ...
  async def setup_hook(...):
    ...
#

You can move everything from your main() to there

#

Including

    with open('./data.json', 'r') as file:
        data = json.load(file)
abstract kindle
#

Ahh I'm such a noob still. I also have code for checking / reloading cogs in my main file. That's probably a bad thing isn't it.

sick birch
#

Nah. Nothing really wrong with that

abstract kindle
#

I see most open source bots have really small main.py files

sick birch
#

Actually, one could argue putting critical functionality like cog reload unloading in your main file is a better way to organize thing

abstract kindle
#

I figured I can't reload Cogs if the code to do so is in a Cog

sick birch
#

Hence the checking?

#

To make sure the cog that unloads reloads other cogs isn't unloaded

abstract kindle
#

Yeah lol. Not sure what other option there is

sick birch
#

Move that out of an extension, that way it can't be unloaded or reloaded

abstract kindle
#

I'm basically just lookin for the easiest way to query my database without having long long lines of code like this

user_in_database = await self.bot.mongo_client['discordbot']['users'].find_one({"_id": ctx.author.id})```
sick birch
#

Does all of your queries have the discordbot users part?

abstract kindle
#

And they get even longer when using stuff like ['update_many']

#

For the most part yes. I only use one database and one whatever you call it. Collection?

sick birch
#

Hm. You could just put that in a variable, I'm sure you've thought of that already

#
x.find_one(...)
abstract kindle
#

Yeah. However, I tried putting the whole ```py
await self.bot.mongo_client['discordbot']['users']

in a variable, and it said that a coroutine object doesn't have attribute `find_one()`
#

Maybe that's a me issue

sick birch
#

Hmm

#

.find_one() is the coroutine

#

Not mongo_client

abstract kindle
#

So I wouldn't put await in the variable?

sick birch
#

No

abstract kindle
#

And then I would just do await x.find_one(...)

sick birch
#

You got it

abstract kindle
#

I'll try it. Then I wouldn't need this entire Database class

#

Where would I put that variable? If it's in a Cog let's say

#

I wouldn't put it in each command, right?

sick birch
#

Best to bind it to your bot instance

abstract kindle
#

Ah, in the main file?

sick birch
#

Right

#

self.bot.x.find_many()

#

Still kind of long but better than before

#

If you want to shorten it even more you could create a custom context and do it that way

#

ctx.db.find_many()

abstract kindle
#

Yeah I was just gonna say it's still self.bot.x

#

Custom context?

sick birch
#

Yes. The ctx provided to you on commands can be modified to your liking

abstract kindle
#

Where would I modify that?

sick birch
#

!d discord.Role.members

unkempt canyonBOT
sick birch
#

What's up?

#

Well, what are you trying to do?

#

That's the best way to do it, better learn

#

Oh. Yeah, just use that property then

#

Tutorials on reading docs... can't think of any. It's a skill you pick up as you go

slate swan
#

!e

class D:
    def __init__(self, *indexes: tuple[int, int]) -> None:
        self.index0, self.index1 = indexes
    
    def get_data(self) -> int:
        return {1: {2: 3}}[self.index0][self.index1]

print(D(1, 2).get_data())

@abstract kindle is this how you would like your class to be or what exactly would you like?

unkempt canyonBOT
#

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

3
abstract kindle
#

Interesting. So it would look like

class MyContext(commands.Context):
  self.x = bot.mongo_client['discordbot']['users']

and then I just set my bot to use this context instead?

sick birch
#

Not quite. You need functions

#

No offense to you, but memorizing is one of the worst ways to learn

abstract kindle
#

Mm. Also would this overwrite the normal ctx? cause that is something I use often..

abstract kindle
#

Oh cool!

lament mesa
#

What is this new modal thing?

#

are there any videos demonstrating it?

abstract kindle
#

@sick birch If I was to just go with the self.bot.x.find_one(...) route, would I put the assignment for that variable under the hook() thing I had?

#

I don't want to overcomplicate things too soon for myself, I find that it adds multiple hours of coding and trying to figure out what I did wrong and I never get what I initially planned to done.

sick birch
verbal breach
#

ok, so i got my bot to work. I want it to be able to take links as input from messages. I see solutions for how to scan if there IS a link in a message. But i want to be able to take those links from messages and store them in a variable for further use. Any thoughts?

abstract kindle
#

Does that subclass go in main? Do people usually put it there? or would they have it in a class library file?

#

Or did I make up class library files lmao

sick birch
#

It can go in main. It makes sense to put it in main anyway

abstract kindle
#

Probably under imports like that example showed

sick birch
#

If you want to, however, you can have a bot.py file containing the subclass. In main.py, import the subclass, instantiate it, and run it

#

That way your main file will be around 3 or 4 lines

abstract kindle
#

That includes all of my Cog reloading stuff too?

verbal breach
#

My bot being able to take entire links and only the links from messages is the most crucial part of it.

sick birch
#

Ehhhh

#

Doesn't make sense to put cog reloading in bot.py

abstract kindle
#

Okay

sick birch
verbal breach
#

hm , whats the methods/properties and how do i use them?

sick birch
#

The re library, and specifically the match() function

vale wing
#

You need to learn regex generally first I'd say

sick birch
verbal breach
#

So uh. Where do i start with that?

vale wing
#

Hell

sick birch
#

Thank me later for saving you the pain of learning regex

#

I wouldn't wish it on my worst enemy

slate swan
sick birch
#

Did I?

slate swan
sick birch
#

Oh. My sincerest apologies 😦

verbal breach
#

can you gave a small coding sample of how it would fit into some code? Im still baby cheeks new at this…

slate swan
vale wing
#

@verbal breach if you just need to extract link use the pattern @sick birch sent, if you would want to learn about regex more, you can use this resource https://www.w3schools.com/python/python_regex.asp

slate swan
#

i hate w3 school

#

its explanations are horrible

vale wing
#

What's so bad about it

slate swan
#

i personally use it sometimes but its not a good source at all

sick birch
slate swan
#

yes

verbal breach
#

first time w3 helped with it’s example.

vale wing
#

When I was learning regex I went to official docs first too and didn't understand a single thing so uh preference

vocal laurel
#

anyone know hot to do slash commands or just commands with sapces?

sick birch
#

Not possible

vocal laurel
#

can i dm u smth

sick birch
#

It's not possible to have commands with spaces in them. Unless you're talking about groups or subcommands

vocal laurel
#

cuz i cant send here

vale wing
#

Unless you do a bunch of subcommands but that would be weird

sick birch
#

Why not?

vocal laurel
#

its an image

sick birch
#

Still should be able to send images here

vale wing
#

However message and user commands names can contain spaces

vocal laurel
#

here

sick birch
#

That's a subcommand

vocal laurel
#

oh

verbal breach
#
@client.event
async def on_message(message):
  txt = message.content
  x = re.search("http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+", txt)
  link = (requests.get(x).text)
vocal laurel
#

how to do?

verbal breach
#

is this code viable?

sick birch
#

Should be

#

Give it a whirl

verbal breach
#

puggin’

vocal laurel
#

whirl?

vale wing
supple thorn
vale wing
#

I might be confusing it so try it out by yourself

supple thorn
#

that's what "give it a whirl" mean

vocal laurel
abstract kindle
#

thanks for helping me out Robin

vale wing
#

And yeah don't use requests in an async application, you can use aiohttp

vocal laurel
#

so how to do sub commands with spaces?

vale wing
#

!d discord.ext.commands.Bot.group

unkempt canyonBOT
#

@group(*args, **kwargs)```
A shortcut decorator that invokes [`group()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.group "discord.ext.commands.group") and adds it to the internal command list via [`add_command()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin.add_command "discord.ext.commands.GroupMixin.add_command").
verbal breach
#

Do I literally just replace requests with aiohttp or do i have to do more.

vale wing
#

A bit of more

vocal laurel
#
@client.command()
async def help_moderation(ctx):
#

see i want to get rid of the underscore

verbal breach
#

ill try requests anyway

vale wing
#

Check the client quickstart in their docs, I think you will get what you need to change

verbal breach
#

i just have to attach my existing program to it.

vocal laurel
#

so how to get rid of underscore?

verbal breach
#

i hope my ipad doesnt explode in my face.

slate swan
vale wing
vale wing
#

Although you'd better sublcass the help

bitter perch
#

no

#

subclass HelpCommand and then add it.

vocal laurel
#

how to make a sub command?

somber sky
#

idk how to explain it but is it possible to make the emoji the thumbnail?

somber sky
#

like this

supple thorn
#

searched everywhere just for you

slate swan
somber sky
slate swan
somber sky
#

theres multiple roles

vocal laurel
#
@bot.group()
async def git(ctx):
    if ctx.invoked_subcommand is None:
        await ctx.send('Invalid git command passed...')

@git.command()
async def push(ctx, remote: str, branch: str):
    await ctx.send('Pushing to {} {}'.format(remote, branch))

this?

slate swan
supple thorn
somber sky
#

its a football team list

#

theres like 8 teams

#

i cant put 1 link

vocal laurel
somber sky
#

i need it to find it by the emoji

#

or somethin

supple thorn
#

\🗿

vocal laurel
#

?

vale wing
#
embed.set_thumbnail(url=emoji.url)```
Basically
vale wing
slate swan
#

!d discord.Emoji.url

unkempt canyonBOT
slate swan
#

ic

vale wing
#

Forgor that url is a kwarg

somber sky
#

theres like 8 different teams and each team has a different emoji to it

#

so i want the thumbnail to be the emoji i put

vocal laurel
#

so i do

@client.group()
async def help(ctx):
  pass
@git.command()
async def moderation(ctx):
  pass

like that right?

verbal breach
#

HOLY [curse word] IT WORKS! I think?

supple thorn
#

no

vocal laurel
#

then?

verbal breach
#

i have to test it first

supple thorn
vocal laurel
#

how to do?

#

of

supple thorn
vocal laurel
#

k

vale wing
verbal breach
#

nope doesnt work. I guess i do need aiohttp

slate swan
native wedge
#

how do i make it so when a specific user talks it gives them a role

slate swan
verbal breach
#

TypeError: on message () takes O positional arguments but 1
was given

slate swan
verbal breach
#

All of them dont have anything in () though but ok

abstract kindle
#
        elif isinstance(error, Unregistered):
            channel = self.bot.get_channel(ctx.channel)
            await ctx.send(f"You must be registered to use this command. Register in {channel.mention}")

        elif isinstance(error, discord.ext.commands.errors.CheckFailure):
            print(f"User {ctx.author.name} brought up {error} with the command {ctx.command}.")
#

How come my error handler is defaulting to the bottom one

slate swan
#

bottom one?

abstract kindle
#
def registered():
    async def predicate(ctx):
        result = await ctx.bot.db.find_one({"_id": ctx.author.id})
        if result is None:
            raise Unregistered("Not registered!")
        return True

    return commands.check(predicate)
#

The bottom isinstance

verbal breach
#
async def on_message():
  txt = message.content
  x = re.search("http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+", txt)
  link = (requests.get(x).text)
  def runAlg():
#

everything below that is the defined algorithm for my thing

#

Well, not EVRYTHING but you know what i mean.

slate swan
verbal breach
#

but it says 0 arguments are needed….

slate swan
#

and defining a function every message is a waste of resources, and making it synchronous....?

slate swan
verbal breach
#

TypeError: on message () takes O positional arguments but 1
was given

#

takes 0 positional arguments u

#

But one was giving

slate swan
#

!d discord.on_message

unkempt canyonBOT
#

discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") is created and sent.

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

Warning

Your bot’s own messages and private messages are sent through this event. This can lead cases of ‘recursion’ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
verbal breach
#

so uh….what do i do with my code then?

#

i feel that im at a dead end now.

slate swan
verbal breach
#

like on_message(message)?

slate swan
abstract kindle
#

I'm very confused. For some commands, an unregistered user brings up my Unregistered error, and other times, it just brings up the CheckFailure error

slate swan
abstract kindle
#
class Unregistered(commands.CheckFailure):
    pass
#

Some commands it works, some it doesn't

slate swan
#

well

verbal breach
#

im not getting any errors.

#

so thats good

abstract kindle
#

For example this command:

    @in_game()
    @registered()
    @commands.command(aliases=["hl", "highlow"])
    async def high_low(self, ctx, bet: int):
      ...
#

Brings up the error properly.

#
    @registered()
    @commands.command()
    async def beg(self, ctx):
      ...

This one brings up CheckFailure

#

indentation is right tho

slate swan
#

ic

#

idk im clueless

verbal breach
#

all i have to do is check all paths and i should be….relativly good

lament mesa
slate swan
#

iirc

rough coral
#

uh sorry, so i can ask something about discord bot development here?

lament mesa
abstract kindle
#

Interesting...

#

Because with my command with in_game() and registered(), both of them work

#

but with the other one, it doesn't

slate swan
lament mesa
#

!e ```py
def foo(obj):
print(obj)

def bar(func):
print(func)
return "Hello world"

@foo
@bar
def test():
pass```

unkempt canyonBOT
#

@lament mesa :white_check_mark: Your eval job has completed with return code 0.

001 | <function test at 0x7f985cce4ca0>
002 | Hello world
lament mesa
#

the string "Hello world" has been passed into foo

slate swan
#

never understood decorators

abstract kindle
#

How come it works for this then?

    @in_game()
    @registered()
    @commands.command(aliases=["hl", "highlow"])
    async def high_low(self, ctx, bet: int):
      ...
lament mesa
slate swan
#

i know that

rough coral
unkempt canyonBOT
#

Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.

For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:

The following restrictions apply to your use of the Service. You are not allowed to:

1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service;  (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;

3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;

9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
unkempt canyonBOT
#

bot/exts/moderation/infraction/infractions.py lines 185 to 186

@command(aliases=["mute"])
@ensure_future_timestamp(timestamp_arg=3)```
lament mesa
#

dunno if that changed in v2.0

slate swan
lament mesa
#

the last version i used is 1.7

abstract kindle
#

Yeah, I thought they came first

rough coral
abstract kindle
#

I just updated to 2.0, but I still had this issue in 1.7

slate swan
vocal laurel
#

hey

abstract kindle
#

Even if I switch the order it still doesn't work

vocal laurel
#

am back

slate swan
vocal laurel
#

can someone help with the subcommands

rough coral
#

i forgot ahahahah

verbal breach
#

await outside of asyn function

slate swan
#

which if you break a platforms tos on discord youre breaking their tos

rough coral
slate swan
slate swan
#

^

boreal ravine
#

he doesn't even explain what the code does

abstract kindle
#

This is so wierd

lament mesa
#

if it works it works™️
who needs an explanation? \s

slate swan
#

like any tutorial

rough coral
slate swan
verbal breach
#

alright so big brain i just deleted the

abstract kindle
#

I'm so confused as to why the Error handler works for commands in one file only

verbal breach
#

await

rough coral
#

i forgot that rythm down cuz of youtube

lament mesa
slate swan
lament mesa
#

yes yes

slate swan
#

but still, he isthe only one other than carberra i found to be using mongoDB for levelling purposes

lament mesa
rough coral
#

just kidding, learning new code is cool

abstract kindle
#

But like, the decorators work fine for one command

slate swan
abstract kindle
#

For one command, they bring up Unregistered as the error

#

and for another, they bring up CheckFailure and CheckFailure sends the error Not registered

#
def registered():
    async def predicate(ctx):
        result = await ctx.bot.db.find_one({"_id": ctx.author.id})
        if result is None:
            raise Unregistered("Not registered!")
        return True

    return commands.check(predicate)
slate swan
abstract kindle
#

Like that's what this does... but it's bringing up CheckFailure and not Unregistered

verbal breach
#

Ah, well, it doesnt work…..

verbal breach
#

I put in a link. Send message. No errors pop up in bot. But nothing happens either….

abstract kindle
#

Ran the debugger. It looks like it goes to

elif isinstance(error, Unregistered):
  ...

and then it jumps down to

elif isinstance(error, commands.CheckFailure):
  ...
#

So wierd

lament mesa
#

both elif statements are executing?

verbal breach
abstract kindle
#

No. It goes from the top one and jumps to the bottom one

#

In the command where it does work, it executes the top one and doesn't go down

verbal breach
#

this is what im trying to run. But instead of doing printing things in the console. It messages discord as output

abstract kindle
#

wtf is this

verbal breach
#

it scans videos if they’re rick rolls or not.

#

thats what ive been trying to do with my bot this entire time.

abstract kindle
#

Oh no I was saying wtf to my errors

verbal breach
#

ill make another bot in the process while i virtually beat tf out of other bot for not working properly.

#

Screw you…..my…bot

slate swan
#

so like im tryna verify this bot but very confused on this part

#

..

supple thorn
#

Are you trying to check if their level is higher than 60 or 70?

#

Higher than 60 and lower than 70?

#

Okay

slate swan
#
elif lvl_end > 60 and level_end < 70:
  ...
supple thorn
#

It should be like this then

if lvl_end > 60 and lvl_end < 70:
    ...
slate swan
supple thorn
#

This is why i like dms

#

😔

slate swan
#

lol

supple thorn
#

I was even typing fast for it

#

Then i saw "Ashley is typing..."

slate swan
#

I swear I was typing with one hand

slate swan
#

ugh

supple thorn
#

Okimii coming here beating us with their code

slate swan
verbal breach
#

hmmm

#

any game ideas for a bot?

slate swan
#

bingo

boreal ravine
verbal breach
#

i dont know how to store variables online yet though…

slate swan
boreal ravine
verbal breach
#

I literally cant do anything with a visual ui. Only text

supple thorn
verbal breach
#

even then. I kinda need to learn

slate swan
supple thorn
#

That's easy to code but takes a shit ton of time

boreal ravine
verbal breach
#

i need to first figure out

boreal ravine
slate swan
verbal breach
#

if your (user) show data for this user

#

I just need to know how to get a bot to store information for anyone who plays it. And shows only THEIR data for when that user gets on.

boreal ravine
slate swan
verbal breach
#

what if……lets say i have x = 10 for the most basic example. But everytime the bot runs again….it

#

theres nothing to set variable again.

#

it only changes what already exists.

#

would it still revert to x equalling 10?

slate swan
#

can i get an example on what you mean exactly

verbal breach
#

i dont know how to explain any further

slate swan
#

!e

x = 10
print(x)
x = 5
print(x)

you cant revert it back ig

unkempt canyonBOT
#

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

001 | 10
002 | 5
slate swan
#

really depends on the scope of the variable

#

if that is what you meant

#

yeah that too

verbal breach
#

Itll be in the beginning. But after that. It doesnt reset whenever its run

slate swan
#

a database.

verbal breach
#

ok so…..i just have to make one…

slate swan
#

yes

verbal breach
#

is this it?

slate swan
verbal breach
#

so….what do i do.

slate swan
verbal breach
#

where…

verbal breach
#

Time to start cramming knoledge…

slate swan
#

you can choose any of those

#

I prefer learning SQL since its really helpful

#

okay so im trying to verify my bot and it says i need a All apps must have a Terms of Service. Add one here. is what it says .

slate swan
verbal breach
#

uhhh….ill stick with a normal server bot for now 🤯

slate swan
#

probably in the applications info

slate swan
jolly karma
#

hello

#

anyone here?

slate swan
slate swan
jolly karma
slate swan
jolly karma
#

how do i do it

slate swan
#

lmao

slate swan
unkempt canyonBOT
#

class discord.FFmpegPCMAudio(source, *, executable='ffmpeg', pipe=False, stderr=None, before_options=None, options=None)```
An audio source from FFmpeg (or AVConv).

This launches a sub-process to a specific input file given.

Warning

You must have the ffmpeg or avconv executable in your path environment variable in order for this to work.
slate swan
jolly karma
slate swan
#

depends if they are using replit....?

jolly karma
#

me = dumb

slate swan
jolly karma
slate swan
#

yeah

jolly karma
#

idk why my repl.it logs me out every time ;-;

#

yea

#

desktop

slate swan
# jolly karma ah ic
cogs/
  events.py
  moderation.py
ext/
  uwu.mp3
  new.mp3
bot.py

./ext/uwu.mp3 will be the path here

jolly karma
#

nah

jolly karma
#

btw how do i download

#

||never gonna give u ☝️ put by sir rick astley||

#

isnt that illegal?

slate swan
#

it depends what you do with the downloaded video

#

it could possibly be illegal

jolly karma
#

ill just play rick roll 24/7 in my server lol

slate swan
#

technically, the creator could sue for loss of earnings

#

since you're downloading there video which leads to less watch time etc..

jolly karma
#

i dont think anyone gonna hear to rick roll for that long

slate swan
jolly karma
slate swan
#

stuff

jolly karma
#

idk why do ppl use uptime robo

slate swan
#

uptimerobot

jolly karma
#

when they can self host

jolly karma
#

;-;

slate swan
slate swan