#discord-bots

1 messages · Page 101 of 1

slate swan
#

you cant use ctx there, app commands work with interactions

#

but in ur case it will

smoky cedar
#

@discord.app_commands.checks.has_permissions(administrator)
@tree.command(name="ban", description = "bans the specific user! (Admin) ")
async def ban(ctx, member : discord.Member, reason:str):
  await member.ban(reason=reason)
  await ctx.response.send_message(f"__**SUCCESSFULLY BANNED {member}! **__")

#

like that?

slate swan
#

yes and rename ctx to interaction to avoid confusion

#

its not a ctx , its an interaction

slate swan
smoky cedar
#

and also, is this how I make return if member don't the hsve the required permission

#

return
#

?

tired hinge
#

okay so my bot keeps getting rate-limited. what happens if this keeps happening? and i'd appreciate any tips on how to reduce requests 😔

rare echo
hushed galleon
#

if you're using replit, getting ratelimited is a typical issue

tiny wraith
#

i did so and it gave me different sets of error

name 'bot' is not defined
name 'bot' is not defined
name 'bot' is not defined
Traceback (most recent call last):
File "c:\Users\Home\Desktop\DingoLingo-master\DingoLingo-master\run.py", line 33, in <module>
@bot.event
NameError: name 'bot' is not defined
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x0000021EC5606BF0>

primal token
#

You would need a huge botnet and either way cloudflare will still block the attack

rare echo
rare echo
#

im not ignorin ya i just dont use the decorator so im not 100% ;o

#

you should be able to make an error handler if they are missing perms and return with a message ie "missing perms"

smoky cedar
#

i know but how..

#

im beginner

naive briar
smoky cedar
#

i mean i wanna learn..

#

soo

#

yeah..

primal token
rare echo
# smoky cedar i mean i wanna learn..

cats not saying its impossible, its just going to be reasonably more difficult to jump straight into this instead of learning some core basics first

primal token
#

Cat never said it was impossible, It's the learning curve that is quite difficult as the paradigms used in the library and the principles are quite complex to learn without any base core knowledge

#

E.g how would you learn about OOP if you dont have a grasp of something like polymorphism, which is an issue i see allot

smoky cedar
#

thanks for explaining even tho I didn't understand some 🥲

mellow hollow
#

dont wanna spam but could u send me the base36 code

meager chasm
primal token
#

Should i be offended?

meager chasm
primal token
#

no

limber bison
#

how can i create a sync command
?

vale wing
#

!e

import base64;[print(chr(int(base64.urlsafe_b64decode(s+"="))>>69),end="") for s in 'NDYwNDMwNzMyMDc5NzkwNDA4MzM1MzY=NTk2MTk4NzY4NDYyMjkyNzA4MjI5MTI=Njk2NTQ5MDU2MjIzMjcyNjY5MDIwMTY=NTk2MTk4NzY4NDYyMjkyNzA4MjI5MTI=NjcyOTM3MjIzODA4OTI0NDQyOTUxNjg=MTg4ODk0NjU5MzE0Nzg1ODA4NTQ3ODQ=NjA4MDA0Njg0NjY5NDY2ODIxMjYzMzY=NjU1MjI4MzQ5NDk4MTYzMjczNDAwMzI=NjQ5MzI1MzkxMzk0NTc2MjE2ODgzMjA=NjQ5MzI1MzkxMzk0NTc2MjE2ODgzMjA=NTcyNTg2OTM2MDQ3OTQ0NDgyMTYwNjQ=MTg4ODk0NjU5MzE0Nzg1ODA4NTQ3ODQ=NjA4MDA0Njg0NjY5NDY2ODIxMjYzMzY=NjE5ODEwNjAwODc2NjQwOTM0Mjk3NjA=Njk2NTQ5MDU2MjIzMjcyNjY5MDIwMTY=NTk2MTk4NzY4NDYyMjkyNzA4MjI5MTI=MTg4ODk0NjU5MzE0Nzg1ODA4NTQ3ODQ=NzE0MjU3OTMwNTM0MDMzODM4NTcxNTI=NjU1MjI4MzQ5NDk4MTYzMjczNDAwMzI=NjkwNjQ2MDk4MTE5Njg1NjEyNTAzMDQ=MTg4ODk0NjU5MzE0Nzg1ODA4NTQ3ODQ=NjkwNjQ2MDk4MTE5Njg1NjEyNTAzMDQ=NjYxMTMxMzA3NjAxNzUwMzI5OTE3NDQ='.split("=") if len(s)>0]```
unkempt canyonBOT
#

@vale wing :white_check_mark: Your 3.11 eval job has completed with return code 0.

Never gonna give you up
vale wing
#

Is this what you are interested in?

vale wing
#

That is the point

primal token
#

smh

slate swan
#

Yes I'm pretty sure there's on command event and the name is global check I think

naive briar
slate swan
#
async def on_command(ctx):
    channel = bot.get_channel(log_channel_id)
    server = ctx.guild.name
    user = ctx.author
    command = ctx.command
await channel.send(f'{user} used {command} in {server}')``` ?
primal token
naive briar
#

😳

primal token
#

!e

print(__import__("base64"))
unkempt canyonBOT
#

@primal token :white_check_mark: Your 3.11 eval job has completed with return code 0.

<module 'base64' from '/usr/local/lib/python3.11/base64.py'>
primal token
abstract lark
#

hi please can anyone help in my python programming question

pastel basin
#

How to run multiple bots in a single block of code discord.py?

sick birch
#

generally not worth doing

#

just run 2 different processes

vale wing
#

Discord just displays as there's a new line but in fact there's no

slate swan
vale wing
pastel basin
#

Should I start coding bots later or now? I don't know about tuples and class but know about other data structures.

#

Async programming isn't also that complicated..

primal token
vale wing
#

More cringe?

sick birch
# pastel basin Async programming isn't also that complicated..

Depends on what you think async programming is. Just "stick await in frnot of everything" is an incomplete understanding of asyncio, and hence would seem easy. I would say having an intermediate knowledge of asynchronous programming as a general concept, and as python's implementation is quite important as well as intermediate python would greatly help speed along the process

primal token
wary shadow
sick birch
#

I also find that people just like to dive into discord bots as their first foray into discord bots, but from what I see a lot, these people end up fighting with the language rather than using it as a tool and working on their bot

primal token
#

Automate the Boring Stuff is boringpithink

vale wing
sick birch
#

It becomes a mindset of "How do i get python to do what I want it to" instead of "How can I make my bot do what I want it to?"

pastel basin
pastel basin
vale wing
sick birch
wary shadow
#

Yeah. Bots are cool. They do what you tell them on a platform others can see. It's the right mixture of allure to make them the starting project for many. That's fine, so long as you know the uphill learning challenge is steeper.

pastel basin
pastel basin
#

I have already made this game months ago but... gonna code it in bot.

dull terrace
#

I also did it entirely in one file

#

Would not recommend

cerulean folio
#

hi people !
there's something i'd like to ask but didn't find the proper community to ask:
Someone told me "when you click an image on discord, never click that 'Open Original' because you can get hacked, and I know how to make such images"
I highly suspect that dude to flex and being a bit mythomaniac but you know I said after all it might be true and googled it, and found out there are some tricks possible by adding a VBScript at the end of the text file that could change your windows wallpaper. So I started doubting.

Are images on discord possibily a security breach? :o

slate swan
#

you'll eventually learn classes since discord.py ( or actually any general usage python library) is designed that way

pliant gulch
# cerulean folio hi people ! there's something i'd like to ask but didn't find the proper communi...

The images you see inside of discord are embeds they are embedded into discord from the information of whatever website link was sent. There is always a risk of a website being malicious potentially. Some websites could utilize vulnerabilities to "hack" your computer, etc. Some might just grab your IP address. You're relatively safe by viewing only through discord. Unless you trust the site you should try to avoid opening original

slate swan
#

thats not the same for images that people upload manually on discord right

#

cuz its just some bytes

pliant gulch
#

Bytes are still harmful generally speaking. I would say your safe from an attack via the website directly as uploaded images go through the discord CDN when you view

#

There is however a chance where there is some kind of vulnerability with the CDN

#

Unless for whatever reason you'd need to open the original I would suggest just viewing it via discord

#

This is pretty much do-able with hex editing though, I think I have a non-malicious example

primal token
primal token
#

😭

cerulean folio
cerulean folio
cerulean folio
pliant gulch
primal token
cerulean folio
#

alright I get it, but indeed what andy said is right, when you paste an image link it doesn't get into discord's CDN, so you get an embed of the image and that "Open Original" will bring you to the link that got shared which opening it on browser could be malicious for sure. Alrightie !

paper sluice
#

!e

print(False == 'False')
unkempt canyonBOT
#

@paper sluice :white_check_mark: Your 3.11 eval job has completed with return code 0.

False
paper sluice
#

the false you get from getpuuid['data'][0]['teams']['red']['has_won'] is probably a boolean, you are trying to compare it with a string which is False

cerulean folio
#
result = "Win" if getpuuid['data'][0]['teams']['red']['has_won'] == True else "Lose"
print(result)

That's one way to fix it. But in your case you have another option for not working ^^

light jungle
#

anyone have an example of a giveaway bot?

glad cradle
split nest
#

can someone help me out with the code for adding roles, i forgot it

cerulean folio
slate swan
unkempt canyonBOT
#

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

Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")s.

