#discord-bots

1 messages · Page 687 of 1

tawdry perch
#

Are you Finn?

slate swan
#

wtf

slate swan
tawdry perch
#

Nice

prisma spoke
#
@bot.command()
@commands.cooldown(1,60,commands.BucketType.user)
async def rob(ctx, member:nextcord.Member):
    robop = ["no","yes"]
    s=random.choices(robop)
    r = s[0]
    await ctx.send(r)

    
    if r == "no":
        robcursor = await bot.db.execute("SELECT bal FROM users WHERE user_id=?",(member.id,))
        robdata = await robcursor.fetchone()
        robmemberbaldata = robdata[0]
        robar = await bot.db.execute("SELECT bal FROM users WHERE user_id=?",(ctx.author.id,))
        robauthor = await robar.fetchone()
        print(robauthor)
        robauthordata = robauthor[0]
        rr = [for i in range(0, robauthordata)]
        robfinee = random.choices(rr)
        robfine = int(robauthordata - robfinee)
        print(robfine)
        await bot.db.execute("INSERT INTO users(bal, user_id) VALUES(?,?)",(robfine,member.id))
        await ctx.send(f"Haha! You got caught! You paid a total fine of {robfinee}, Now you have {robfine}")
    else:
        robcursor = await bot.db.execute("SELECT bal FROM users WHERE user_id=?",(member.id,))
        robdata = await robcursor.fetchone()
        robmemberbaldata = robdata[0]
        robar = await bot.db.execute("SELECT bal FROM users WHERE user_id=?",(ctx.author.id,))
        robauthor = await robar.fetchone()
        print(robauthor)
        robauthordata = robauthor[0]
        rr = [for i in range(0,robauthordata)]
        robfinee = random.choices(rr)
        robfine = int(robauthordata - robfinee)
        print(robfine)
        await bot.db.execute("INSERT INTO users(bal, user_id) VALUES(?,?)",(robfine,member.id))
        await ctx.send(f"Haha! You got caught! You paid a total fine of {robfinee}, Now you have {robfine}")```
#
Traceback (most recent call last):
  File "C:\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "c:\Users\admin\.vscode\extensions\ms-python.python-2021.12.1559732655\pythonFiles\lib\python\debugpy\__main__.py", line 45, in <module>
    cli.main()
  File "c:\Users\admin\.vscode\extensions\ms-python.python-2021.12.1559732655\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 444, in main
    run()
  File "c:\Users\admin\.vscode\extensions\ms-python.python-2021.12.1559732655\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 285, in run_file
    runpy.run_path(target_as_str, run_name=compat.force_str("__main__"))
  File "C:\Python310\lib\runpy.py", line 268, in run_path
    code, fname = _get_code_from_file(run_name, path_name)
  File "C:\Python310\lib\runpy.py", line 242, in _get_code_from_file
    code = compile(f.read(), fname, 'exec')
  File "c:\Users\admin\Downloads\underdev.py", line 113
    rr = [for i in range(0, robauthordata)]
          ^^^
SyntaxError: invalid syntax```
shadow wraith
#

wtf?

#

that's long

slate swan
#

flooding the channel fr

shadow wraith
#

fr i just went to my ide

slate swan
#

message.txt pls

shadow wraith
#

and then that message popped up wtf?

tawdry perch
#

!paste @prisma spoke

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.

shadow wraith
#

and you have like over 10 variables btw

#

☠️

prisma spoke
slate swan
#

haha wanna see my mess of a code bruh

slate swan
#
status = f"{Fore.RED}DOWN{Style.RESET_ALL}"
version = f"0.1 [{Fore.RED}BETA{Style.RESET_ALL}]"
author = "ADX#5452"
running = False
latestcommit = "ADX#5452"
devpage = "https://discord.com/developers/applications/920685915519717466/bot"
invite = "https://discord.com/oauth2/authorize?client_id=920685915519717466&permissions=8&scope=bot"
website = "adxbot.xyz"
webversion = f"0.0 [{Fore.RED}Development Not Started{Style.RESET_ALL}]"
run = input(f"Start? [{Fore.GREEN}Y{Style.RESET_ALL}|{Fore.RED}N{Style.RESET_ALL}] ")
run = run.lower()
if run == "y":
    status = f"{Fore.GREEN}UP{Style.RESET_ALL}"
    os.system("clear")
    print(f"{Fore.CYAN}ADX Discord BOT \n{Style.RESET_ALL}\nStatus: "+status+"\nVersion: "+version+"\nAuthor(s): "+author+"\nLatest commit by: "+latestcommit+"\nDeveloper tools: "+devpage+"\nInvite link "+invite+"\nWebsite: "+website+"\nWebsite version: "+webversion)
    running = True
else:
    os.system("clear")
    print(f"{Fore.CYAN}ADX Discord BOT \n{Style.RESET_ALL}\nStatus: "+status+"\nVersion: "+version+"\nAuthor(s): "+author+"\nLatest commit by: "+latestcommit+"\nDeveloper tools: "+devpage+"\nInvite link "+invite+"\nWebsite: "+website+"\nWebsite version: "+webversion)
    running = False

(start of the code here)

tawdry perch
#

f string would be nice

slate swan
#

ik

#

kinda didn't remembed f strings cuz python2

shadow wraith
#

guys, how can you implement a check where it checks where if you have a specific role then execute the cmd

#

this is my help cmd code

#
class coolHelpCommand(commands.MinimalHelpCommand):
    def __init__(self):
        super().__init__(no_category="Commands", dm_help=True)

    async def send_pages(self):
        destination = self.get_destination()
        for page in self.paginator.pages:
            emby = discord.Embed(
                description=f"{page}", color=discord.Colour.random())
            await destination.send(embed=emby)
prisma spoke
slate swan
#

if message.author.guild_permissions.manage_messages:

prisma spoke
#

!rtfm member.roles

slate swan
#

ah wait roles yes

prisma spoke
slate swan
#

perms easier tho

prisma spoke
shadow wraith
#

i tried doing self.command_attrs but that just made the help command nonexistent

shadow wraith
prisma spoke
#

!discord.member.roles

#

bruh

shadow wraith
#

!d discord.Member.roles

unkempt canyonBOT
#

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

These roles are sorted by their position in the role hierarchy.
slate swan
# shadow wraith ☠️

bro I didn't read the whole message I just assumed u asked for check permissions thing cuz u were asking about roles

prisma spoke
shadow wraith
#

but how will i get the member obj

prisma spoke
halcyon tulip
#

Mhmm.

shadow wraith
halcyon tulip
#

Best forks of discord.py now that it is no longer being worked on?

prisma spoke
shadow wraith
prisma spoke
#

fetch the author

#

message.author

#

or whatever.author

slate swan
shadow wraith
prisma spoke
#

discord.Member object or message.author or interaction.user for buttons or whatever

shadow wraith
#

not saying it is, but how else would you fetch a role instead of guild.get_role() ☠️

slate swan
#

or just make all ur commands in on_message ez

slate swan
unkempt canyonBOT
shadow wraith
#

☠️

peak loom
#

This doesn't work it shows no errors but it doesn't work..

prisma spoke
quaint epoch
#

hi

prisma spoke
slate swan
shadow wraith
prisma spoke
#

typo sry

slate swan
quaint epoch
#

so what's going on?

shadow wraith
slate swan
#

Ah a help command

shadow wraith
#

if i have no context at all. ☠️

peak loom
slate swan
shadow wraith
slate swan
shadow wraith
#

i mean context as in context not actual discord context

peak loom
slate swan
#

use if 'F' in message.content.lower()

quaint epoch
#

'F' is capital in a lowered string?

prisma spoke
slate swan
#

or if message.content.lower() == 'F'

#

and change it to lower bruh

quaint epoch
#
if 'f' in str(message.content).lower():
  #dostuff
slate swan
#

u dont need str(message.content)

#

its always string

peak loom
peak loom
slate swan
prisma spoke
quaint epoch
peak loom
prisma spoke
shadow wraith
prisma spoke
#

not bot.user

peak loom
slate swan
shadow wraith
#

damn you got super black mode my pfp camouflaging (sort of)

slate swan
#

"checks where if you have a specific role"

quaint epoch
prisma spoke
prisma spoke
peak loom
quaint epoch
shadow wraith
#

ok, if i don't understand all deez solutions (discord.Guild.get_member will probably not work since i have abs no idea how im gonna fetch the member id ☠️ )

peak loom
prisma spoke
quaint epoch
peak loom
# prisma spoke mind sending ur code again?
@bot.event
async def on_message(message):
    if message.author == bot.user:
        return
    if message.content == 'F':
        await message.delete()
        await message.channel.send('Thats not appropriate')
prisma spoke
shadow wraith
#

is there a check i can define in the __init__ of my code which checks if the user has a role (if does: exec command, if doesn't: don't exe c command)

prisma spoke
#

yup i am right

shadow wraith
#

!d discord.commands.Bot.user

unkempt canyonBOT
#
Not gonna happen.

No documentation found for the requested symbol.

quaint epoch
#

!d discord.Client.user

unkempt canyonBOT
#

property user: Optional[discord.user.ClientUser]```
Represents the connected client. `None` if not logged in.
shadow wraith
#

@peak loom rip, bot.user doesn't exist

slate swan
shadow wraith
prisma spoke
peak loom
shadow wraith
quaint epoch
prisma spoke
quaint epoch
prisma spoke
slate swan
#

MinimalHelpCommand is a subset of HelpCommand , so add_check works there too

shadow wraith
#

i mean does it support that

prisma spoke
slate swan
prisma spoke
shadow wraith
halcyon tulip
#

Mhm.

prisma spoke
#

like this or whatever

shadow wraith
#

o

halcyon tulip
#

0.o

shadow wraith
#

ok but do i HAVE to pass a function in check, because i was sure that lambda funcs were allowed in self.add_check()

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.

prisma spoke
#

i also know this.

velvet tinsel
#

Are you on a phone?

prisma spoke
#

no.

velvet tinsel
#

Ok.

prisma spoke
#

I just didnt wanna format it that way.

shadow wraith
#

bru dekriel rember my thing

prisma spoke
#

Cuz, I was in a hurry to do smthn.

shadow wraith
#
self.add_check(lambda: self.context.author.roles in staffs)
``` im not sure if this would work :c
velvet tinsel
#

What, the JavaScript

shadow wraith
velvet tinsel
#

What about it?

shadow wraith
#

yea nvm don't talk about it here

shadow wraith
shadow wraith
velvet tinsel
#

Let’s go there

lament mesa
slate swan
#

What the heck is happening

lament mesa
shadow wraith
prisma spoke
shadow wraith
#

and we probably aren't 💀

prisma spoke
slate swan
#

What is happening

lament mesa
#

i thought it was related to commands

fiery scarab
#