You must have [`manage_roles`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
slate swan
pliant gulch
#

In some cases omitting the actual check and only seeing if it is truthy will be slower than checking the identity of the thing

hasty bison
#
@bot.event
async def on_ready():
    Channel = bot.get_channel(1027322918570573925)
    Text= "TEST"
    Moji = await Channel.send(Text)
    await Moji.add_reaction('🏃')
@bot.event
async def on_reaction_add(reaction, user):
    Channel = bot.get_channel(1027322918570573925)
    if reaction.message.channel.id != 1027322918570573925:
        return
    if reaction.emoji == "🏃":
        role = get(user.roles, name="Verified")
        await bot.add_roles(user, Verified)
#
    await coro(*args, **kwargs)
  File "C:\Users\User\PycharmProjects\PYBOT\main.py", line 88, in on_reaction_add
    await bot.add_roles(user, Verified)
AttributeError: 'Bot' object has no attribute 'add_roles'```
#

please help the below one is the error

glad cradle
#

!d discord.Member.add_roles

unkempt canyonBOT
#

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

Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")s.

You must have [`manage_roles`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
hasty bison
austere vale
#

im trying to code my bot to send a message when i go live on twitch. how can i get my client id and bot token? or do i not need one?

slate swan
hasty bison
#

thank you anyway

#
#Clear Messages Command
@bot.command(aliases= ['purge','delete'])
@commands.has_permissions(manage_messages=True)
async def clearall(ctx, amount=None):
    if amount == None:
        await ctx.channel.purge(limit=1000000)
        await ctx.send(ctx.message.author.mention + '  `Clear Messages Command` ** has been used succesfully**')
        time.wait(1)
        await message.delete()
#

it doesn't delete the msg afterwards

slate swan
#

because you don’t have a message object so ur not deleting anything

hasty bison
#

i think ive found it

#

lemme try

#

still havent found it

spark saddle
#

I need help with a lfp command ill send u a dm of an example.

#

also give Role

slate swan
#

you probably won't need the discord bot's client id

spark saddle
austere vale
slate swan
slate swan
austere vale
spark saddle
#

no but i do have an error with this member thingy

#

async def mir(ctx, role: discord.Role):

  members = []
  try:
    for member in role.members:
      members.append(f"\n {member.mention} `{member}`")
  except Exception as err:
    print(err)
    return await ctx.respond('error', ephemeral=True)
    
  
  e = discord.Embed(title=role.name, description=''.join(members), color=role.color)
  await ctx.respond(embed=e, ephemeral=True)
#

is the code @slate swan

slate swan
austere vale
#

idk, ive never done this before so thats why im trying to look at ways to code it

slate swan
slate swan
#

if you haven't made any progress with nextcord yet, im aware of libs with twitch integration

spark saddle
#

oops

slate swan
#

like what if they don't use rich presense

#

yeah that’s the only catch

#

and if twich api exists, why not use it

spark saddle
slate swan
unkempt canyonBOT
slate swan
#

prob sure twitch has endpoints for started streaming too

slate swan
#

well that’s what I was gonna say last time I checked they don’t, you have to make a task to check

#

if they’re streaming

spark saddle
slate swan
austere vale
# slate swan how much are you done with the discord bot part?

i have this right now

  @commands.Cog.listener()
  @tasks.loop(seconds=10)
  async def check_For_live_secretsocietyserver(self,ctx):
    channel = self.bot.get_channel(1016937526046502973)
    API_ENDPOINT = 'https://api.twitch.tv/helix/streams?user_login=secretsocietyserver 10'
    Client_ID = "client_id"
    botToken = "discordbottoken"
    head = {
        'client-id': Client_ID,
        'authorization': 'Bearer ' + 'discordbottoken'
    }
    r = requests.get(url=API_ENDPOINT, headers=head, )
    w = r.text
    if "live" in w:
        e = nextcord.Embed(
            color=nextcord.Color(0x9146ff),
            description=f"Playing (game) for (viewers) viewers\n[Watch Stream]('https://www.twitch.tv/secretsocietyserver')",
            timestamp=datetime.datetime.utcnow())
        e.set_footer(text="Notification preview")
        e.set_author(
            name="The Secret Society is now live on Twitch!",
            url='https://www.twitch.tv/secretsocietyserver',
            icon_url='https://cdn.discordapp.com/attachments/917184938690899971/1009332026148667392/A7049B45-44C4-4E5F-8498-BC11A585F442.jpg')
        e.set_image(url="https://images-ext-1.discordapp.net/external/FueXlfSkrjOeYMx92Qe3Y2AaV4G5dk9ijVlNGpF-AgU/https/static-cdn.jtvnw.net/previews-ttv/live_user_overwatchcontenders-1920x1080.jpg")
        await channel.send(embed=e)
        time.sleep(1800)
    else:
        print(w)
        time.sleep(1)
#

but the async def function doesnt exist obviously haha

slate swan
#

ur better off using presence updates lol.

#
@Cog.listener()
    async def on_presence_update(self, before: disnake.Member, after: disnake.Member):
        role = after.guild.get_role(985059814583459851)
        channel = after.guild.get_channel(985055579569541141)
        for activity in after.activities:
            if isinstance(activity, disnake.Streaming):
                if role in after.roles:
                    embed = disnake.Embed(title=activity.name, url=activity.url, description=activity.game)
                    embed.set_author(name=activity.twitch_name, icon_url=after.avatar.url)
                    embed.set_thumbnail(url=after.avatar.url)
                    embed.set_image(url=f"https://static-cdn.jtvnw.net/previews-ttv/live_user_{activity.twitch_name}-500x500.jpg")
                    
                    await channel.send(content=f"Hey {after.guild.default_role.mention}. {activity.twitch_name} is now streaming @ {activity.url}!", embed=embed)
spark saddle
slate swan
austere vale
spark saddle
slate swan
austere vale
#

mans just pinging everyone bugcat_laugh

slate swan
#

lmao

spark saddle
#
@slash_command
member_object.add_roles(role_object)
embed.set_description()```
#

?? @slate swan

austere vale
#

why dont you just try it instead of pinging to ask if something works

#

u dont even have anything inside to set the description to

plucky forge
spark saddle
plucky forge
#

I have installed discord-components and i don's know what's happend

austere vale
#

@spark saddle ok but you could easily answer your own question by attempting to run the code and seeing that it results in an error, why are you asking other ppl if something works when they're not the one running the code?

austere vale
#

the error? you run the code and the error pops up in your console

spark saddle
#

oh ok

#

thanks

spark saddle
slate swan
spark saddle
#

oops

#

wrong guy

spark saddle
slate swan
plucky forge
slate swan
#

that library isn't really under development anymore
avoid using it

plucky forge
#

@slate swan and what button library exists now?

slate swan
plucky forge
#

obvious

slate swan
slate swan
plucky forge
#

xd

#

but

#

i try to make an atractive user interface in my discord bot

spark saddle
#

how do i make a command that gives a role to a specific user and a specific role? with slash command, options.

slate swan
#

hey

#

what lib should i use for making my bot

primal token
#

I prefer disnake because of their implementation of slash commands, it's quite easier

flat pier
#

in dpy its literally just a decorator, you sync then you use commands, not very hard at all

spark saddle
#

Guys how do you add a role to a specific user, specific role?

slate swan
spark saddle
spark saddle
#

anyone?

spark saddle
#

i really need to learn python

flat pier
slate swan
#

i don't think making a bot is for newbies

#

someone told me same

flat pier
#

100%, especially in discord.py and other libs there's a lot of complex/advanced concepts going on and it simply can be hard for new python users to use discord.py

spark saddle
#

Member.add_roles is that it im trying to make it slash command @flat pier

#

it would be @gloomy cloak.slash or sum

slate swan
#

you have to get the user then use that on that user

flat pier
slate swan
#

get user with slash command

spark saddle
deep saddle
#

why does this not work ```weight = input('Weight: ')

switch = input('(L)lbs or (K)g: ')

switch = switch.upper

if switch == 'L':
mathL = weight / 2.205
print(mathL)```

flat pier
spark saddle
flat pier
spark saddle
#

embed.set_description()
embed.set_title()

#

like that?

primal token
flat pier
#

its a command tree, same thing differen't wording

primal token
#

Literally makes no sense kek

spark saddle
flat pier
#

not to mention its named app_commands in Cogs

spark saddle
#

embed.set_title(Sign Command)
embed.set_description(User has been signed to a team)
Member.add_roles
#

is my code

primal token
pliant gulch
#

A tree is just separating the interface into a different area making it easier to navigate

#

It's more modular as well since you can subclass, etc

primal token
pliant gulch
#

But context commands make sense for that as you have a DIFFERENT class for commands, E.g commands.Bot not Client

slate swan
#

the tree stuff is a load of horse shit 🤣

primal token
pliant gulch
#

And what do you think the tree is, bound too..??

#

Do you magically somehow get state, do you magically somehow get rest?

primal token
#

The app commands would still be bounded to the tree technically?

pliant gulch
#

And therefor it's bound to the client no?

primal token
#

They just probably get internally parsed and setup etc

#

I'm not sure, dont you setup your app commands with an instance of a tree?

pliant gulch
#

And what do you think you need to make that tree...?

unkempt canyonBOT
#

examples/app_commands/basic.py lines 10 to 20

class MyClient(discord.Client):
    def __init__(self, *, intents: discord.Intents):
        super().__init__(intents=intents)
        # A CommandTree is a special type that holds all the application command
        # state required to make it work. This is a separate class because it
        # allows all the extra state to be opt-in.
        # Whenever you want to work with application commands, your tree is used
        # to store and work with them.
        # Note: When using commands.Bot instead of discord.Client, the bot will
        # maintain its own tree instead.
        self.tree = app_commands.CommandTree(self)```
primal token
#

Which you would use CommandTree.app_command?

pliant gulch
#

Is that no different from client.slash_command?

#

It's literally just another decorator

#

Your separating the code which is good

#

It's like saying, why use Cogs when I can put all the commands in the main file

#

I didn't design trees myself but I assume a huge point about that is modularity

#

I don't see how it gets any more complex in the way you put it

#

It's literally the same access like usual, a decorator

primal token
#

I'm not saying it's not good, I'm just saying its abstractions are quite questionable especially for something that shouldnt be so complex, in discords API it's just app commands bounded to your application I'm not sure why you would make it more complex than that, that just makes more confusion, going to your modular point, cant you just set the app command in a cog in disnake?

flat pier
#

you can do the same in dpy?

primal token
#

Never said you cant

#

We cant forget about pythons zen:

Simple is better than complex.

Complex is better than complicated.

pliant gulch
wicked atlas
#

HTTP interactions > gateway interactions imo

pliant gulch
#

If the wrapper decides to make it complicated great. But as a user you are negligibly effected by it

#

It's literally, just another attribute, just another decorator, and done

pliant gulch
wicked atlas
#

You don't even need to have it as an attribute either, you can define it wherever the heck you want, as long as you can pass a Client into it.

primal token
flat pier
#

how? its literally all you do to create a slash command

primal token
#

Eitheir way, this discussion is all based on opinions and personal preference

slate swan
#

^

primal token
#

I ment it's not completely true in a sense of abstractions

#

Its not only another attribute and decorator as ive seen theres more steps to it

hushed galleon
#

in a way they took both implementation approaches as for the base client the command tree is (almost) completely decoupled, but for the commands extension they had to reference the tree several times in the bot/cog to provide a convenient integration of application commands

#

i.e. if you used Client + CommandTree you always have to reference the tree in order to manage your app commands, but for Bot you get the option to use @app_commands.command() in a cog or the @bot.hybrid_command() decorator which just turns into an app command for you, without the .tree step

flat pier
#

yea its simple to me which confused me as to why noid said it was complex after i told someone it isn't very hard to create a slash command

primal token
#

It's simple as you probably already have done it, but to me it's a bit overly complex and complicated and many beginners have issues with them e.g how to sync them and where or when to sync them, i'm not saying disnakes implementation doesnt raise questions either

flat pier
#

how to sync and "where" to sync is a thing (or should be a thing) in every lang, no lib should be syncing for you in my opinion

primal token
#

Not sure why given the user a bit more of complication is necessary but sure not wasting a few of the requests to sync your app commands isnt a problem to me, I'm not even sure a lib like disnake even waste those request to sync your commands, either way the limit per day is 200/1d so i wouldnt say that's quite an issue, it can happen as ive seen it happen which it only happened when the user did it manually, which made the user question where to sync the app commands

meager chasm
# flat pier yea its simple to me which confused me as to why noid said it was complex after ...

well, that is because noid is very smart in the aspect of developing. so when noid explains something to someone who doesnt have the same knowledge, it may be looked at as confusing because noid is explaining something with the assumption it can be understood as simply as he/she understands the topic. so yeah it creates confusion. thats why you ask more and more. the more you ask the more you know. dont walk away misunderstanding the topic because one explanation didnt give you the knowledge needed. im sure noid would have been willing to break down the explanation.

flat pier
#

so im dumb for saying something is simple to me and complex for them (in a way)? this convo had already been broken down lol

rugged shadow
#

explain argument in fortnite terms

slate swan
meager chasm
rugged shadow
#

copypasta??

#

i dont think it is

meager chasm
#

Piece of text which is copied and pasted with minor modifications for humorous purposes

flat pier
#

im not offended at all it was just a random response loll

meager chasm
flat pier
meager chasm
#

But with andy instead of noid

rugged shadow
#

ok

#

but it seems like a valid argument though

#

it's a common situation with helpers honestly

slate swan
flat pier
#

they weren't trying to make a point?

it is a copypasta
either way i dont care to argue it anymore

eternal delta
#

Just normally

thorny flint
#

Anyone who have an example of a paginator with Embeds and components?

I've made one'ish, but the current page is keep messing up.
I have the embeds and views of components like this,

the_list = [[embed, view], [embed, view], [embed, view]]

They get added with a loop,, where each embed and view is different.

How can I add a paginator to that, without also messing up the current page (and total pages) ?

I'm using dpy v2

glad cradle
# thorny flint Anyone who have an example of a paginator with Embeds **and** components? I've ...

you could look at my repo, it isn't made using discordpy however even if it's made with disnake the concept is the same

https://github.com/Snipy7374/disnake-ext-paginator

GitHub

A very simple extension to easily create customizable Paginator - GitHub - Snipy7374/disnake-ext-paginator: A very simple extension to easily create customizable Paginator

thorny flint
#

and when going to next page, the components changes too

glad cradle
#

maybe I'll try to do a paginator with multy view

thorny flint
#

I'm probably looking on it in a wrong way, because right now, when I switch pages the current page index button gets messed up

glad cradle
#

how are you unpacking the lists of embed and view?

#

you're using static indexes?

#

if you want you can share the code

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.

thorny flint
#

Not on my pc now, but, well, first I made I added all the components to a list with the embeds..
So they go like this:
[[embed, [btn1, btn2, btn3, btn4, btn5], [embed, [btn6, btn7...]... ]
That was to get the total pages.
I then added the 5 buttons of each elements to a View, which i then replaced them with,
so it became like this, [[embed, view], [embed, view]...]

Sorry, I'm typing from my phone atm

#

For each element i added there was a a custom variable which was the current page.
That's where it gets messed.
Since they go +1 or - 1 everytime I go previous or next page

glad cradle
#

you should treat the sublist as the same way you treat it when there are only embeds and unpack two variables from it

first get the sublist with the page index

page_index = 1
components = [[...], ...]
msg_component = components[page_index]
embed, msg_view = msg_component

where msg_component is the sublist, e.g [embed, view]

note that that's only an example and it won't work if you copy paste it, I've made it just to let you understand

#

I haven't test this logic but should work well

thorny flint
#

I'm having a brain fart now. Need some rest

glad cradle
kind trellis
#

I want to send a log embed for when a member gets timed out. How do I do that?

hasty bison
#
#Clear Messages Command
@bot.command(aliases= ['purge','delete'])
@commands.has_permissions(manage_messages=True)
async def clearall(ctx, amount=None):
    if amount == None:
        await ctx.channel.purge(limit=1000000)
        await ctx.send(ctx.message.author.mention + '  `Clear Messages Command` ** has been used succesfully**')
        time.wait(1)
        msg = message.content.lower()
        if ".clearall" in msg:
            await message.delete()```
#

it doesn't delete the message

slate swan
meager chasm
#

!d discord.on_member_update

unkempt canyonBOT
#

discord.on_member_update(before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") updates their profile.

This is called when one or more of the following things change...
meager chasm
#

That channel is closed

kind trellis
#

I know, but it'll help you catch up

meager chasm
#

Ok so ur question is how to get duration of time out?

kind trellis
#

Yeah

#

So far, the only solution that has been found is with datetime

meager chasm
#

You will need to get datetime of when the timeout was issued

#

Through audit log or storing it urself

kind trellis
meager chasm
#

U have to go through audit log and find the correct entry

kind trellis
#

Alright. I'll do it later

naive briar
#

You could use on_member_update and check if the member got timed out and save it somewhere instead of looping through the audit log entries, but you do you

kind trellis
slate swan
#

on_member_update provides you the member object that has those fields

#

!d discord.Member.timed_out_until

unkempt canyonBOT
#

An aware datetime object that specifies the date and time in UTC that the member’s time out will expire. This will be set to None if the user is not timed out.

New in version 2.0.

naive briar
slate swan
#

lucas owo

#

okay so you need to await load_extensions now

#

that code is outdated

#

for the most of part yes

#

yes exactly

#

yep, but inside an asyncio.run()

#

yes

#

both bot.run and start works

#

you'll be awaiting start tho

#

hm is the cog loaded

naive briar
#

bot.run isn't a coroutine, so don't await it smh

upbeat gust
#

!e x += 1

unkempt canyonBOT
#

@upbeat gust :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | NameError: name 'x' is not defined
slate swan
#

no worries

smoky cedar
#

can someone help? is my ban command good?



@client.command()
async def ban(ctx, member : discord.Member, *, reason=None):
  await member.ban(reason=reason)
  await ctx.send(f'**SUCCESSFULLY BANNED** __**{member}**__!')

@ban.error
async def ban_error(ctx, error: client_commands.AppCommandError):
  if isinstance(error, client_commands.MissingRole): 
    await ctx.reply(f"You dont have that perms.")

rugged shadow
smoky cedar
#

oh yes

fresh ferry
#

hey everyone, was wondering if anyones attempted to make a bot which dms the user the moment they join your server?? im wanting to make one so users have a FAQ about the server plus a cool cat gif at the bottom ahah

rugged shadow
unkempt canyonBOT
#

discord.on_member_join(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") joins a [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild "discord.Guild").

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

??

rugged shadow
smoky cedar
#

there is one

primal token
#

!d discord.ext.commands.Command.error

unkempt canyonBOT
#

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

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

Changed in version 2.0: `coro` parameter is now positional-only.
smoky cedar
#

like this?



@client.command()
async def ban(ctx, member : discord.Member, *, reason=None):
  await member.ban(reason=reason)
  await ctx.send(f'**SUCCESSFULLY BANNED** __**{member}**__!')

@ban.error
async def ban_error(ctx, error: client_commands.AppCommandError):
  if isinstance(error, client_commands.MissingRole): 
    await ctx.reply(f"You dont have that perms.")

#

or this?



@client.command()
async def ban(ctx, member : discord.Member, *, reason=None):
  await member.ban(reason=reason)
  await ctx.send(f'**SUCCESSFULLY BANNED** __**{member}**__!')

@ban.error
async def ban_error(ctx, error: on_commands.error): 
 if isinstance(error, client_commands.MissingRole): 
    await ctx.reply(f"You dont have that perms.")

tidal hawk
#

How to view user Activity through Discord API ?

#

with request

slate swan
tidal hawk
#

Yeap

slate swan
#

not possible without gateway

#

you get it thru gateway events

tidal hawk
#

damn okay

#

Does anyone know some sort of Discord's voice gateway libraries? To securely join voice chats through my own website xd

slate swan
#

most libraries implement sending voice

#

pycord and nextcord has recieve support too

tidal hawk
slate swan
tidal hawk
#

Welp I need to do it through raw api, so I'm going to need to find out, how they are doing it

#

Bruh it's not actually supported

pastel basin
slate swan
#

*is

tidal hawk
#

Mhm

tepid dagger
#

idk where this would fit so im sending it here randomly but where can i find commands and stuff for the kahoot api

#

lol

rugged shadow
shadow vigil
#

what is discord.utils.find?

slate swan
#

!d discord.utils.find its like get but can search thru a function as well

unkempt canyonBOT
#

discord.utils.find(predicate, iterable, /)```
A helper to return the first element found in the sequence that meets the predicate. For example:

```py
member = discord.utils.find(lambda m: m.name == 'Mighty', channel.guild.members)
```  would find the first [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") whose name is ‘Mighty’ and return it. If an entry is not found, then `None` is returned.

This is different from [`filter()`](https://docs.python.org/3/library/functions.html#filter "(in Python v3.10)") due to the fact it stops the moment it finds a valid entry.

Changed in version 2.0: Both parameters are now positional-only.

Changed in version 2.0: The `iterable` parameter supports [asynchronous iterable](https://docs.python.org/3/glossary.html#term-asynchronous-iterable "(in Python v3.10)")s.
slate swan
#

.get works with with a particular attribute, .find works with a user defined function

tepid dagger
meager chasm
tepid dagger
#

alr

tepid dagger
#

im pretty sure the thing is js so idk how to translate to python lol

meager chasm
slate swan
#

lmao it was originally written in js

#

but well, it's better if you make your own scraper since that lib has a lot of issues and is severely undocumented

uncut comet
#
    valorant = app_commands.Group(name="valorant", description="Valorant Commands")
    #@app_commands.command(description='Valorant Commands')
    #async def valorant(self, ctx):
    #    await ctx.send("WIP val commands")
    @valorant.command(description='Log in with your Riot acoount')
    #@valorant.describe(username='Input username', password='Input password')
    # @dynamic_cooldown(cooldown_5s)
    async def login(self, interaction: Interaction, username: str, password: str) -> None:

        response = ResponseLanguage(interaction.command.name, interaction.locale)

i am trying to make sub commands for app_commands but now they arent appearing when i sync the commands and try to type them out am i mission something?

slate swan
#

and you'll have to use @app_commands.describe

uncut comet
#

Yup i can

slate swan
#

cool

white citrus
#
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\client.py", line 502, in _run_event
    await coro(*args, **kwargs)
  File "c:\Discord\Maja Projekt\MajaSystem_Test\bot.py", line 200, in on_application_command_error
    raise error
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\application_command.py", line 863, in invoke_callback_with_hooks
    await self(interaction, *args, **kwargs)
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\cooldowns\cooldown.py", line 93, in inner
    result = await func(*args, **kwargs)
  File "c:\Discord\Maja Projekt\MajaSystem_Test\modules\information\cog.py", line 200, in userinfo
    await interaction.edit_original_message(embed=userinfo, view=view)
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\interactions.py", line 451, in edit_original_message
    params = handle_message_parameters(
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\webhook\async_.py", line 537, in handle_message_parameters
    payload["components"] = view.to_components()
AttributeError: 'coroutine' object has no attribute 'to_components'```
uncut comet
# slate swan cool

well i tried to show you but uh
discord.errors.HTTPException: 400 Bad Request (error code: 30034): Max number of daily application command creates has been reached (200)

white citrus
# white citrus ```Traceback (most recent call last): File "C:\Users\domin\AppData\Local\Progr...
    @nextcord.slash_command(name="userinfo", description="Shows you a user info of a user!")    
    @custom_check.has_moderation_and_admin_role_interaction()
    @custom_check.If_User_on_UserBlacklist_Slash()
    @cooldowns.cooldown(1, 25, bucket=cooldowns.SlashBucket.guild)
    async def userinfo(self, interaction: nextcord.Interaction,
                       _member: nextcord.Member = SlashOption(name="member", description="Please select a member", required=False)):
        
        member = _member or interaction.user
        await interaction.response.send_message(embed=wait)

        @nextcord.ui.button(label="Show all Roles", style=nextcord.ButtonStyle.blurple)
        async def show_member_roles(interaction: nextcord.Interaction):
            all_roles = await interaction.user.get_roles(interaction.user)
            embed_roles = nextcord.Embed(description=all_roles)
            await interaction.response.send_message(embed=embed_roles)
            
        view = show_member_roles(interaction)
            
        de = pytz.timezone('Europe/Berlin')
        await self.universal_log_embed_slash(interaction, _member=_member)        
        await interaction.edit_original_message(embed=userinfo, view=view)```
spark saddle
#

yo anyone can help me with a slash command add role to a specific user and a specific team?

slate swan
spark saddle
#

async def mir(ctx, role: discord.Role):

  members = []
  try:
    for member in role.members:
      members.append(f"\n {member.mention} `{member}`")
  except Exception as err:
    print(err)
    return await ctx.respond('error', ephemeral=True)
    
  
  e = discord.Embed(title=role.name, description=''.join(members), color=role.color)
  await ctx.respond(embed=e, ephemeral=True)
slate swan
#

py-cord?

spark saddle
slate swan
#

that's seriously invalid

uncut comet
spark saddle
slate swan
slate swan
spark saddle
#

which one

spark saddle
#

#channel?

slate swan
spark saddle
#

OH

#

Can someone help me fix this code?


async def mir(ctx, role: discord.Role):

  members = []
  try:
    for member in role.members:
      members.append(f"\n {member.mention} `{member}`")
  except Exception as err:
    print(err)
    return await ctx.respond('error', ephemeral=True)
    
  
  e = discord.Embed(title=role.name, description=''.join(members), color=role.color)
  await ctx.respond(embed=e, ephemeral=True)
#

doesnt need to be slash

slate swan
#

ctx.respond is still invalid

spark saddle
#

how do i fix that?

vocal snow
#

That has to be pycord

slate swan
#

ephemeral is also not a kwarg

#

that's literally py-cord lmao

spark saddle
#

oh its pycord?

slate swan
#

...

vocal snow
#

...you don't know the library your own code uses?

slate swan
#

imma take my leave lmao

spark saddle
spark saddle
vocal snow
vocal snow
spark saddle
vocal snow
#

How are you planning on running it?a

vocal snow
#

And malicious things don't necessarily need to be downloaded

#

So i hope you trust your source

spark saddle
#

import discord
from discord.ext import commands

client - commands.Bot(command_prefix - '-')

@client.event
async def on_ready():
    print('Drome is Online')

@client.command(aliases['p'])
async def ping(ctx):
    await ctx.send('Pong!')

@client.command(aliases=['8ball', '8b'])
async def _8ball(ctx, *, question):
  responses = [
        'Hell no.',
        'Prolly not.',
        'Idk bro.',
        'Prolly.',
        'Hell yeah my dude.',
        'It is certain.',
        'It is decidedly so.',
        'Without a Doubt.',
        'Yes - Definitaly.',
        'You may rely on it.',
        'As i see it, Yes.',
        'Most Likely.',
        'Outlook Good.',
        'Yes!',
        'No!',
        'Signs a point to Yes!',
        'Reply Hazy, Try again.',
        'IDK but you should join my bot server ngl',
        'Better not tell you know.',
        'Cannot predict now.',
        'Concentrate and ask again.',
        "Don't Count on it.",
        'My reply is No.',
        'My sources say No.',
        'Outlook not so good.',
        'Very Doubtful']
  await ctx.send(f' :8ball: Question: (question)\n:8ball: Answer: (random.choice(responses))')


  client.run(token)
#

can someone help?

#

I made this by myself

robust fulcrum
#

Guys i want to make a python library that can help people make discord bots some easily
Can anyone suggest me any idea?

spark saddle
#

@vocal snow

#

can u help me with that

robust fulcrum
#

At what you need help?

spark saddle
#

import discord
from discord.ext import commands

client - commands.Bot(command_prefix - '-')

@client.event
async def on_ready():
    print('Drome is Online')

@client.command(aliases['p'])
async def ping(ctx):
    await ctx.send('Pong!')

@client.command(aliases=['8ball', '8b'])
async def _8ball(ctx, *, question):
  responses = [
        'Hell no.',
        'Prolly not.',
        'Idk bro.',
        'Prolly.',
        'Hell yeah my dude.',
        'It is certain.',
        'It is decidedly so.',
        'Without a Doubt.',
        'Yes - Definitaly.',
        'You may rely on it.',
        'As i see it, Yes.',
        'Most Likely.',
        'Outlook Good.',
        'Yes!',
        'No!',
        'Signs a point to Yes!',
        'Reply Hazy, Try again.',
        'IDK but you should join my bot server ngl',
        'Better not tell you know.',
        'Cannot predict now.',
        'Concentrate and ask again.',
        "Don't Count on it.",
        'My reply is No.',
        'My sources say No.',
        'Outlook not so good.',
        'Very Doubtful']
  await ctx.send(f' :8ball: Question: (question)\n:8ball: Answer: (random.choice(responses))')


  client.run(token)
#

thats the command @robust fulcrum

robust fulcrum
spark saddle
robust fulcrum
spark saddle
#

k

#

where do i put it

#

on top?

simple kettle
#

Any know any good videos to learn discord.py I have made discord bots I’m just new to the new version

robust fulcrum
spark saddle
#

command_prefix is an error

#

discord.ext

#

and thats it

robust fulcrum
#

Guys i want to make a python library that can help people make discord bots some easily
Can anyone suggest me any idea?
Pls anyone suggest me

sick birch
slate swan
unkempt canyonBOT
#
Missing required argument

package

#
Command Help

!pypi <package>
Can also use: pack, package, pip

Provide information about a specific package from PyPI.

#

The PyPA recommended tool for installing Python packages.

mental hollow
#

How can I make a select menu option for every one of my cogs using a for loop?

tidal hawk
feral frost
#

how do i use an if custom_id from a button = something

naive briar
feral frost
feral frost
#

if the button id is smth else it will print smth else

feral frost
naive briar
unkempt canyonBOT
#

property custom_id```
The ID of the button that gets received during an interaction.

If this button is for a URL, it does not have a custom ID.
feral frost
feral frost
feral frost
feral frost
feral frost
feral frost
naive briar
#

You could subclass the view and put your desired buttons and callbacks in it

unkempt canyonBOT
#

examples/views/counter.py lines 21 to 28

class Counter(discord.ui.View):

    # Define the actual button
    # When pressed, this increments the number displayed until it hits 5.
    # When it hits 5, the counter button is disabled and it turns green.
    # note: The name of the function does not matter to the library
    @discord.ui.button(label='0', style=discord.ButtonStyle.red)
    async def count(self, interaction: discord.Interaction, button: discord.ui.Button):```
slate swan
#

Can anyone help me out with a basic problem with discord bot?

#
  bot.load_extension(f'cogs.{filename[:-3]}')
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
2022-10-06 21:27:10 INFO     discord.client logging in using static token
2022-10-06 21:27:12 INFO     discord.gateway Shard ID None has connected to Gateway.```
#

i am getting this error

shrewd apex
slate swan
#

can i dm you

unkempt canyonBOT
#

Hey @hidden hazel!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.

slate swan
#

How do I add an avatar image to a webhook.

await interaction.channel.create_webhook(name="Roles", avatar=)

Idk what to put after the avatar= part

patent fjord
#
import discord
from discord.ext import commands, tasks
from discord.ext.commands import bot


class event(commands.Cog):
    def __init__(self, client) -> None:
        super().__init__()
        self.client = client

    @commands.command()
    async def hello(self, ctx):
        await ctx.send(f'Hello')
    
async def setup(client: commands.Bot):
    await client.add_cog(event(client))

why my code dont work?
who can help me please

primal token
#

users is a list

#

!e

print([1]["1"])
unkempt canyonBOT
#

@primal token :x: Your 3.11 eval job has completed with return code 1.

001 | <string>:1: SyntaxWarning: list indices must be integers or slices, not str; perhaps you missed a comma?
002 | Traceback (most recent call last):
003 |   File "<string>", line 1, in <module>
004 | TypeError: list indices must be integers or slices, not str
primal token
#

You can only index elements from a list with their position

naive briar
unkempt canyonBOT
#

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

Creates a webhook for this channel.

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

Changed in version 1.1: Added the `reason` keyword-only parameter.
torn sail
#

len(bot.commands)

#

I think

tidal hawk
#

lol

limber bison
#

bot perms !!
overwrites = {
guild.me : discord.PermissionOverwrite(manage_channels = True , view_channel= True , manage_permissions = True) ,
guild.default_role: discord.PermissionOverwrite(connect=False) ,
discord.Object(ctx.author.id): discord.PermissionOverwrite(connect=True)
}
PVC = await guild.create_voice_channel(f"{ctx.author.name}'s Pvc" , position = 0 , category = discord.Object(pvc_category) , overwrites=overwrites)

#

use correctly Hybrid command raised an error: Command 'pvc' raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions

error

plain cedar
#

What can i do ? Can someone help me ?

cinder nacelle
#

TextInput(
style=TextStyleType.SHORT,
label="Enter The Code",
value="Enter The Code That You Have Been Given!",
custom_id="text-input-1"
)

#

textstyletype is not there or something

cinder nacelle
slate swan
cinder nacelle
cinder nacelle
#
    code = discord.ui.TextInput(label="Enter The Code")
    async def on_submit(self, interaction: discord.Interaction):
        await interaction.response.send_message(code, ephemeral=True)``` so i got my modal and when i enter everything it is all working but i can't seem to get the entered data please help
indigo pilot
#

hey, does anyone know how i can make a specific button for each item in a dict

torn sail
#

!d discord.ui.TextInput.value

unkempt canyonBOT
spark saddle
#

import token
from discord.ext import commands

client = commands.Bot(command_prefix - '-')

@client.event
async def on_ready():
    print('Drome is Online')

@client.command(aliases=['p'])
async def ping(ctx):
    await ctx.send('Pong!')

@client.command(aliases=['8ball', '8b'])
async def _8ball(ctx, *, question):
  responses = [
        'Hell no.',
        'Prolly not.',
        'Idk bro.',
        'Prolly.',
        'Hell yeah my dude.',
        'It is certain.',
        'It is decidedly so.',
        'Without a Doubt.',
        'Yes - Definitaly.',
        'You may rely on it.',
        'As i see it, Yes.',
        'Most Likely.',
        'Outlook Good.',
        'Yes!',
        'No!',
        'Signs a point to Yes!',
        'Reply Hazy, Try again.',
        'IDK but you should join my bot server ngl',
        'Better not tell you know.',
        'Cannot predict now.',
        'Concentrate and ask again.',
        "Don't Count on it.",
        'My reply is No.',
        'My sources say No.',
        'Outlook not so good.',
        'Very Doubtful']
  await ctx.send(f' :8ball: Question: (question)\n:8ball: Answer: (random.choice(responses))')


  client.run(token)

2 errors its discord.ext and command_prefix

sick birch
sick birch
spark saddle
sick birch
#
client = commands.Bot(command_prefix - '-')

here

spark saddle
#

oh shoot

#

what abt discord.ext?

sick birch
#

To be able to import from discord.ext you need to import discord first

spark saddle
#

ok im getting 2 errors now

sick birch
#

I can't tell what those errors are but I'm guessing it's probably that you don't have discord.py installed

#

Also are you following a tutorial? That code seems familiar

spark saddle
sick birch
#

Great. Just as a note of advice though I'd either be very careful about following those tutorials or just not use them as a resource altogether

spark saddle
#

oh

#

where is my discord.py suppose to be im pretty new to this is it a extension or do i make a folder and put it inside of the folder?

#

@sick birch

spark saddle
#

Collecting discord.py
Downloading discord.py-2.0.1-py3-none-any.whl (1.1 MB)
---------------------------------------- 1.1/1.1 MB 16.6 MB/s eta 0:00:00
Collecting aiohttp<4,>=3.7.4
Downloading aiohttp-3.8.3-cp310-cp310-win_amd64.whl (319 kB)
---------------------------------------- 319.7/319.7 kB 20.6 MB/s eta 0:00:00
Collecting charset-normalizer<3.0,>=2.0
Downloading charset_normalizer-2.1.1-py3-none-any.whl (39 kB)
Collecting yarl<2.0,>=1.0
Downloading yarl-1.8.1-cp310-cp310-win_amd64.whl (55 kB)
---------------------------------------- 55.9/55.9 kB ? eta 0:00:00
Collecting frozenlist>=1.1.1
Downloading frozenlist-1.3.1-cp310-cp310-win_amd64.whl (33 kB)
Collecting aiosignal>=1.1.2
Downloading aiosignal-1.2.0-py3-none-any.whl (8.2 kB)
Collecting async-timeout<5.0,>=4.0.0a3
Downloading async_timeout-4.0.2-py3-none-any.whl (5.8 kB)
Collecting attrs>=17.3.0
Downloading attrs-22.1.0-py2.py3-none-any.whl (58 kB)
---------------------------------------- 58.8/58.8 kB ? eta 0:00:00
Collecting multidict<7.0,>=4.5
Downloading multidict-6.0.2-cp310-cp310-win_amd64.whl (27 kB)
Collecting idna>=2.0
Downloading idna-3.4-py3-none-any.whl (61 kB)
---------------------------------------- 61.5/61.5 kB ? eta 0:00:00
Installing collected packages: multidict, idna, frozenlist, charset-normalizer, attrs, async-timeout, yarl, aiosignal, aiohttp, discord.py
WARNING: The script normalizer.exe is installed in 'C:\Users\jorda\AppData\Local\Programs\Python\Python310\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed aiohttp-3.8.3 aiosignal-1.2.0 async-timeout-4.0.2 attrs

#

thats what it says

sick birch
#

Looks like it's good

#

Try running your python script again

spark saddle
#

ok now what

sick birch
#

Run your script and it should work

spark saddle
#

my token is a error now.

#

and it still dont work

sick birch
#

Can I see the error?

spark saddle
cinder nacelle
sick birch
torn sail
#

you can also use it outside of the modal cause its an attribute of the modal instance

spark saddle
#

ya no

sick birch
#

I think you're looking at the wrong tab

sick birch
# spark saddle

Select the "terminal" tab at the bottom, then run it from there

spark saddle
#

what?

cinder nacelle
sick birch
#

I believe the output is for VSCode-related things like extensions or any language servers

spark saddle
#

where

sick birch
# spark saddle

Should be at the bottom where you see "output", "debug console"

#

just hit terminal, then run your file again

spark saddle
#

its stil lthe same

sick birch
#

What's it say now?

torn sail
#

if yes then it would be nameofmodalvariable.code.value

spark saddle
#

idk what to do

sick birch
#

Yes, but can I see what it says?

spark saddle
#

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows

PS C:\Users\jorda\Documents> & 'C:\Users\jorda\AppData\Local\Programs\Python\Python310\python.exe' 'c:\Users\jorda.vscode\extensions\ms-python.python-2022.17.12791010\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher' '58588' '--' 'c:\Users\jorda\Documents\import discord.py'
Traceback (most recent call last):
File "C:\Users\jorda\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in

sick birch
#

Could you send a screenshot of your screen?

unkempt canyonBOT
#

Hey @spark saddle!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.

cinder nacelle
sick birch
#

You need to press the "save" button in the top right hand corner, then send the link

spark saddle
sick birch
#

there you go

spark saddle
#

there

sick birch
#

Now we're getting somewhere. You're missing intents

spark saddle
#

oh

sick birch
#

You can pass in default intents like so

intents = discord.Intents.default()
bot = commands.Bot(..., intents=intents)
#

You'll probably also need message content intents

spark saddle
#

where do i put that

sick birch
#

So:
You can pass in default intents like so

intents = discord.Intents.default()
intents.message_content = True

bot = commands.Bot(..., intents=intents)

make sure you enable it in your discord developer portal as well

sick birch
spark saddle
#

bruh

#

it doesnt work

sick birch
#

How does your code look like now?

spark saddle
#
import discord
from discord.ext import commands

intents = discord.Intents.default()
intents.message_content = True

bot = commands.Bot(..., intents=intents)


client = commands.Bot(command_prefix = '-')

@client.event
async def on_ready():
    print('Drome is Online')

@client.command(aliases=['p'])
async def ping(ctx):
    await ctx.send('Pong!')

@client.command(aliases=['8ball', '8b'])
async def _8ball(ctx, *, question):
  responses = [
        'Hell no.',
        'Prolly not.',
        'Idk bro.',
        'Prolly.',
        'Hell yeah my dude.',
        'It is certain.',
        'It is decidedly so.',
        'Without a Doubt.',
        'Yes - Definitaly.',
        'You may rely on it.',
        'As i see it, Yes.',
        'Most Likely.',
        'Outlook Good.',
        'Yes!',
        'No!',
        'Signs a point to Yes!',
        'Reply Hazy, Try again.',
        'IDK but you should join my bot server ngl',
        'Better not tell you know.',
        'Cannot predict now.',
        'Concentrate and ask again.',
        "Don't Count on it.",
        'My reply is No.',
        'My sources say No.',
        'Outlook not so good.',
        'Very Doubtful']
  await ctx.send(f' :8ball: Question: (question)\n:8ball: Answer: (random.choice(responses))')
  

  client.run(token)
sick birch
#

You don't need to instantiate a completely new bot instance

#
bot = commands.Bot(..., intents=intents)

I only included this to hint at where the new piece of code should go, but you already have it

#

You only need these two lines

intents = discord.Intents.default()
intents.message_content = True
#

Oh and you'll also want to pass it into your bot instance, of course

slate swan
#

What does it require to build a chatbot along with ML?

spark saddle
#

still doesnt work

sick birch
#

How does the code look now?

spark saddle
#

import discord
from discord.ext import commands

intents = discord.Intents.default()
intents.message_content = True

client = commands.Bot(command_prefix = '-')

@client.event
async def on_ready():
    print('Drome is Online')

@client.command(aliases=['p'])
async def ping(ctx):
    await ctx.send('Pong!')

@client.command(aliases=['8ball', '8b'])
async def _8ball(ctx, *, question):
  responses = [
        'Hell no.',
        'Prolly not.',
        'Idk bro.',
        'Prolly.',
        'Hell yeah my dude.',
        'It is certain.',
        'It is decidedly so.',
        'Without a Doubt.',
        'Yes - Definitaly.',
        'You may rely on it.',
        'As i see it, Yes.',
        'Most Likely.',
        'Outlook Good.',
        'Yes!',
        'No!',
        'Signs a point to Yes!',
        'Reply Hazy, Try again.',
        'IDK but you should join my bot server ngl',
        'Better not tell you know.',
        'Cannot predict now.',
        'Concentrate and ask again.',
        "Don't Count on it.",
        'My reply is No.',
        'My sources say No.',
        'Outlook not so good.',
        'Very Doubtful']
  await ctx.send(f' :8ball: Question: (question)\n:8ball: Answer: (random.choice(responses))')
  

  client.run(token)
sick birch
#

You haven't passed your intents instance into your bot constructor

#

Right now it's just kind of sitting there, not doing anything

spark saddle
#

oh

#

TypeError: init() missing 1 required keyword-only argument: 'intents'

#

it shows that now @sick birch

#

btw im using replit now

#

simpler

sick birch
#

You're sure you're passing in intents properly?

spark saddle
#

yes look

sick birch
spark saddle
#

huh

sick birch
# spark saddle simpler

I disagree, but if it works for now I suppose it's alright. Though I'd still stay away from it

spark saddle
#

intents = discord.Intents.default()
intents.message_content = True
sick birch
#

You need to pass it into your bot constructor

spark saddle
#

where do i go for that?

spark saddle
#

ok

#

wait it still says the same thing

sick birch
#

How does the code look like?

spark saddle
#
import discord
from discord.ext import commands

intents = discord.Intents.default()
intents.message_content = True

bot = commands.Bot(..., intents=intents)

client = commands.Bot(command_prefix = '-')

@client.event
async def on_ready():
    print('Drome is Online')

@client.command(aliases=['p'])
async def ping(ctx):
    await ctx.send('Pong!')

@client.command(aliases=['8ball', '8b'])
async def _8ball(ctx, *, question):
  responses = [
        'Hell no.',
        'Prolly not.',
        'Idk bro.',
        'Prolly.',
        'Hell yeah my dude.',
        'It is certain.',
        'It is decidedly so.',
        'Without a Doubt.',
        'Yes - Definitaly.',
        'You may rely on it.',
        'As i see it, Yes.',
        'Most Likely.',
        'Outlook Good.',
        'Yes!',
        'No!',
        'Signs a point to Yes!',
        'Reply Hazy, Try again.',
        'IDK but you should join my bot server ngl',
        'Better not tell you know.',
        'Cannot predict now.',
        'Concentrate and ask again.',
        "Don't Count on it.",
        'My reply is No.',
        'My sources say No.',
        'Outlook not so good.',
        'Very Doubtful']
  await ctx.send(f' :8ball: Question: (question)\n:8ball: Answer: (random.choice(responses))')
  

  client.run(token)
cinder nacelle
#

how can i get the user id of the person who pressed a specific button?

cinder nacelle
cinder nacelle
spark saddle
sick birch
spark saddle
#

no

#

command_prefix doesnt work

sick birch
#

How does it not work?

spark saddle
#

thats the error

sick birch
#

What is?

cinder nacelle
spark saddle
#

command_prefix = "-"

sick birch
#

How is that an error?

spark saddle
#

NVM

sick birch
spark saddle
#

client = commands.Bot(command_prefix = '-')

#

it is the error now

cinder nacelle
sick birch
cinder nacelle
sick birch
#

I can't help fix a problem if I don't know what's wrong

cinder nacelle
#

and i get no error in terminal

spark saddle
#

Traceback (most recent call last):
File "main.py", line 7, in <module>
client = commands.Bot(command_prefix = '-')
TypeError: init() missing 1 required keyword-only argument: 'intents'

#

thats the error

#

@sick birch

cinder nacelle
sick birch
sick birch
sick birch
spark saddle
sick birch
#

That's what you have in your code

#

You would add your intents to the end, so it looks like commands.Bot(..., intents=intents)

spark saddle
#

import discord
from discord.ext import commands

intents = discord.Intents.default()
intents.message_content = True

commands.Bot(..., intents=intents)

commands.Bot(command_prefix = '-')

@client.event
async def on_ready():
    print('Drome is Online')

@client.command(aliases=['p'])
async def ping(ctx):
    await ctx.send('Pong!')

@client.command(aliases=['8ball', '8b'])
async def _8ball(ctx, *, question):
  responses = [
        'Hell no.',
        'Prolly not.',
        'Idk bro.',
        'Prolly.',
        'Hell yeah my dude.',
        'It is certain.',
        'It is decidedly so.',
        'Without a Doubt.',
        'Yes - Definitaly.',
        'You may rely on it.',
        'As i see it, Yes.',
        'Most Likely.',
        'Outlook Good.',
        'Yes!',
        'No!',
        'Signs a point to Yes!',
        'Reply Hazy, Try again.',
        'IDK but you should join my bot server ngl',
        'Better not tell you know.',
        'Cannot predict now.',
        'Concentrate and ask again.',
        "Don't Count on it.",
        'My reply is No.',
        'My sources say No.',
        'Outlook not so good.',
        'Very Doubtful']
  await ctx.send(f' :8ball: Question: (question)\n:8ball: Answer: (random.choice(responses))')
  
commands.Bot(..., intents=intents) 

client.run(token)
#

oops

#

i removed it now

fading marlin
#

you're just instantiating commands.Bot, you're not assigning the object to a variable. f-strings are with curly brackets: {}, not parenthesis

thorny flint
#

Anyone who have an example of a paginator with Embeds and components?

I've made one'ish, but the current page is keep messing up.
I have the embeds and views of components like this,
the_list = [[embed, view], [embed, view], [embed, view]]

They get added with a loop,, where each embed and view is different.

How can I add a paginator to that, without also messing up the current page (and total pages) ?

I'm using dpy v2
A screenshot example I made in V1 with another old 3rd party

spark saddle
#

guys how do i download discord.ext

sick birch
#

It's included in the discord module

primal token
sick birch
#

it gets the point across

#

I'd use the right term if that was their question, but these are 2 unrelated questions

primal token
#

Never said it didn't, but it's not exactly correct, talking about questions, isnt it better giving the correct view/point correctly with the correct terminology over raising questions or causing more trouble to a user, helpers should give great help over help that may cause further questions because of the wrong usage of terms, no? Not saying your help isnt good, but of course it should be as exact as possible

https://docs.python.org/3/tutorial/modules.html

A module is a file containing Python definitions and statements.

thorny flint
#

uhm, so how do I take a variable from outer class?

I basically have a View class inside a Cog,

So example

class the_cog(commands.Cog):
    def __init__(self, bot: commands.Bot) -> None:
        self.bot = bot
        self.a_list = []

    class the_view(discord.ui.View):
        def __init__(self):
            super().__init__(timeout=None)
            print(len(the_cog(None).a_list))

    @commands.command(name="nice_command")
    async def nice_command(self, ctx: commands.Context):
        self.a_list.append("Anything")

        view = the_cog.the_view()

async def setup(bot):
    await bot.add_cog(the_cog(bot))

Like example this would still print 0 instead of Anything in print(len(the_cog(None).a_list)) under the_view

primal token
sick birch
# primal token Never said it didn't, but it's not exactly correct, talking about questions, isn...

over raising questions or causing more trouble to a user
You're right, in this case it really doesn't matter. It probably seems to people that modules and libraries are interchangeable terms, I could've used either. Module came to my head first, so I used it. In the vast majority of cases though, trying too hard to be terminologically (i don't know if that's a word) can and will raise more questions, so I try to use the most laymen terms I can so we can solve the question on hand instead of going on tangents to try and explain some terminology I used. In this case you're correct though, thanks for pointing it out

thorny flint
primal token
primal token
#

The logic of the code isnt correct

fresh ferry
#

Im wanting to make the bot send an embed instead of message ?? any ideas how i could do that ??

import discord
import asyncio
import sys
import random
import re
import os
client=discord.Client()

@client.event
async def on_ready():
    print('Welcome message bot Logged in')
    print(client.user.name)
    print(client.user.id)
    print('-----')

newUserMessage = """your message
"""

@client.event

async def on_member_join(member):
    await client.send_message(member, newUserMessage)

client.run('token') 
sick birch
fresh ferry
sick birch
#

Wherever you got this code from, it's either A) written by someone who doesn't know what they're doing or B) just really, really outdated

robust fulcrum
fresh ferry
robust fulcrum
sick birch
sick birch
robust fulcrum
sick birch
#

Whenever we need to make a new bot we always start with the botcore as it has a lot of the boilerplate

robust fulcrum
#

Ok

#

Ig i should make something else

fresh ferry
sick birch
#

Good, don't look at tutorials

#

Most of them are outdated by now and even when they weren't, they weren't very good to begin with

fresh ferry
robust fulcrum
sick birch
unkempt canyonBOT
#

Kindling Projects

The Kindling projects page on Ned Batchelder's website contains a list of projects and ideas programmers can tackle to build their skills and knowledge.

sick birch
#

!resources as for resources, see here VVV

unkempt canyonBOT
#
Resources

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

primal token
#

Robin you're using the command incorrectly

sick birch
#

which one

primal token
#

Look at the url of the hyperlink, your message was used as a query

#

resources

sick birch
#

oh

#

i didn't know it did that

wicked atlas
#

didn't even know that was a thing tbh

sick birch
#

doesn't seem to do anything though

wicked atlas
#

probably accounted for this 💀

fresh ferry
primal token
#

What's discord python?

sick birch
fresh ferry
sick birch
#

no worries

thorny flint
#

Basically I'm trying to make paginator with embeds and components,
I'm having a hard time not messing up the Current page and/or total pages

Now, I have the total pages working on the index, but the current page in the index button isn't working

#

I do change it init and I also see self.cog.index is changing.. but the Index button isnt updating

#

I also try to change it with the interaction of the button before editing the message, but still nothing

feral breach
#

my bot can't read messages

fresh ferry
feral breach
fresh ferry
# feral breach me too

insane what discord bots can do aye ahaha hopefully he can slide us the sauce for it haha

thorny flint
feral breach
thorny flint
feral breach
fresh ferry
thorny flint
fresh ferry
feral breach
thorny flint
feral breach
#

search stackoverflow

thorny flint
#

I'm not getting any errors

feral breach
thorny flint
feral breach
thorny flint
#

So everytime I go next page it the label of IndexButton stays the same for some reasons

feral breach
thorny flint
#

What do you mean

#

Finally after 3 days of trying to get it to work properly, I finally managed

thorny flint
#

Going to publish a smaller version later

slate swan
#

how can i get a role by id to set channel perms.. ive tried same methods as adding role but its not returning a role object for the channel.set_perms

#

^ in a cmd so i have ctx

unkempt canyonBOT
#

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

Changed in version 2.0: `role_id` parameter is now positional-only.
drifting arrow
#

How can I pass a dictionary as the variables for a sqlite query?

await cur.execute("INSERT INTO playerprofile VALUES (:bmid,:steamid,:playername,:rusthours,:aimtrain,:steamurl,:avatar,:relatedplayers,:updatedat,:names,:kills_week,:kills_day,:deaths_day,:deaths_week,:gamebanned)",({playerinfo}))

where playerinfo is a dictionary

sick birch
#

**dict

#

oops wrong reply

drifting arrow
#

lol

sick birch
#

i suppose i owe you some help eh

#

I don't see what's wrong with putting the logic in the view class

unkempt canyonBOT
#

Hey @hidden hazel!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.

sick birch
#

Are all the buttons the same?

#

What information is different between each button?

#

Do they need to be dynamic?

#

E.g, will all the information about the buttons be known before runtime?

#

Okay.. so this might be an easier alternative:

class MyView(discord.ui.View):
  def __init__(self):
    super().__init__(...) # regular view constructor arguments

  @discord.ui.button(label="Notifications", ...)
  async def notifs_callback(self, button: discord.ui.Button, interaction: discord.Interaction) -> None:
  ...

  @discord.ui.button(label="Nickname", ...)
  async def nickname_callback(self, button: discord.ui.Button, interaction: discord.Interaction) -> None:
  ...
#

Because as it stands, I don't see any use for a button subclass

#

Sure can

#
class MyView(discord.ui.View):
  def __init__(self):
    super().__init__(...) # regular view constructor arguments

  @discord.ui.select(...)
  async def select_callback(self, select: discord.ui.Select, interaction: discord.Interaction) -> None:
  ...
#

It's practically the same thing

sick birch
#

that's not really necessary in your case

#

but it's there if you'd like

#

Ah, my bad. I had a feeling it was the other way around

#

You forget things like that after a while, my apologies

deep saddle
#

gv

drifting arrow
#

aahh

#

raise ValueError("unconverted data remains: %s" % ValueError: unconverted data remains: .794388 ;-;

#

lastupdate = datetime.datetime.strptime( fromdb['updatedat'], '%Y-%m-%d %H:%M:%S')

sick birch
drifting arrow
#

2022-10-07 14:03:44.794388

#

it's stored as a string for whatever reason

#

and I need to convert it to a datetime so I can compare it

#

fuck it. I dont need the h/m/s anyway

#

just remove them 😄

sick birch
drifting arrow
#

it's fiiiiine

sick birch
#

preferably the latter which targets the source of the issue

drifting arrow
#
weekago = datetime.datetime.now(
            timezone.utc) - datetime.timedelta(hours=168)
        weekago = str(weekago)
        weekago = weekago.split(" ")
        weekago = weekago[0]
        weekago = datetime.datetime.strptime(weekago, '%Y-%m-%d')
        db = DataBase()
        fromdb = await db.get_playerinfo(bmid=bmid)
        if fromdb:
            lastupdate = fromdb['updatedat']
            lastupdate = lastupdate.split(" ")
            lastupdate = lastupdate[0]
            lastupdate = datetime.datetime.strptime(
                lastupdate, '%Y-%m-%d')
            if lastupdate < weekago:
                print('Updated a week ago :/')
            return
        else:
            print("NOT IN DB!!")
#

Solution!

sick birch
#

And use the same argument in strptime

#

It's consistent and would work because you're storing it and retrieving it in the same manner

#
dt_format = '%Y-%m-%d'
weekago = ...
weekago_str = weekago.strftime(dt_format)
# store `weekago_str` to 

And retrieving:

lastupdate = fromdb['updatedat']
datetime.datetime.strptime(lastupdate, dt_format)
shrewd apex
#

!e

import datetime
now = datetime.datetime.now()
print(f'{now:%Y-%m-%d %H:%M}')
unkempt canyonBOT
#

@shrewd apex :white_check_mark: Your 3.11 eval job has completed with return code 0.

2022-10-07 03:49
ionic edge
#

How Can i add owners to my jishaku command?

upbeat gust
slate swan
# upbeat gust Wdym low level in this case

components. rather than using a view, disnake has something called low level. where you assign the components with the message then use a listener for when the components are interacted with.

upbeat gust
#

Something similar to the components thing can be done though

slate swan
#

disnake does too they just give u the option to use low level or views.

upbeat gust
#
view = View()
view.add_item(myButton)
.send(view=view)```
Close enough
slate swan
#

also benefits to low level as well compared to views

#
@bot.command()
async def send_button(ctx: commands.Context):
    await ctx.send(
        "Here's a button!",
        components=disnake.ui.Button(label="Click me!", custom_id="cool_button"),
    )
@bot.listen("on_button_click")
async def cool_button_listener(inter: disnake.MessageInteraction):
    if inter.component.custom_id != "cool_button":
        return
    await inter.response.send_message("You clicked the cool button!")

beautiful

upbeat gust
#

No thanks

slate swan
#

persistency

#

and better on memory

upbeat gust
#

Interesting

slate swan
#

memory management in discord.py in general is not so good, you have no control over it

#

the same applies for forks

slate swan
unkempt canyonBOT
#

disnake/state.py lines 953 to 954

if interaction.data.component_type is ComponentType.button:
    self.dispatch("button_click", interaction)```
sweet ore
#

How may I send messages at a specific time? Let's say I wanna send a message at 2 pm.

#

I don't wanna use. ```py
await asyncio.sleep(8000)

unkempt canyonBOT
#

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

You can pass datetime object to the time parameter

sweet ore
#

Thanks!

smoky cedar
#

can someone help..

slate swan
#

"no permission called send_message"

#

!d discord.Permissions.send_messages

unkempt canyonBOT
smoky cedar
#

hm

#

There is

slate swan
#

its send_messages

smoky cedar
#

ohh i forgot to add s

lilac sentinel
#

Help me

slate swan
#

why is it indented inside analysers

lilac sentinel
#

Aapke profile mai achha mantra hai

#

@slate swan

slate swan
#

why are you using that toml file anyways?

lilac sentinel
#

😳

cloud dawn
#

yaml all the way ducky_dave

vocal snow
smoky cedar
#

howd i make the


ctx.guild(role), send_messages = True)

#

I mean howd i add the role

cloud dawn
#

What is ctx.guild.22341534161346_role?

smoky cedar
#

the id role

#

🥲

cloud dawn
#

Okay but why is it an attribute of guild?

smoky cedar
#

server?

#

do i need to make it


ctx.channel(the id role), send_messages = True)

?

#

orr

#

no?

meager chasm
#

???

#

U cant put random shit together and expect it to work xd

#

Do you understand what function is

smoky cedar
#

no?

meager chasm
smoky cedar
#

kinda

meager chasm
#

You supposed to know python fundamentals before making discord bot

#

Like functions, classes, data structures

smoky cedar
#

is it like this then?

ctx.channel.set_permissions(ctx.guild.channel.1023331692515164222_role, send_messages = True)
#

or

#

ctx.channel.set_permissions(ctx.guildchannel.1023331692515164222_role, send_messages = True)

vocal snow
#

what the fuck

smoky cedar
#

?

vocal snow
#

You really should learn python before attempting to do whatever you're trying to do

#

I hope you know that putting random symbols and words together won't magically make your code work...

cinder nacelle
#
                collab = await collab_category.create_text_channel(f"🤝| {self.project_name} | {self.spots}")
                collab_channel = bot.get_channel(collab)

                print(collab)
                print(collab_channel)

                (this is not the actual code but the print results are:
                 🤝-newcollab--50000
                  None ``` so i created a channel but how can i get the channel id?
vocal snow
#

collab_channel = bot.get_channel(collab) is unnecessary. collab is already a TextChannel object

cinder nacelle
# vocal snow `collab.id`

AttributeError: 'int' object has no attribute 'set_permissions'
i got the channel id but now i get this error

vocal snow
#

you can't use set_permissions method on a number

#

you do collab.set_permissions since collab is the TextChannel object

cinder nacelle
vocal snow
#

also, you should be able to set the permissions in create_text_channel

#

!d discord.CategoryChannel.create_text_channel

unkempt canyonBOT
#

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

A shortcut method to [`Guild.create_text_channel()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.create_text_channel "discord.Guild.create_text_channel") to create a [`TextChannel`](https://discordpy.readthedocs.io/en/latest/api.html#discord.TextChannel "discord.TextChannel") in the category.
vocal snow
#

see the params

slate swan
#

whats difference between a client and a bot?

slate swan
slate swan
#

its just a fancy name?

#

not entirely

#

commands.bot()

#

commands.Bot() is different

#

im asking ab this

#

we can use prefix in this one

#

how is that different from discord.client()

#

i pretty sure bot is just an extension of Client

#

bot is same as client the difference is bot comes with commands. its automated for you compared to using client and manually having to handle the events

#

ok

#

commands.Bot is just a subclass of discord.Client with prefix commands related extensions

brazen raft
# slate swan whats difference between a client and a bot?

discord.ext.commands.Bots have the concept of commands built into the class, so you can have command handling and other stuff that is related to bot users. discord.Client is more abstract and has no concept of commands, only event handling, so you have to do these in on_message events for message commands, and on_interaction (I think it was called that) for slash commands

slate swan
#

more like a command handler

#

you can do app_commands without commands.Bot in discord.py, it works with CommandTree structure

slate swan
brazen raft
#

With discord.ext.commands.Bot, you can also have cogs and command groups (and also slash command groups)

#

Because discord.ext.commands.Bot has the concept of cogs and (slash) command groups. Same thing with extensions.

robust fulcrum
#

Guys i want to make a library realted to discord.py that helps making bots using dpy easy
Can anyone tell what type of library should i make?
Any idea?

slate swan
#

depends on wym by easy

#

id override the app_commands part if i were to do that

brazen raft
#

Maybe something around the component system

placid skiff
slate swan
#

Client also represents the bot, Bot is merely an extension for prefix cmds

placid skiff
#

Of course, since client communicates with the API it is the bot too
If you interface the GroupMixin class with the Client class you will be able to manage prefix cmds without the use of the Bot class

slate swan
#

is there a way to give custom color to ButtonStyle then just using the predefined one?

quick gust
#

I guess yeah

#

use ButtonStyle.[color](...) maybe

#

or however buttons work

short silo
#
class Hello(commands.Cogs):
    def __init__(self, bot):
        self.bot = bot

    @discord.slash_command(guild= bleh)
     async def hello (self,ctx):
        Function

def setup(bot):
    bot.add_cog(Hello(bot))

Just started using cogs, what am I doing wrong here ? Ignore the typos and indentation error if any, it isn't a copy paste.

short silo
#

Pycord

naive briar
#

Ok, you have to add the bot argument in the setup function's parameters

short silo
#

My bad as said not copy paste, forgot to write

naive briar
#

It seems fine to me. Did you get any errors while loading it?

short silo
#

Nope

#

Let me share both files a sec

#

class Hello(commands.Cog):
    def __init__(self,bot):
        self.bot= bot
    
    @discord.slash_command(guild_ids=config.GUILD, description="Says Hello.")
    async def hello(self,ctx : discord.Interaction):
        await ctx.response.send_message("Hello")

def setup(bot: discord.Client):
    bot.add_cog(Hello(bot))
#
@bot.command()
async def start(ctx: discord.Interaction):
    for filename in os.listdir('./Commands'):
        if filename.endswith(".py"):
            bot.load_extension(f'Commands.{filename[:-3]}')
    await ctx.channel.send("Bot loaded.")
pulsar bridge
#

Could one of you two ping me when you're done?
I don't wanna interrupt with my own problem sip

short silo
#

so probably cog not getting loaded ?

slate swan
#

i want to edit a embed when a button is clicked any example?

slate swan
naive briar
#

I don't know if you have to sync commands in Pycord

slate swan
#

it doesn't seem like pycord to me

#

or idk

short silo
#

it's pycord

#

well, i will look into it

pulsar bridge
#

Thanks!

#

Is there a way to either:
Delay the execution of something (like using time.sleep()) without making the whole program stop

Orrrr use a database to assign a 'tag' to a user for x amount of time, and after that time is up it executes some stuff?

slate swan
#

there's asyncio.sleep

short silo
#

i think i read somewhere that it might not be

slate swan
#

don't see an issue with it until the program exists before the sleep task is completed

#

but yes a db with a .ext.tasks.loop is lot better

pulsar bridge
#

I’m familiar with how DBs work… just not that familiar

slate swan
pulsar bridge
#

I see, is there a place to read on it though?
An API or doc?

slate swan
#

!d discord.ext.tasks.loop

unkempt canyonBOT
#

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

Epic
Thanks, Sarth AE_Violet_salute

slate swan
#

how to edit an embed using the button please help

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.

slate swan
#

!discord

#

its not working

fresh notch
#

how do i make an error command so that if all the args are not fulfilled it sends a message

slate swan
#
class TicketReason(discord.ui.View):
    def __init__(self, user):
        self.user= user
        super().__init__(timeout=None)

    
    @discord.ui.select(placeholder="Choose your ticket reason", options=[
        discord.SelectOption(
            label="select1", description="select1"
        ),
        discord.SelectOption(
            label="select2", description="select2"
        )
    ])
    async def help_callback(self, select, interaction: discord.Interaction):
        select.placeholder = f"Reason: {self.children[0].values}"
        reason=self.children[0].values
        if reason == 'select1':
            channel=await interaction.guild.create_text_channel(name=f"{interaction.user.display_name}┃Ticket", topic=f"{interaction.user.id}")
            await interaction.response.send_message("Ticket Created")
            embed=discord.Embed(title="טיקט חדש!", description="פתוח")
            embed.add_field(name="סיבה:", value=f"> `{reason}`")
            await channel.set_permissions(interaction.guild.default_role, view_channel=False)
            await channel.set_permissions(interaction.user, view_channel=True)
            await channel.send(embed=embed)
        if reason == 'select2':
            channel=await interaction.guild.create_text_channel(name=f"{interaction.user.display_name}┃Ticket", topic=f"{interaction.user.id}")
            await interaction.response.send_message("Ticket Created")
            embed=discord.Embed(title="טיקט חדש!", description="פתוח")
            embed.add_field(name="סיבה:", value=f"> `{reason}`")
            await channel.set_permissions(interaction.guild.default_role, view_channel=False)
            await channel.set_permissions(interaction.user, view_channel=True)
            await channel.send(embed=embed)
@bot.command()
async def ticket(ctx):
    view = TicketReason(ctx.author)
    await ctx.reply(view=view)```

```[2022-10-07 15:23:09] [ERROR   ] discord.ui.view: Ignoring exception in view <TicketReason timeout=None children=1> for item <Select placeholder='Choose your ticket reason' min_values=1 max_values=1 options=[<SelectOption label='select1' value='select1' description='select1' emoji=None default=False>, <SelectOption label='select2' value='select2' description='select2' emoji=None default=False>] disabled=False>
Traceback (most recent call last):
  File "C:\Users\PC\AppData\Roaming\Python\Python39\site-packages\discord\ui\view.py", line 425, in _scheduled_task
    await item.callback(interaction)
  File "c:\Users\PC\Desktop\AlonDaPro Bot\main.py", line 207, in help_callback
    select.placeholder = f"Reason: {self.children[0].values}"
AttributeError: 'Interaction' object has no attribute 'placeholder'
[2022-10-07 15:24:16] [ERROR   ] discord.ui.view: Ignoring exception in view <TicketReason timeout=None children=1> for item <Select placeholder='Choose your ticket reason' min_values=1 max_values=1 options=[<SelectOption label='select1' value='select1' description='select1' emoji=None default=False>, <SelectOption label='select2' value='select2' description='select2' emoji=None default=False>] disabled=False>
Traceback (most recent call last):
  File "C:\Users\PC\AppData\Roaming\Python\Python39\site-packages\discord\ui\view.py", line 425, in _scheduled_task
    await item.callback(interaction)
  File "c:\Users\PC\Desktop\AlonDaPro Bot\main.py", line 207, in help_callback
    select.placeholder = f"Reason: {self.children[0].values}"
AttributeError: 'Interaction' object has no attribute 'placeholder'```
#

Would the level 6 thing able to be written while checking database

#

And how would I go about making it

#

Writing text onto a template seems hard with python