I just found my interest in developing a discord bot for myself, and found out discord.py is not maintained anymore. Is there any other good alternatives I should look at (I really don't want to start at something that is not maintained)

sage otter
#

disnake is a good one. I heard.

#

It’s the only fork so far that Danny hasn’t shit on yet.

maiden fable
sage otter
#

Really?

#

Didn’t know AMshrug

maiden fable
#

In the Discord API server, a looong time ago, yes

sage otter
#

What did he say about it?

slate swan
#

what can i use to see all listeners active on the bot?

maiden fable
#

Eh, it was something related to comments. One of the contributors (who is a contributor in the repo too) added comments like Time for some real code UwU and stuff and Danny was just making fun of it, with some other people lmao

slate swan
#

i wouldve thought bot.listeners in the same case as bot.cogs

#

but no

maiden fable
#

Istg there was something like that

maiden fable
#

Nvm, it's cog.get_listeners

sage otter
slate swan
#

im not using a cog however?

maiden fable
maiden fable
slate swan
maiden fable
#

I don't think u can ;-;

slate swan
#

smh

maiden fable
#

Sad

sage otter
#

well you could in a way

slate swan
#

go on...

#

i could just make it a cog

maiden fable
sage otter
#

orrr you can read the file

lament mesa
maiden fable
#

Danny being Danny ¯_(ツ)_/¯

#

He made bot.commands
He made bot.cogs
He didn't make bot.listeners

#

Whyyyyy

slate swan
#

¯_(ツ)_/¯

#

wouldve made sense to yk

lament mesa
#

had to check the source code to find that

maiden fable
slate swan
#

f

kindred epoch
#

Me and someone else used a command at the same time and switched things in my db, is there a way I can fix that?

kindred epoch
#

Postgres

lament mesa
#

If you successfully commit'ed I don't think its reversable

kindred epoch
#

Yea but what if that happens again

maiden fable
kindred epoch
maiden fable
#

!d discord.ext.commands.max_concurrency

unkempt canyonBOT
#

@discord.ext.commands.max_concurrency(number, per=discord.ext.commands.BucketType.default, *, wait=False)```
A decorator that adds a maximum concurrency to a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") or its subclasses.

This enables you to only allow a certain number of command invocations at the same time, for example if a command takes too long or if only one user can use it at a time. This differs from a cooldown in that there is no set waiting period or token bucket – only a set number of people can run the command.

New in version 1.3.
lament mesa
maiden fable
#

How many times a command can be used at a single time

kindred epoch
maiden fable
#

Like if I set it to 1 and the bucket type is guild, and I am using the AI Chat command, none will be able to use it as long as I don't end/complete it

kindred epoch
#

I see

#

So I set per to BucketTypr.user?

maiden fable
#

Iirc that will make it so that one single person can't use in multiple guilds

lament mesa
maiden fable
#

Like I can't use the command in guild 1 as well as guild 2 in user bucket

#

But in member bucket I can use it in guild 2, even when it's working in guild 1

kindred epoch
maiden fable
maiden fable
kindred epoch
#

Ok

maiden fable
#

!d discord.ext.commands.BucketType.guild

unkempt canyonBOT
maiden fable
#

This ig?

visual island
maiden fable
#

Mhm

visual island
#

when dispatching

kindred epoch
maiden fable
#

Who knows ¯_(ツ)_/¯

I guess just make a check yourself with an if statement and use on_command?

#

Or just add multiple decos lol

visual island
#

what was their question?

maiden fable
#

Limit the command so that only one user at a time can use it

#

From all the servers*

kindred epoch
#

Well, it was the db transaction that messed up things

visual island
#

2 max_concurency maybe

maiden fable
#

Yea

boreal ravine
visual island
#

with BucketType.user and guild

maiden fable
boreal ravine
#

i never get ignored

maiden fable
#

So yea, better would be if someone else tells them to do so

maiden fable
boreal ravine
#

sad

visual island
#

sad2

maiden fable
#

Tbh at this point I feel like making my own wrapper, but uhh, nvm

visual island
#

imma make some PRs

maiden fable
#

I am too lazy to maintain it ngl

visual island
#

dont be that guy

maiden fable
#

Also working on other projects with a friend of mine

maiden fable
visual island
maiden fable
#

Soo uhhh

#

👋

visual island
maiden fable
visual island
#

anyways time to sleep

#

gn cya

visual island
#

At least if you make it public

maiden fable
maiden fable
#

Sure I can try. What's up

slate swan
#

Once you guys have helped him I would like some service on a problem that just popped up for my bot.

maiden fable
#

Seems like result is None

#

That error comes when u try to do None[...]

slate swan
#
  File "/home/runner/NootsCustomBot/main.py", line 61, in on_ready
    bot.ticket_configs[int(data[0])] = [int(data[1]), int(data[2]), int(data[3])]
AttributeError: 'Bot' object has no attribute 'ticket_configs'```
#

this error has just began to pop up and here is my code for what I am doing:

#
@bot.event
async def on_ready():
    async with aiofiles.open("ticket_configs.txt", mode="a") as temp:
        pass

    async with aiofiles.open("ticket_configs.txt", mode="r") as file:
        lines = await file.readlines()
        for line in lines:
            data = line.split(" ")
            bot.ticket_configs[int(data[0])] = [int(data[1]), int(data[2]), int(data[3])]```
maiden fable
#

Ah

#

!botvar u need to define it

unkempt canyonBOT
#

Python allows you to set custom attributes to most objects, like your bot! By storing things as attributes of the bot object, you can access them anywhere you access your bot. In the discord.py library, these custom attributes are commonly known as "bot variables" and can be a lifesaver if your bot is divided into many different files. An example on how to use custom attributes on your bot is shown below:

bot = commands.Bot(command_prefix="!")
# Set an attribute on our bot
bot.test = "I am accessible everywhere!"

@bot.command()
async def get(ctx: commands.Context):
    """A command to get the current value of `test`."""
    # Send what the test attribute is currently set to
    await ctx.send(ctx.bot.test)

@bot.command()
async def setval(ctx: commands.Context, *, new_text: str):
    """A command to set a new value of `test`."""
    # Here we change the attribute to what was specified in new_text
    bot.test = new_text

This all applies to cogs as well! You can set attributes to self as you wish.

Be sure not to overwrite attributes discord.py uses, like cogs or users. Name your attributes carefully!

maiden fable
#

U can do something like bot.ticket_configs = [] or whatever the data type is

slate swan
#

but here is all of my code, I already defined it earlier but I did something and now it doesnt work:

#
@bot.command(aliases=["ct", "config_ticket", "configticket"])
async def configure_ticket(ctx, msg: discord.Message=None, category: discord.CategoryChannel=None):
    if msg is None or category is None:
        await ctx.channel.send("**Failed to configure the ticket as an argument was not given or was invalid.**")
        return

    bot.ticket_configs[ctx.guild.id] = [msg.id, msg.channel.id, category.id] # this resets the configuration

    async with aiofiles.open("ticket_configs.txt", mode="r") as file:
        data = await file.readlines()

    async with aiofiles.open("ticket_configs.txt", mode="w") as file:
        await file.write(f"{ctx.guild.id} {msg.id} {msg.channel.id} {category.id}\n")

        for line in data:
            if int(line.split(" ")[0]) != ctx.guild.id:
                await file.write(line)
                
    await msg.add_reaction(u"\U0001F3AB")
    await ctx.channel.send("**Succesfully configured the ticket system.**")


@bot.event
async def on_ready():
    async with aiofiles.open("ticket_configs.txt", mode="a") as temp:
        pass

    async with aiofiles.open("ticket_configs.txt", mode="r") as file:
        lines = await file.readlines()
        for line in lines:
            data = line.split(" ")
            bot.ticket_configs[int(data[0])] = [int(data[1]), int(data[2]), int(data[3])]





@bot.event
async def on_raw_reaction_add(payload):
    if payload.member.id != bot.user.id and str(payload.emoji) == u"\U0001F3AB":
        msg_id, channel_id, category_id = bot.ticket_configs[payload.guild_id]

        if payload.message_id == msg_id:
            guild = bot.get_guild(payload.guild_id)

            for category in guild.categories:
                if category.id == category_id:
                    break

            channel = guild.get_channel(channel_id)

            ticket_channel = await category.create_text_channel(f"ticket-{payload.member.display_name}", topic=f"A ticket for {payload.member.display_name}.", permission_synced=True)
            
            await ticket_channel.set_permissions(payload.member, read_messages=True, send_messages=True)

            message = await channel.fetch_message(msg_id)
            await message.remove_reaction(payload.emoji, payload.member)

            await ticket_channel.send(f"**{payload.member.mention} Thank you for creating a ticket! Use ``'-close'`` to close your ticket.**")

            try:
                await bot.wait_for("message", check=lambda m: m.channel == ticket_channel and m.author == payload.member and m.content == "-close", timeout=3600)

            except asyncio.TimeoutError:
                await ticket_channel.delete()

            else:
                await ticket_channel.delete()```
maiden fable
#

No I mean

#

Where u define your bot instance

#
bot = commands.Bot(...) 
bot.ticket_configs = []
#

Like this

slate swan
#

k hold on

maiden fable
#

Just set the data type correct. Idk if it's a list or dict*

#

Oh, hmm

#

BTW there's a problem

#

U should connect to the database once on the startup, instead of connecting everytime and store it in a bot var

#

!botvars

unkempt canyonBOT
#

Python allows you to set custom attributes to most objects, like your bot! By storing things as attributes of the bot object, you can access them anywhere you access your bot. In the discord.py library, these custom attributes are commonly known as "bot variables" and can be a lifesaver if your bot is divided into many different files. An example on how to use custom attributes on your bot is shown below:

bot = commands.Bot(command_prefix="!")
# Set an attribute on our bot
bot.test = "I am accessible everywhere!"

@bot.command()
async def get(ctx: commands.Context):
    """A command to get the current value of `test`."""
    # Send what the test attribute is currently set to
    await ctx.send(ctx.bot.test)

@bot.command()
async def setval(ctx: commands.Context, *, new_text: str):
    """A command to set a new value of `test`."""
    # Here we change the attribute to what was specified in new_text
    bot.test = new_text

This all applies to cogs as well! You can set attributes to self as you wish.

Be sure not to overwrite attributes discord.py uses, like cogs or users. Name your attributes carefully!

lament mesa
maiden fable
#
bot.db = sqlite.connect(...) 

c = bot.db.cursor() 
#

And stuff...

slate swan
#

im lost

maiden fable
slate swan
#

bot.ticket_configs[int(data[0])] = [int(data[1]), int(data[2]), int(data[3])] would this already define it?

valid barn
#

waited a few hours, still says that :(

maiden fable
#

@slate swan u need to first populate the list/dict with some values

#

U r tryna index an empty list/dict

slate swan
#

values of what? on ticket reaction it should do this

#

could I do this in my on ready? py bot.ticket_configs = [int(data[0])] = [int(data[1]), int(data[2]), int(data[3])]

maiden fable
#

Sure

slate swan
#

like this: ```py
@bot.event
async def on_ready():
async with aiofiles.open("ticket_configs.txt", mode="a") as temp:
pass

bot.ticket_configs = [int(data[0])] = [int(data[1]), int(data[2]), int(data[3])]

async with aiofiles.open("ticket_configs.txt", mode="r") as file:
    lines = await file.readlines()
    for line in lines:
        data = line.split(" ")
        bot.ticket_configs[int(data[0])] = [int(data[1]), int(data[2]), int(data[3])]```??
twin moon
#
@commands.command()
  async def meme(self,ctx,Subreddit="memes"):
    post = reddit.subreddit(Subreddit).random()
    embed = nextcord.Embed(description=f"**[{post.title}]({post.url})**")
    embed.set_image(url=post.url)
    embed.set_footer(text=f"Thanks to {post.author} for this {Subreddit}.")
    await ctx.send(content=None, embed=embed)```why does this post  2 things?
slate nymph
#
class Cog2(commands.Cog):
    def __init__(self,bot):
        self.bot = bot
    @commands.Cog.listener()
    async def on_guild_join(self,guild:discord.Guild):
        for channels in guild.channels:
            global channel_list
            channel_list = await channels.create_webhook(name="Lemontree bot hook")

    @commands.command()
    async def sudo(self,ctx:commands.Context,member:discord.Member,*,message):
        hook = Union(channel_list)
        async with ClientSession() as session:
            await hook.send(content=message,avatar_url=member.display_avatar,username=member.display_name) ```
upbeat otter
slate nymph
#
    await ctx.command.invoke(ctx)
  File "C:\Users\sony\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\commands\commands.py", line 133, in invoke
    await injected(ctx)
  File "C:\Users\sony\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\commands\commands.py", line 90, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.commands.errors.ApplicationCommandInvokeError: Application Command raised an exception: NameError: name 'channel_list' is not defined```
quaint epoch
#

where did you get that reddit module can i have the repos?

quaint epoch
twin moon
#

its called praw

quaint epoch
twin moon
#

yes

#

its good

quaint epoch
twin moon
quaint epoch
twin moon
#

can I hyperlink something in a footer

sage otter
#

Have you tried committing?

#

!d sqlite3.Connection.commit

unkempt canyonBOT
#

commit()```
This method commits the current transaction. If you don’t call this method, anything you did since the last call to `commit()` is not visible from other database connections. If you wonder why you don’t see the data you’ve written to the database, please check you didn’t forget to call this method.
sage otter
sage otter
#

It’s a Connection method

#

Not Cursor

#

It should be db.commit() in your case

#

Also consider using an async version of SQLite

slate swan
#

!pypi aiosqlite

unkempt canyonBOT
slate swan
#

Use that

spark sentinel
#

Hey, how do I get a message out of an embed ?

#

I tryed to split it but that didnt works

sage otter
#

That’s kind of an ambiguous question. Like what part of the embed do you want?

spark sentinel
#

the description

sage otter
#

Grab the object and just read the description then

#

!d discord.Embed.description

unkempt canyonBOT
sage otter
#

Not subscriptable means you can’t index or slice it.

#

And you can’t do any of those things with None

final iron
#

Whatever you're trying to splice/index is None

sage otter
final iron
#

!e

a = "ABCDEFG"
print(a[:-6])
unkempt canyonBOT
#

@final iron :white_check_mark: Your eval job has completed with return code 0.

A
sage otter
#

that’s slicing.

final iron
#

So would this being splicing or slicing?

#

Ah

#

I always thought that was splicing

#

What is splicing then?

lament mesa
#

You need to do db.commit() for the changes to apply

sage otter
#

thank you Rush for saying the same exact thing I said.

tiny ibex
#

Wait there is an unofficial Discord API too?

sage otter
#

no. that doesn’t exist.

tiny ibex
lament mesa
tiny ibex
#

1 min

sage otter
#

There’s an Unofficial API support server.

tiny ibex
#

And link please

sage otter
#

Idk. It’s something that Danny made.

fiery scarab
#

what is bot.user_command and how does it work?

tiny ibex
tiny ibex
#

Guess I found it

sage otter
sage otter
#

In the case I’m wrong. It’s probably an alias for slicing.

final iron
#

I asked in general. Let's see if I get a response

boreal ravine
sage otter
boreal ravine
#

nice

lament mesa
slate swan
#

when you send a request to discord to leave a guild, what does the "lurking" parameter mean?

slate swan
boreal ravine
#

Ask in the api server

#

no idea what that means

slim whale
#

I'm trying to make an image command that searchs images in a website, I followed a tutorial.
code: py @bot.command() async def image(ctx, *, search): search = search.replace(' ', '') url = f"https://api.unsplash.com/photos/random/?query={search}&orientation=squarish&content_filter=high&client_id={token}" async with aiohttp.ClientSession.get(url) as r: if r.status in range(200,299): try: data = await r.json() url = data['urls']['regular'] e = discord.Embed( title = 'Aqui esta tu foto', ) e.set_image(url=image) await ctx.send(embed=e) except IndexError: await ctx.send('Imagen no encontrada.') else: await ctx.send(f'Error al hacer la petición. {r.status}')
Traceback: ```Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "main.py", line 43, in image
async with aiohttp.ClientSession.get(url) as r:
TypeError: get() missing 1 required positional argument: 'url'

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

Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/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: get() missing 1 required positional argument: 'url'```

full lily
#

try this

slim whale
#

it works but it says The else Error al hacer la petición. 401

grim oar
#

That random/?query= looks weird

slim whale
#
client_session: <aiohttp.client.ClientSession object at 0x7fe6ab3583a0>
Unclosed connector
connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x7fe6ab339940>, 71556.599530096)]']
connector: <aiohttp.connector.TCPConnector object at 0x7fe6ab358160>```
grim oar
#

Have you tried random?query=?

slim whale
slate swan
slim whale
slim whale
slate swan
slim whale
#

so why it doesnt work xd?

slate swan
#

He deserves it ngl

slim whale
#
@bot.command()
async def image(ctx, *, search):
  search = search.replace(' ', '')
  url = f"https://api.unsplash.com/photos/random?query={search}&orientation=squarish&content_filter=high&client_id={token}"
  async with aiohttp.ClientSession().get(url) as r:
    if r.status in range(200,299):
      try:
        data = await r.json()
        url = data['urls']['regular']
        e = discord.Embed(
          title = 'Aqui esta tu foto',
        )
        e.set_image(url=image)
        await ctx.send(embed=e)
      except IndexError:
        await ctx.send('Imagen no encontrada.')
    else:
      await ctx.send(f'Error al hacer la petición. {r.status}')```
grim oar
#

It's a warning that you haven't closed the ClientSession

slim whale
slate swan
slim whale
slim whale
slate swan
grim oar
#

Well it doesn't but you can close it with await r.close()

#

Actually that won't work lmao

#

you should use a separate context manager for ClientSession

slim whale
#

how i can make the bot send the image instead of this: Error al hacer la petición. 401

grim oar
slim whale
#

its the else

#

401 its the r.status

grim oar
#

Oh yeah am blind

#

you are getting an error code of 401

grim oar
slim whale
#

url thing its like this rn: url = f"https://api.unsplash.com/photos/random?query={search}&orientation=squarish&content_filter=high&client_id={token}"

grim oar
#

hmm is the token correct?

slim whale
#

yes

grim oar
#

Hmm the api is returning that error code I think you have some problem with that endpoint

slim whale
#

did a stupid error but same thing

#

in the embed i did e.set_image(url=image)

#

but changed it to url

#

the bot sends same thing f

pulsar shell
# slate swan this

it's probably just tracking whether or not you are lurking for server statistics

#

which request was it in?

upbeat otter
#

Guys guys, a question

#

I have a dictionary (global variable) and it stores data like guild_id = messages, I want to check the number of messages using iteration and if the number of messages exceed the default limit, I want to fetch the guild id, how do I do that?

#

just put, help_command = None in your bot constructor

cloud dawn
#

!d discord.ext.commands.Bot

unkempt canyonBOT
#

class discord.ext.commands.Bot(command_prefix, help_command=<default-help-command>, description=None, **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.
cloud dawn
#

Then restart.

slate swan
#

Its not a coro right

upbeat otter
#

,-,

cloud dawn
slate swan
#

I do the kwarg method it looks cleaner

upbeat otter
cloud dawn
#

Or just subclassing the help command the best by far.

slate swan
#

I just make a new command lol

cloud dawn
upbeat otter
#
main_message_count = {}

@client.event
async def on_message_delete(message):
    if message:
        if message.guild.id not in main_message_count:
            main_message_count[message.guild.id] = 1
            return
        main_message_count[message.guild.id] += 1

cloud dawn
slate swan
#

Pretty easy lol

upbeat otter
cloud dawn
cloud dawn
upbeat otter
slate swan
cloud dawn
#

!e ```py
test = {"test": 1, "yes": 2}
print(len(test))

unkempt canyonBOT
#

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

2
upbeat otter
slate swan
upbeat otter
#

nvm

#

no need, tq

#

I was being too dumb

cloud dawn
vagrant brook
#

Dict.keys() is a thing ig

upbeat otter
#

i have an if statement for that

#

NVM i FOUND THE BULK MESSAGE DELETE EVENT, THAT'LL HELP ME

vagrant brook
#

Owo

tacit horizon
#

logo_pycharm or logo_vscode

tacit horizon
upbeat otter
cloud dawn
#

sorry

upbeat otter
slate swan
tacit horizon
slate swan
upbeat otter
sage otter
cloud dawn
#

I use vscode sometimes.

slate swan
#

Pycharm looks boring to me

#

Vsc is more colorful to me maybe im just childish

sage otter
#

Is honestly use Atom over vsc tbh. If I wanted IDE features I’d use an actual IDE

cold sonnet
#

I just came here to tell you

#

!ot

unkempt canyonBOT
slate swan
cold sonnet
#

he knew kekw

cloud dawn
#

For coding discord bots i use atom

tacit horizon
slate swan
sage otter
maiden fable
slate swan
vagrant brook
sage otter
#

Material theme exists.

sage otter
cloud dawn
vagrant brook
#

I been using it for years

cloud dawn
slate swan
#

logo_idle > anything else

vagrant brook
#

Ok

slate swan
tacit horizon
slate swan
cloud dawn
#

In MS word you can give everything a different color AND font, what IDE let's you do that?

tacit horizon
#

Ms word

sage otter
#

The one that has a sane design.

#

That video Joma Tech made on Ms word as an IDE was a bonafide shitpost

tacit horizon
#

Jomu op

honest vessel
#

sublime +sftp

slate swan
#

Poor jupyter notebook

slate swan
cloud dawn
#

ftp king

slate swan
honest vessel
upbeat otter
tacit horizon
sage otter
pliant gulch
#

You guys are using VSC and all that other stuff, but neovim on top

slate swan
#

logo_vsc_insiders whats this🤔

pliant gulch
#

VSC Insiders

cloud dawn
slate swan
pliant gulch
#

Vim & neovim, basically the same thing

slate swan
pliant gulch
#

Although I prefer neovim more

upbeat otter
#

Meh, cli best

pliant gulch
#

neovim is a cli as well

slate swan
#

Notepad is better

sage otter
#

If you use cli editors you actually belong in a mental hospital. unless you need to quickly edit something, they have their uses. though if it mattered that much id just use nano or micro

pliant gulch
#

How??

tacit horizon
upbeat otter
slate swan
cloud dawn
slate swan
slate swan
tacit horizon
cold sonnet
upbeat otter
cold sonnet
cloud dawn
slate swan
#

Not the uwu 🚶

upbeat otter
#

Page design

cloud dawn
upbeat otter
cloud dawn
#

Don't see any cloud editing for vscode

pliant gulch
#

Huh

#

that exists lol

slate swan
#

Yall forgot the best editor tbh

upbeat otter
cloud dawn
slate swan
#

Its jupyter notebook ofc

cloud dawn
tacit horizon
#

Why can't code in discord

slate swan
upbeat otter
pliant gulch
slate swan
#

Made an eval command for my bot and im runnig a bot with a bot🕴️ pithink

pliant gulch
#

This ones built into gitub^

upbeat otter
#

Like discord comes with inbuilt interpreters

upbeat otter
#

Cant see

cloud dawn
pliant gulch
cloud dawn
#

huh who knew.

#

😂

slate swan
sage otter
#

I mean fleet has that.

#

Fleet is basically just vsc but with IntelliJ code processing.

pliant gulch
#

Theres also a thing for neovim on the web as well

#

It's alright

slate swan
#

What is neovim😔

sage otter
#

Vim fork

pliant gulch
#

Better vim

tacit horizon
slate swan
#

What is vim🤬

sage otter
#

Terminal editor

slate swan
slate swan
cloud dawn
tacit horizon
#

Taking over humanity

slate swan
tacit horizon
slate swan
#

I made a bot that runs a bot with a eval command and the bot im running with the eval is running a bot with a eval command 🕴️

verbal cairn
#

anyone know how to space out embed fields

honest vessel
#

instead of format, u can do

sql = """SELECT timestamp FROM users WHERE user_id = ?"""
await cursor.execute(sql, (user_id,))
#

then just do timestamp-10

pliant gulch
honest vessel
#

i mean aslong timestamp is a unix format

#

aka seconds, its possible

pliant gulch
#

Depends, sql has a DATE DATETIME and TIMESTAMP type, so it doesn't always need to be epoch time

honest vessel
#

yes if timestampnow >= old_timestamp-10

#

it will pass if 10 or older

cloud dawn
#

@hidden hazel Are you trying to add cooldowns to commands inside on_message..?

#

I have to give props to the dedication if so.

honest vessel
#

he wants cooldown after X messages posted looks like

#

activate slowmode? 😄

cloud dawn
#

So why are you using a DB for that..? Seems like a weird solution right now then.

pliant gulch
#

You could also just use discord.py's built in cooldown system to make a custom bucket for message sending cooldowns

honest vessel
#

@hidden hazel```py
import typing
import discord
from discord.ext import commands

class SomeCog(commands.Cog):
def init(self, bot):
self.bot = bot
self._cd = commands.CooldownMapping.from_cooldown(1, 6.0, commands.BucketType.member) # Change accordingly
# rate, per, BucketType

def get_ratelimit(self, message: discord.Message) -> typing.Optional[int]:
    """Returns the ratelimit left"""
    bucket = self._cd.get_bucket(message)
    return bucket.update_rate_limit()


@commands.Cog.listener()
async def on_message(self, message):
    if "check something":
        # Getting the ratelimit left
        ratelimit = self.get_ratelimit(message)
        if ratelimit is None:
            # The user is not ratelimited, you can add the XP or level up the user here

        else:
            # The user is ratelimited
cloud dawn
#

I get that you want to track the messages to count it but to use a DB to see how many messages got typed in the last 10 seconds is a bit over the top.

slim whale
#

Does on_channel_update on_channel_delete and on_channel_create exist?

pliant gulch
#

This is deviating a bit but perhaps a asyncio.Lock and asyncio.sleep here could work as well

slim whale
#

tnx

cloud dawn
#

Then you are still using the database. And i suggest using the RAM since it will use less resources then.

slim whale
#
@bot.event
async def on_channel_update(before,after):
  # Channel Update Logs
  channel = bot.get_channel(913158722992373854)
  await channel.send(f"🖊️ [{after.created_at.replace(microsecond=0)}] El nombre del canal {after.mention} ha sido editado. \nAntes: `{before.name}`\nDespués: `{after.name}`")```bc this sends nothing
velvet tinsel
#

PandaBweer ❤️

honest vessel
#

    Called whenever a channel is updated. e.g. changed name, topic, permissions.
    Parameters:    channel – The Channel that got updated.```
slim whale
#

tnx

cloud dawn
unkempt canyonBOT
#

discord.on_guild_channel_update(before, after)```
Called whenever a guild channel is updated. e.g. changed name, topic, permissions.

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

but how i can know the before name?

#

ohhhhhhhhhh

honest vessel
#

oh there u have another 🙂

slim whale
#

thanks!

velvet tinsel
#

at least the bot is feeling better now

slim whale
#

thanks for helping @honest vessel @cloud dawn

pliant gulch
#

You could, have a temp dict inside of your code, when a user sends a message, store message.created_at that inside of the dict. Have a if statement inside of the on_message callback checking if the created_at exists, if so check if it is 10 seconds behind of datetime.datetime.utcnow(), if it is continue

#

Idk if I explained that well, but I don't see an error in logic with that method

honest vessel
#

oh i was checking old API doc 😛

pliant gulch
#

Saves resources as well

cloud dawn
honest vessel
pliant gulch
#

Then you'd just do ```py
if datetime.datetime.utcnow() >= (stored_timestamp + datetime.timedelta(seconds=10))

cloud dawn
#

And i'm telling you that is not a good way to code it, on each message the person send it will connect to the database. Even with the 10 sec interval i would have made a task for commiting to the DB. Since you are just using bandwith like crazy right now.

pliant gulch
#

You are also not using an async driver for sqlite

honest vessel
#

maybe his db is on same server

cloud dawn
honest vessel
#

and prob not 9999999 users

pliant gulch
#

E.g if the bot had downtime within those 10 seconds, It would remember that

cloud dawn
slim whale
#

how i can know if a channel its a voice channel or a text one?

pliant gulch
#

If you want you could cache the database for more resources save as well

#

It shouldn't matter so as long as you use an async driver for sqlite

cloud dawn
unkempt canyonBOT
#

class discord.abc.GuildChannel```
An ABC that details the common operations on a Discord guild channel.

The following implement this ABC...
slim whale
#

tnx

cloud dawn
unkempt canyonBOT
cloud dawn
snow flare
#

How can I send a message to a channel using the channel ID?

cloud dawn
#

!d discord.ext.commands.Bot.get_channel

unkempt canyonBOT
#

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

Retrieves a [`abc.GuildChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.GuildChannel "discord.abc.GuildChannel"), [`abc.PrivateChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.PrivateChannel "discord.abc.PrivateChannel"), or [`Thread`](https://discordpy.readthedocs.io/en/master/api.html#discord.Thread "discord.Thread") with the specified ID.

Note

This method is an API call. For general usage, consider [`get_channel()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.get_channel "discord.ext.commands.Bot.get_channel") instead.

New in version 1.2.
slate swan
#

Get the channel first

#

If not in cache fetch it

honest vessel
snow flare
cloud dawn
slate swan
#

Why are you guys sending the message separately?

honest vessel
#

and also if u wnt to delete msg, u have the variable

pliant gulch
snow flare
slate swan
pliant gulch
pliant gulch
#

Although dict getitem is O(1) so it's def faster

snow flare
sage otter
#

3 different people giving the same exact solution to the same exact person.

cloud dawn
cloud dawn
snow flare
cloud dawn
#

I first try to get it from the cache else fetch it.

snow flare
#

anyways, I get it now, thanks guys

cloud dawn
#

👍

slate swan
#

If your gonna fetch a channel and send a msg with the .send() attr then youll need 2 awaits

#

Since fetch and .send are both coros

snow flare
#

ok

pliant gulch
#

Problem isn't the awaiting though

pliant gulch
#

The issue is that you spend 2 ratelimit requests to get a channel, and to send a message

#

Whilst grabbing from cache spends a net total of 1 request

slate swan
cloud dawn
pliant gulch
#

They are sending a string though

slate swan
cloud dawn
sage otter
#

I literally just did Panda.

cloud dawn
#
# Won't work
await bot.get_channel(int).send("msg")

# will work
await (bot.get_channel(int)).send("msg")
slate swan
#
await(await bot.fetch_channel(int)).send("msg")
slate swan
pliant gulch
pliant gulch
sage otter
pliant gulch
#

You would need it if you are awaiting another coro iirc

#

But here, it isn't needed

slim whale
#
@bot.event
async def on_guild_channel_create(channel):
  # Channel Create Logs
  print(channel.type)
  tipo = ""
  if channel.type == "text":
    tipo = "El canal de texto"
  elif channel.type == "voice":
    tipo = "El canal de voz"
  elif channel.type == "category":
    tipo = "La categoria"
  elif channel.type == "stage_voice":
    tipo = "El escenario"
  elif channel.type == "store":
    tipo = "La tienda"
  elif channel.type == "news":
    tipo = "El canal de noticias"
  channel2 = bot.get_channel(913158722992373854)
  await channel2.send(f"🖊️ [{channel.created_at.replace(microsecond=0)}] {tipo} `{channel.name}` ({channel.id}) ha sido creado.")``` why this only sends the tipo variable empty
cold sonnet
#

.type returns the type

#

not a string

cloud dawn
# sage otter <:smilebutcryinside:412234433379434496>
Ignoring exception in command test:
Traceback (most recent call last):
  File "C:\Users\eboss\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\core.py", line 175, in wrapped
    ret = await coro(*args, **kwargs)
  File "C:\Users\eboss\Downloads\p.py", line 18, in test
    channel = await bot.fetch_channel(814647436575244298).send('test')
  File "C:\Users\eboss\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\client.py", line -1, in fetch_channel
TypeError: can't send non-None value to a just-started coroutine

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

Traceback (most recent call last):
  File "C:\Users\eboss\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\bot_base.py", line 560, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\eboss\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\core.py", line 929, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\eboss\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\core.py", line 184, in wrapped
    raise CommandInvokeError(exc) from exc
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: can't send non-None value to a just-started coroutine

==============

@bot.command()
async def test(ctx):
    channel = await bot.fetch_channel(814647436575244298).send('test')
cold sonnet
#

what does it print

slim whale
#

text voice news

#

stage_voice

sage otter
#

Yes because fetch_channel is a coro

sage otter
#

What okimii sent was get_channel() which is a cache call

cloud dawn
slate swan
#

2 coros

cloud dawn
#

Well anyways with a coro it's ```py
await (bot.fetch_channel(814647436575244298)).send('test')

slim whale
slate swan
#

how can i scrape all members from a discord server? i want to make a giveaway bot

cloud dawn
slate swan
cold sonnet
slate swan
#

To

cold sonnet
#

?

slate swan
#

Nah my other msg lol

cloud dawn
slim whale
cold sonnet
#

?

slate swan
#

I realized now

slim whale
# cold sonnet ?

when i create a text channel the type its text, when i create a voice one its voice, a news one news, a stage channel stage_voice

cold sonnet
#

that can't be

#

.type has to be a class

slate swan
cold sonnet
#

discord.TextChannel for example

slim whale
#

print(channel.type)

cloud dawn
cold sonnet
#

what

slim whale
#

bc i dont know why it doesnt send the tipe

#

type*

pliant gulch
#

.type returns an Enum

cloud dawn
#

But you can compare them to a string though.

#

If you want.

slim whale
cold sonnet
pliant gulch
#

Because hes comparing a string to an Enum

#

If you want to compare enum to string you need to cast it to str

slim whale
#

i dont remember whats an Enum

#

xd

cloud dawn
cold sonnet
#

enumerator

slim whale
sage otter
#

Panda did you even read what Andy just said

pliant gulch
unkempt canyonBOT
#

@pliant gulch :white_check_mark: Your eval job has completed with return code 0.

False
cloud dawn
#

But tbh i would just make the response a bit broader like this is a ...

slim whale
cold sonnet
#

that's what I'm asking myself

pliant gulch
cold sonnet
#

I don't know python

pliant gulch
cold sonnet
#

they aren't attributes nor methods so I'm out there

slim whale
#

u made me think XD, didnt remember that

unkempt canyonBOT
slim whale
#

lol

slate swan
slim whale
#

where are u from guys?

slate swan
slate swan
slate swan
dire folio
#

i should be able to do this right? waiting.insert(0, [userid, 'staff'])

pliant gulch
dire folio
#

ye it is

#

but i keep getting AttributeError: 'str' object has no attribute 'insert'

pliant gulch
#

It isn't a list then

#

Perhaps you instantiate a new waiting variable that overwrites the previous

dire folio
#

nope there isn't anything that makes waiting not a list

pliant gulch
#

Can you show your code

dire folio
#

1 sec brb

dire folio
verbal cairn
#

how can u make it so only the person who runs the command can click the buttons

sage otter
#

Run a check with Context.author

verbal cairn
#

in the view?

pliant gulch
#

You should be doing json.dump

dire folio
#

i see

spark sentinel
#

!d discord.Embed.description

unkempt canyonBOT
dire folio
#

i did not know that

spark sentinel
#

can someone say me how this works (i will grab the description out of an embed)

pliant gulch
#

!d json.loads

unkempt canyonBOT
#

json.loads(s, *, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)```
Deserialize *s* (a [`str`](https://docs.python.org/3/library/stdtypes.html#str "str"), [`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes "bytes") or [`bytearray`](https://docs.python.org/3/library/stdtypes.html#bytearray "bytearray") instance containing a JSON document) to a Python object using this [conversion table](https://docs.python.org/3/library/json.html#json-to-py-table).

The other arguments have the same meaning as in [`load()`](https://docs.python.org/3/library/json.html#json.load "json.load").

If the data being deserialized is not a valid JSON document, a [`JSONDecodeError`](https://docs.python.org/3/library/json.html#json.JSONDecodeError "json.JSONDecodeError") will be raised.

Changed in version 3.6: *s* can now be of type [`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes "bytes") or [`bytearray`](https://docs.python.org/3/library/stdtypes.html#bytearray "bytearray"). The input encoding should be UTF-8, UTF-16 or UTF-32.

Changed in version 3.9: The keyword argument *encoding* has been removed.
snow flare
#

How can I make a button only viewable to a certain person or role?

snow flare
verbal cairn
snow flare
#

not just the person who ran the command

verbal cairn
#

dont think so, discord limitation

cloud dawn
snow flare
#

ok, thanks

pliant gulch
#

Would that even work without making a new interaction?

#

As sending the first message already "responds" to the interaction

verbal cairn
#

no

pliant gulch
#

You can't respond to the same interaction twice

#

Not unless the first response was a defer

verbal cairn
#

defer not gonna help him tho so idk

pliant gulch
#

Yea, so you can't just simply send the message again

verbal cairn
#

well u could

#

just wouldnt do anything

pliant gulch
#

You would need a new interaction

#

Since, like I said you can't respond to a already responded interaction

#

And the only way to send ephemeral messages is via an interaction response

verbal cairn
#
@bot.command()
async def profile(ctx, member: disnake.Member):
    Code here...
slate swan
verbal cairn
slate swan
#

Only the message will be ephemeral

snow flare
slate swan
cloud dawn
#

!d disnake.ext.commands.MemberConverter

unkempt canyonBOT
#

class disnake.ext.commands.MemberConverter(*args, **kwargs)```
Converts to a [`Member`](https://docs.disnake.dev/en/latest/api.html#disnake.Member "disnake.Member").

All lookups are via the local guild. If in a DM context, then the lookup is done by the global cache.

The lookup strategy is as follows (in order)...
slate swan
#

Its a member obj

verbal cairn
#

attached to nothing

slate swan
#

Ephemeral is only for interaction msgs

verbal cairn
#

interactions can have a view tho

snow flare
slate swan
tacit horizon
slate swan
#

You mean attaching buttons on an ephemeral msg?

verbal cairn
#

yes

#

how else would u use buttons if they arent attached to anything

cerulean osprey
#

Can someone link the docs for client.wait_for ? I tried using !d and Python yelled at me :(

slate swan
south thicket
#

who know something about pafy lib

#

in bots music

cerulean osprey
#

Sir that’s illegal

unkempt canyonBOT
#

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

Waits for a WebSocket event to be dispatched.

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

The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.

In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
cerulean osprey
slate swan
#

How can i make a check that makes the intr author the ctx author

south thicket
#

hello

pastel cobalt
slate swan
#

Never seen one

pastel cobalt
south thicket
#

did you know about pafy library

pastel cobalt
#

intr in the sense interaction only na?

slate swan
slate swan
pastel cobalt
#

yes it has

slate swan
south thicket
#

guys

pastel cobalt
#

you mean check function?

slate swan
#

No

dire folio
slate swan
#

Like the attrs of intr where it says author

pastel cobalt
slate swan
#

Because ive never seen one idk if im blind but never seen one

south thicket
#

k now

#

someone know about pafy ?

#

library ?

cloud dawn
south thicket
#

dude

cloud dawn
south thicket
#

no but its have good connect with the lib

slate swan
unkempt canyonBOT
slate swan
#

Against tos lol

#

coughs in rule 5

south thicket
#

this lib help you do music bot

slate swan
#

!rule 5

unkempt canyonBOT
#

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

slate swan
#

!ytdl

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)
slate swan
snow flare
#

btw, going back to the topic of making a button ephemeral. Can't I just make a check if the user interacting with it is a certain user (that I fetch with the user's id). And then send them and ephemeral message saying that the button is not for him or smt, if he tries to interact with it of course?

south thicket
#

: )

#

guys mention any room can help me

slate swan
slate swan
#

because rule 5

south thicket
snow flare
slate swan
slate swan
unkempt canyonBOT
#

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

cloud dawn
#

Ah yeah it does download video/audio

snow flare
south thicket
slate swan
#

....

south thicket
#

why just me

slate swan
#

read the rule?

slate swan
south thicket
#
  • this is just lib not something break laws
slate swan
#

ye it is

snow flare
# slate swan 2.0?

yeah, the latest version, you have to get it of github, it isn't on pypi

slate swan
#

it breaks TOS

south thicket
snow flare
slate swan
#

@cloud dawn is their really an author attr for an interaction?

slate swan
south thicket
#

happy ?

slate swan
#

sure ig

cloud dawn
unkempt canyonBOT
slate swan
#

Im blind🚶

snow flare
snow flare
slate swan
snow flare
slate swan
#

that doesn't have button support or anything tho, does it?

snow flare
#

and that is why people are making forks of it, so that they can keep on working on it, and make updates if something new comes up

#

but currently, while discord hasn't created any massive api breaking update, it all works perfectly fine

slate swan
#

alright

slate swan
#

Just use disnake lol

snow flare
#

but yeah, it is just better to use one of the forks

slate swan
#

nowhere on here does it have the word button, lol

#

so ok, disnake it is

pliant gulch
#

It has all components

slate swan
#

Andy your late

#

Lol

#

Scroll up

pliant gulch
#

Oh

slate swan
#

Watch him drop a fat explanation pithink

pliant gulch
#

Maybe later

slate swan
brittle ingot
#

User Timeout moderation feature is releasing monday 😮

slate swan
#

holy fucking shit. I just published my bot, and its already laggy as hell (4gb 2core vds), wtf.

brittle ingot
#

memory leak?

#

what is the response time?

slate swan
#

client.latency * 1000 right?

brittle ingot
#
round(client.latency * 1000, 2)
slate swan
#

python is a slow lang

#

¯_(ツ)_/¯

brittle ingot
#

ive had response times of less then 20ms...