#discord-bots

1 messages Ā· Page 1110 of 1

slate swan
#

oh there's a comma nvm

paper sluice
#

python just sleeping instead of waiting for the prey, async programming

slate swan
#

yes you love me pls

slate swan
paper sluice
slate swan
#

lmao

iron sorrel
slate swan
#

im your soulmate

#

šŸ¦€

paper sluice
slate swan
#

!ot

unkempt canyonBOT
slate swan
#

what trapšŸ™„

iron sorrel
#

i love traps

slate swan
#

šŸ˜

iron sorrel
#

are you one? :0 hot

slate swan
#

okimii's love aint fake, i know that fine enough (ssriously)
now take this to an ot channel

iron sorrel
#

how off topic lol

slate swan
#

lmao

iron sorrel
#

china is typing 😳 šŸ‡ØšŸ‡³

slate swan
#

😳

tough lance
#

😳

iron sorrel
slate swan
iron sorrel
#

async socket server for CRUD on an async database

slate swan
#

i was thinkin a cli for random cat pics cuz why not

iron sorrel
#

ascii cats

slate swan
#

good idea

uncut portal
#

!ot

unkempt canyonBOT
slate swan
#

.topic

lament depotBOT
#
**What feature would you be the most interested in making?**

Suggest more topics here!

iron sorrel
slate swan
#

😳 šŸ˜

iron sorrel
slate swan
# lament depot

something that pings okimii every 5 seconds and tells him that he's cutely annoying
easy peasy

uncut portal
slate swan
#
    @commands.Cog.listener()
    async def on_member_remove(self, member: discord.Member):
        channel = self.client.get_channel( 977252614498582538)

        await channel.send (f"{member.mention}, Ущел с сервера")

Please tell me why it worked a week ago and now it doesn't

iron sorrel
iron sorrel
#

did you check the id of the channel?

slate swan
#

can you guys stop or move to an off topic channel if you want to discuss about rust now?

iron sorrel
slate swan
#

make a getch instesd

#
channel = self.client.get_channel(channel_id) or await self.client.fetch_channel(channel_id)```
iron sorrel
#

how will it fetch something that can be inexistent

slate swan
iron sorrel
#

doesnt answer this question,

#

but

#

answers a different question

slate swan
#

what does then?

#

go ahead

slate swan
iron sorrel
#

if the channel was deleted, then it will not exist, not in the cache or anywhere.

if it is just not in the cache, then sure, fetching it answers the cache

slate swan
#

and how do you know the channel is inexistent

slate swan
iron sorrel
iron sorrel
slate swan
iron sorrel
#

did i say it was?

slate swan
slate swan
#

elaborate

iron sorrel
#

my question lol

slate swan
#

version

iron sorrel
# slate swan 2.0

did you check if the channel ids match? did someone change the channels in 1 week lol

slate swan
# iron sorrel

"elaborate" on how you know that the channel is inexistent, it'll either raise a 404 error or return the TextChannel object, so that settles it

slate swan
slate swan
iron sorrel
#

deleted and made a new channel 🤷

#

but apparently not

uncut jacinth
#

How do i get a unixtimestamp out of this?

#

member.created_at.strftime("%b %d, %Y")

slate swan
iron sorrel
#

created_at returns datetime.datetime object

slate swan
slate swan
unkempt canyonBOT
#

datetime.timestamp()```
Return POSIX timestamp corresponding to the [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "datetime.datetime") instance. The return value is a [`float`](https://docs.python.org/3/library/functions.html#float "float") similar to that returned by [`time.time()`](https://docs.python.org/3/library/time.html#time.time "time.time").

Naive [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "datetime.datetime") instances are assumed to represent local time and this method relies on the platform C `mktime()` function to perform the conversion. Since [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "datetime.datetime") supports wider range of values than `mktime()` on many platforms, this method may raise [`OverflowError`](https://docs.python.org/3/library/exceptions.html#OverflowError "OverflowError") for times far in the past or far in the future.

For aware [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "datetime.datetime") instances, the return value is computed as:

```py
(dt - datetime(1970, 1, 1, tzinfo=timezone.utc)).total_seconds()
```   New in version 3.3.

Changed in version 3.6: The [`timestamp()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.timestamp "datetime.datetime.timestamp") method uses the [`fold`](https://docs.python.org/3/library/datetime.html#datetime.datetime.fold "datetime.datetime.fold") attribute to disambiguate the times during a repeated interval.
uncut jacinth
#

You smart man

paper sluice
slate swan
iron sorrel
#

||she/her|| but yes, smart

slate swan
#

it's okay lmao

slate swan
#

I'm now completely in denial of you being in denial of something you shouldnt deny about

#

šŸ˜”

slate swan
paper sluice
slate swan
#

    @commands.Cog.listener()
    async def on_member_remove(self, member: discord.Member):
        channel = self.client.get_channel(977252614498582538) or await self.client.fetch_channel(977252614498582538)
        
        await channel.send (f"{member.mention}, Ущел с сервера")
#

lmao

slate swan
#

Just restarted still 0 reaction. maybe the command structure changed after the python update?

slate swan
iron sorrel
#

what do these messages look like for you ppl?

paper sluice
#

do objects randomly disappear from the cache? if not, load the channel once, store it someone in a bot variable or something and use that, why getch everytime

slate swan
#

cz it's not cached by your client

neat field
# iron sorrel

Sometimes if u don’t have access to view those servers , it appears like that

slate swan
iron sorrel
#

[#977252614498582538](/guild/267624335836053506/channel/977252614498582538/)

paper sluice
#

šŸ‘€

iron sorrel
#

wait

paper sluice
#

they should name it something like unkown channel or invalid channel, this is bs error handling by discord

slate swan
neat field
slate swan
paper sluice
#

still, discord needs to be better at that, i dont like it

slate swan
#

Inarguable

iron sorrel
# slate swan ```py @commands.Cog.listener() async def on_member_remove(self, member:...

why not try something like:

inside of the cog

class Cog(commands.Cog):
  def __init__(self, client):
    self.client = client
    self.leave_channel = channel
    self.leave_channel_id = 977252614498582538

  @commands.Cog.listener()
  async def on_ready(self):
    self.leave_channel = self.client.get_channel(self.leave_channel_id) or await self.client.fetch_channel(self.leave_channel_id)

  @commands.Cog.listener()
  async def on_member_remove(self, member: discord.Member):
      await self.leave_channel.send(f"{member.mention}, Ущел с сервера")
slate swan
#

subclass commands.Cog first

iron sorrel
neat field
#

It’s just probably a class in his main file

slate swan
paper sluice
iron sorrel
#

fetch your dependencies inside of on_ready

slate swan
iron sorrel
#

that... has never happened to me lol :D

slate swan
#

nor a good practice as suggested

paper sluice
#

the only time I see on_ready getting triggered multiple times is when i sleep my pc and turn it back on :D

paper sluice
uncut portal
slate swan
#
    @commands.Cog.listener()
    async def on_member_remove(self, member: discord.Member):
        print("123")
        await self.leave_channel.send(f"{member.mention}, Ущел с сервера")
    @commands.Cog.listener()
    async def on_ready(self):
        self.leave_channel = self.client.get_channel(977252614498582538) or await self.client.fetch_channel(977252614498582538)
        print("READY!")
        await self.client.change_presence( status= discord.Status.online, activity= discord.Game(".хелп"))

He didn't even write "123" print...

#

Rusts syntax imo is better than cpp

slate swan
# iron sorrel i never saw it lol

Don't make API calls in on_ready within your Bot or Client.
Discord has a high chance to completely disconnect you during the READY or GUILD_CREATE events (1006 close code) and there is nothing you can do to prevent it.

Basically: don't do shit in on_ready.

(This comes straight from the discord.py server)

iron sorrel
#

can u link the source

paper sluice
slate swan
slate swan
iron sorrel
#

thx

slate swan
#

mut?

let mut ok = "bro";
#

😳

iron sorrel
paper sluice
slate swan
#

ban kick mutšŸ˜…

paper sluice
slate swan
paper sluice
slate swan
#

No. the event does not work for me when it leaves the serveršŸ™ƒ

slate swan
#

but if i remove mut compiler goes boom

paper sluice
slate swan
paper sluice
#

what if u make a singleton run file, u can run the file only once, other times u try to run it runs the previous compiled file

#

debug--

slate swan
#

doesnt rust already do that

paper sluice
#

like even if u edit the file, it just runs the old compiled one

slate swan
#

doesnt rust run the previous conpiled file if you havent compiled anything?

#

iirc it gets stored in the debug folder thats made when you do cargo new package_name

paper sluice
slate swan
#

yup

paper sluice
#

ya, i dont want that, hence why singleton-run

slate swan
#

well idk maybe deleting the debug folder

paper sluice
#

why am i still talking, i dont even code in rust lol

slate swan
#

šŸ—æ

iron sorrel
slate swan
sick birch
elfin moon
#

hi I have this code and it is running, but the slash command doesn't work and I dont know why

#

and of course i put client.run(token)

paper sluice
elfin moon
paper sluice
# elfin moon like `tree.sync()`?

ya that syncs globally, so it might take a few mins for it to load. u can do implicit syncing using the guild keyword arg, thats faster

elfin moon
#

and also do i have to put in an async function?

#

because it's a coroutine

paper sluice
#

yes

elfin moon
#

ok

#

and how long will it take if i specify the guild?

paper sluice
elfin moon
elfin moon
#

This still doesn't work 😦

paper sluice
elfin moon
#

idk

paper sluice
#

i doubt that method gets called by default and you are not calling it either

elfin moon
#

OK i replaced it with on_Ready

#

on_ready

#

OMG thanks it works thinkies

paper sluice
#

u can also change the name of that function from startup to setup_hook because, that is an async function that gets called internally

elfin moon
#

Hi, I have another question. I have a command group called helpcommands and a command called help in it. How do I only display the command, not the command group?

#

I originally had a bunch of cogs and I am making it into slash commands, so do I have to move all the commands out of the cog?

serene mantle
#

Hey guys i'm trying to make a bot with a task in it

#
@tasks.loop(seconds=1)
    async def send_message():
        
        channel_id = 981276650975158275

        channel = client.fetch_guild(channel_id)

        message = f"""
        Example Message
        """
    
        await channel.send(message)

    send_message.start()```
#

for some reason the client object isn't being recognized

#

i did some research and people are saying something about cache, anyone know how to solve this issue?

potent spear
#

also, fetching a guild with a channel id? 🧠

vale wing
uncut jacinth
#

Hey any body idea why it is not working?

AttributeError: 'Member' object has no attribute 'avatar_url'

if user.is_avatar_animated():

#

async def test(ctx, user: discord.User):

#

I tried it with member to

potent spear
#

you're on v2, I suppose?

uncut jacinth
potent spear
#

since v2, it's member.avatar.url

elfin moon
#

(2.0)

uncut jacinth
#

Ohhh

potent spear
#

!d discord.Member.avatar

unkempt canyonBOT
#

property avatar```
Equivalent to [`User.avatar`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User.avatar "discord.User.avatar")
uncut jacinth
#

And whats about is_animated

potent spear
#

the docs will tell you šŸ˜‰

uncut jacinth
#

so basically

#

user.avatar.is_animated?

potent spear
#

yup

#

it's a method though, so ()

uncut jacinth
potent spear
#

thank the docs

slate swan
#

though it's somewhat a confusing kind of implementation if you compare it with the forks, but it's usable

slate swan
#
    @commands.Cog.listener()
    async def on_ready(self):

        cursor.execute("""CREATE TABLE IF NOT EXISTS users(
            name TEXT,
            id INT,
            gems BIGINT,  
            lvl INT
            )""")
        for guild in self.client.guilds:
            for member in guild.members:
                if cursor.execute(f"SELECT id FROM users WHERE id = {member.id}").fetchone() is None:
                    cursor.execute(f"INSERT INTO  users VALUES ({member.name}, {member.id}, 0, 1 )")
                else:
                    pass
        conn.commit()

        print("READY!")
        await self.client.change_presence( status= discord.Status.online, activity= discord.Game(".хелп"))

Dear please tell me what is the problem. "Барак" is the server principal name

long zinc
#

hey this is python with discord.py but the command doesnt run

import imp
import discord
from discord.ext import commands
from Tokens import DiscordToken
import discord.ui
from discord.ui import Button, View, view

intents = discord.Intents.default()

bot = commands.Bot(command_prefix="!",intents=intents)

@bot.event
async def on_ready():
    print("HigherBot Succesfully Logged in :green_circle:")

@bot.command()
async def config(ctx):
    SetupButton = Button(label="Setup",style=discord.ButtonStyle.green,emoji=":screwdriver:")
    view = View()
    View.add_item(SetupButton)
    await ctx.send("Interact with the Following", view=view)


bot.run(DiscordToken)

sick birch
#

Doesn't run how?

potent spear
slate swan
azure nebula
#
import discord
from discord import Interaction, app_commands
from discord.ext import commands
from discord import member
from discord.ext.commands import has_permissions, MissingPermissions
import os
from discord import Intents

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

class aclient(discord.Client):
    def __init__(self):
        super().__init__(intents=discord.Intents.default())
        self.synced = False

    async def on_ready(self):
        await self.wait_until_ready()
        if not self.synced:
            await tree.sync(guild = discord.Object(id = 984317836094746624))
            self.synced = True
        print(f'Logged in as {self.user}.')


client = aclient()
tree = app_commands.CommandTree(client)


@tree.command(name="help", description='Help command.', guild = discord.Object(id = 984317836094746624))
async def self(interaction: discord.Interaction):
    embed = discord.Embed(title="Help", color=0x03f4fc)
    embed.add_field(name='**IP**', value="Shows server's IP.", inline=False)
    embed.add_field(name='**TS**', value="Shows server's TeamSpeak.", inline=False)
    embed.add_field(name='**MODERATION**', value="Shows moderation commands.")
    await interaction.response.send_message(embed=embed)


@tree.command(name="ip", description="Shows server's IP.", guild = discord.Object(id = 984317836094746624))
async def self(interaction: discord.Interaction):
    embed = discord.Embed(color=0x03f4fc)
    embed.add_field(name="**Server's IP**", value="There's no defined IP yet!", inline=False)
    await interaction.response.send_message(embed=embed)


@tree.command(name='ts', description='Shows teamspeak adress.', guild = discord.Object(id = 984317836094746624))
async def self(interaction: discord.Interaction):
    embed = discord.Embed(color=0x03f4fc)
    embed.add_field(name = "**Server's TS**", value="There's no TS yet!", inline=False)
    await interaction.response.send_message(embed=embed)

@tree.command(name='moderation', description='Shows moderation commands.', guild = discord.Object(id = 984317836094746624))
async def self(interaction: discord.Interaction):
    embed = discord.Embed(title = "Moderation commands", color=0x03f4fc)
    embed.add_field(name = "**Ban**", value="Bans a user permanently.")
    embed.add_field(name = "**Kick**", value="Kicks people from the server..")
    await interaction.response.send_message(embed=embed)

@tree.command(name="kick", description='Kicks people from the server.', guild = discord.Object(id = 984317836094746624))
async def self(interaction: discord.Interaction, member : discord.Member, *, reason=None):
    await interaction.member.send(f"You were kicked for: {reason}")
    embed = discord.Embed(title = "Moderation command was issued", color=0x03f4fc)
    embed.add_field(name="**A user was kicked!**", value=f"{member.mention} was kicked from the server.")
    await interaction.response.send_message(embed=embed)
    await member.kick(reason=reason)```
#

it worked before

blissful lagoon
#

@azure nebula please do not post that URL

potent spear
#

I wouldn't use self as a function name

blissful lagoon
#

it is not appropriate for our server

#

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

blissful lagoon
#

if you need to share something

azure nebula
#

it's an image hosting, im sorry

#
@tree.command(name="kick", description='Kicks people from the server.', guild = discord.Object(id = 984317836094746624))
async def self(interaction: discord.Interaction, member : discord.Member, *, reason:str=None):
    await interaction.member.send(f"You were kicked for: {reason}")
    embed = discord.Embed(title = "Moderation command was issued", color=0x03f4fc)
    embed.add_field(name="**A user was kicked!**", value=f"{member.mention} was kicked from the server.")
    await interaction.response.send_message(embed=embed)
    await member.kick(reason:str=reason)```
balmy bobcat
#

hello, can I mention someone with their ID ?

potent spear
#

also please rename, don't call it self that's a reserved variale

potent spear
balmy bobcat
#

thank you!

cerulean folio
#
def update(arg):
  con = sqlite3.connect(os.path.join(BASE_DIR, "example.sqlite"))
  cur = con.cursor()
  update = "UPDATE table SET value1 = ?, value2 = ?, value3 = ?, WHERE entry_id = ?;"
  payload = (
    arg['value1'],
    arg['value2'],
    arg['value3'],
    arg['subject_id']
    )
  cur.execute(update, payload)
  con.commit()
  cur.close()
  con.close()
  return True

Is the the correct way of doing things? I'm starting to doubt XD

raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: OperationalError: near "WHERE": syntax error
potent spear
cerulean folio
azure nebula
#
@tree.command(name="kick", description='Kicks users from the server.', guild = discord.Object(id = guild_id_goes_here))
@has_permissions(kick_members=True)
async def kick(interaction: discord.Interaction, member : discord.Member, *, reason:str=None):
    try:
        await interaction.member.send(f"You were kicked for: {reason}")
        embed = discord.Embed(title = "A moderation command was issued!", color=0x03f4fc)
        embed.add_field(name="**A user was kicked!**", value=f"{member.mention} was kicked.")
        await interaction.response.send_message(embed=embed)
        await member.kick(reason=reason)
    except:
        await interaction.response.send_message(f"I couldn't ban {member}!")

@kick.error
async def kick_error(interaction: discord.Interaction, error):
  if isinstance(error, commands.MissingPermissions):
    await interaction.reply("You don't have permission to: Kick Members")```
potent spear
daring olive
#

@azure nebula can you just copy/paste your text code? no one enjoys reading screenshots

daring olive
#

and next time you accidentally post that link you'll be banned, last warning

azure nebula
#

ok

dusky pine
#

in fact, you can name self anything in a method

#

since all Python does is pass the current instance there

potent spear
#

just a bad variable in general

dusky pine
#

i agree, self tends to be used in methods

azure nebula
#
@tree.command(name="ban", description='Bans people from the server.', guild = discord.Object(id = guild_id_goes_here))
@has_permissions(ban_members=True)
async def ban(interaction: discord.Interaction, member : discord.Member, *, reason:str=None):
    if has_permissions(ban_members=True) == True:
        try:
            await interaction.member.send(f"You were banned from Example_Server for: {reason}")
            embed = discord.Embed(title = "A moderation command was issued.", color=0x03f4fc)
            embed.add_field(name="**A user was banned!**", value=f"{member.mention} was permanently banned.")
            await interaction.response.send_message(embed=embed)
            await member.ban(reason=reason)
        except:
            await interaction.response.send_message(f"I couldn't ban {member.mention}!")
    else:
        await interaction.response.send_message(f"You cannot ___ban members___")``` this works but when I try to ban someone __with__ permissions, it replies ``You cannot ___ban members___`` instead of ``I couldn't ban @user!``
desert heart
azure nebula
#

I also tried doing it like this but it didn't work either

@tree.command(name="ban", description='Bans people from the server.', guild = discord.Object(id = guild_id_goes_here))
@has_permissions(ban_members=True)
async def ban(interaction: discord.Interaction, member : discord.Member, *, reason:str=None):
    try:
        await interaction.member.send(f"You were banned from Example_Server for: {reason}")
        embed = discord.Embed(title = "A moderation command was issued.", color=0x03f4fc)
        embed.add_field(name="**A user was banned!**", value=f"{member.mention} was banned from the server.")
        await interaction.response.send_message(embed=embed)
        await member.ban(reason=reason)
    except:
        await interaction.response.send_message(f"I couldn't ban {member.mention}!")

@ban.error
async def ban_error(interaction: discord.Interaction, error):
    if isinstance(error, commands.MissingPermissions):
        await interaction.reply("You cannot ban members!")```
desert heart
#

You are already decorating the ban command with it. I guess your goal is to have a custom error message when someone doesn't have permission?

#

Yeah okay

#

That would be the appropriate way to do it

azure nebula
#

yeah

#

it doesn't work

desert heart
#

What does "doesn't work mean". Are you getting an error, or just not seeing "You cannot ban members!" replied?

azure nebula
#

oh wtf

#

it works now

#

i swear it didn't work before xd_freddy

desert heart
#

Maybe you didn't save the file or reload your bot. Something like that.

sonic flax
#
import pynput 

state = True

while state:
    def on_press(key):
        global pressed
        while not pressed:
            if pos == 1 and aim == 1 and res == 1:
                pyautogui.click(x=1080, y=1020)
                pyautogui.click(x=650, y=500)
                pyautogui.click(x=840, y=1020)
                pyautogui.click(x=650, y=500, clicks=hit, interval=0.25)
            else:
                break

how would i make it keep looping unless "P" is pressed

slate swan
elfin moon
#

How can I add a cog with slash commands to the client object in discord.py 2.0

alpine cove
elfin moon
#

okay

slate swan
#
import slash_command

@slash_command(name = "membercount")
async def membercount(self, ctx):
        embedmem = discord.Embed(title=f"**Members**", description=f"{ctx.guild.member_count}", color = 0x0000)
        embedmem.set_footer(text=f"{ctx.guild.name}")
        await ctx.respond(embed=embedmem)
``` this is correct?
slate swan
#

oh nvm

#

what's the main library you're using for your bot?

slate swan
dusky pine
#

replit everywhere..

slate swan
#

@slate swan 1.7.3

#

@slate swan what happened?

#

Code is wrong?

#

Anyone?

dusky pine
#

you probably didn't install the library

#

nothing wrong with your code AFAIK

slate swan
# slate swan Yes discord.py

discord 1.7.3 doesnt supoort slash commands, upgrade to discord.py 2.0 for that
run ?tag install dev in the dpy server cz im too lazy to do it
then read about the breaking changes (?tag mg2)

dusky pine
#

just use pycord or sm lol

alpine cove
dusky pine
#

buy a vps lmao

slate swan
dusky pine
#

that's not the point

#

it's that swas.py teaches people to host their bots in repl.it+uptimerobot

#

and i find that concerning

#

at least.... let your viewers know there is a better alternative if you can afford it

vocal snow
#

That's the least concerning thing in a swas.py tutorial lol

dusky pine
#

there are a lot more

#

including json as database 😭

slate swan
dusky pine
#

Code with swastik, i think it was

shrewd apex
#

yes

slate swan
#

Never heard of him

shrewd apex
#

search yt dpy economy bot

slate swan
#

No

#

šŸ˜”

#

but im lazy

shrewd apex
#

i was thinking abt that too make a decent yt tutorial on dpy but my accent...

slate swan
#

Make a site

#

Dpy tutorial

slate swan
slate swan
#

You miss all the shots you dont take :))

dusky pine
#

unless it's really really really heavy

#

Show them how to setup Postgres

shrewd apex
shrewd apex
dusky pine
#

as long as they can understand what ur saying it's fine

shrewd apex
# slate swan Why not

coz beginners will just search yt first which beginner actually opens the docs and reads?pithink

dusky pine
#

an experienced beginner šŸ‘

slate swan
#

me: pydis_peek

shrewd apex
#

pygame/tkinter/and some bots

vocal snow
shrewd apex
slate swan
shrewd apex
#

oki is experienced

slate swan
#

no

dusky pine
#

you shot miss take dont

slate swan
#

hunter hasnt accepted my proposal for marriage šŸ˜”

slate swan
shrewd apex
slate swan
#

idk find out ;))

dusky pine
#

"it dont matter"

  • okimii 2022, in his head
shrewd apex
slate swan
#

love is love no?

#

😳

slate swan
dusky pine
#

okimii x hunter fanfic confirmed

slate swan
#

ugh i hate puberty

dusky pine
slate swan
#

!resources this is trash

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.

slate swan
#

I can't even find anything

dusky pine
#

it's not your preferred way of learning

slate swan
#

trash docs doesnt mean all docs are trash

shrewd apex
#

mhm

slate swan
#

discrimination smh

#

!d discord

unkempt canyonBOT
#

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

Creating a Bot account is a pretty straightforward process.

dusky pine
#

docs brokey broke broke

slate swan
#

Its an advance lib

#

possible to set the chance of random.choice?
Ex:

`e = [70ā€œ10ā€,
1ā€œ20ā€,
33ā€29ā€]

await ctx.send(random.coice(e))`

#

1% chance for 20

#

70 for 10 and 33 for 29

#

!d random.choice

unkempt canyonBOT
#

random.choice(seq)```
Return a random element from the non-empty sequence *seq*. If *seq* is empty, raises [`IndexError`](https://docs.python.org/3/library/exceptions.html#IndexError "IndexError").
slate swan
#

im pretty sure it has a kwarg for the chances

#

which iirc you would pass a list and then all the chances

hollow osprey
#

!d random.sample

unkempt canyonBOT
#

random.sample(population, k, *, counts=None)```
Return a *k* length list of unique elements chosen from the population sequence or set. Used for random sampling without replacement.

Returns a new list containing elements from the population while leaving the original population unchanged. The resulting list is in selection order so that all sub-slices will also be valid random samples. This allows raffle winners (the sample) to be partitioned into grand prize and second place winners (the subslices).

Members of the population need not be [hashable](https://docs.python.org/3/glossary.html#term-hashable) or unique. If the population contains repeats, then each occurrence is a possible selection in the sample.
slate swan
#

Make a list then do random.choice and put the extra chance thing twice šŸ’€

hollow osprey
#

pass the chances to the counts kwarg

slate swan
#

welp guess i had the wrong method lol

#

and hey moyenšŸ‘‹

hollow osprey
#

yo

slate swan
#

šŸ‘‹

slate swan
hollow osprey
#

the docs say so

slate swan
#

Oh

#

@slate swan

#

Anyone?

slate swan
lyric apex
#

Huh

slate swan
#

there's no ext.buttons in any fork afaik

slate swan
lyric apex
slate swan
#

it doesn't have an ext.buttons either

#

import app_commands = this is correct?

#

where did you get this code from?

slate swan
slate swan
slate swan
slate swan
slate swan
lyric apex
#

app_commands doesn't have paginator

slate swan
#

Ignored šŸ’€

shrewd apex
#

send it here smh

paper sluice
#

how do u make a lightbulb plugin work with classes? got it

slate swan
slate swan
paper sluice
#

i was it to be like completely oop

placid skiff
#

!d disnake.ext.commands.Cooldown

unkempt canyonBOT
shrewd apex
#

lmao

placid skiff
#

.-.

paper sluice
shrewd apex
#

!d discord.ext.commands.cooldown

unkempt canyonBOT
#

@discord.ext.commands.cooldown(rate, per, type=discord.ext.commands.BucketType.default)```
A decorator that adds a cooldown to a [`Command`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command")

A cooldown allows a command to only be used a specific amount of times in a specific time frame. These cooldowns can be based either on a per-guild, per-channel, per-user, per-role or global basis. Denoted by the third argument of `type` which must be of enum type [`BucketType`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.BucketType "discord.ext.commands.BucketType").

If a cooldown is triggered, then [`CommandOnCooldown`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CommandOnCooldown "discord.ext.commands.CommandOnCooldown") is triggered in [`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") and the local error handler.

A command can only have a single cooldown.
placid skiff
#

that is not the class lmao

paper sluice
slate swan
#

How to give description to a cog if possible?

#

auto moderation is here

placid skiff
#

for what purpose?

slate swan
slate swan
#

uh nvmd

#

and it sucks

#

i typed something and i got that then i checked

placid skiff
#

it is older than the server itself

slate swan
#

lol

#

rip

slate swan
honest shoal
#

I'm getting hex colour from a json api, how can I use it in my embed colour?

slate swan
honest shoal
#

can't use in this way

slate swan
#

uh?

honest shoal
#

color=0x + data["cpkHexColor"])

slate swan
#

hm

restive osprey
slate swan
#

go to the bot tab and switch off requires Oauth2...

honest shoal
restive osprey
#

url not generating like it used to šŸ¤”

#

got it

slate swan
honest shoal
#
"cpkHexColor":"3DFF00"```
restive osprey
#

now it even removed

slate swan
#

reload

slate swan
honest shoal
#

yes

slate swan
#

lemme see

#

works fine for me....

#

!e

a = "3DFF00"
print(0xa)
unkempt canyonBOT
#

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

10
paper sluice
#

i uses classes for everything

honest shoal
#

lemme check again

slate swan
#
    @commands.Cog.listener()
    async def on_member_join(self, member: discord.Member):
        channel = self.client.get_channel( 977252614498582538)

        role = discord.utils.get ( member.guild.roles, id = 977252174964871258)

        await member.add_roles (role)
        await channel.send (f"{member.mention}, Гобро ŠæŠ¾Š¶Š°Š»Š¾Š²Š°Ń‚ŃŒ на сервер")
        for guild in self.client.guilds:
            for member in guild.members:
                if cursor.execute(f"SELECT id FROM users WHERE id = {member.id}").fetchone() is None:
                    cursor.execute(f"INSERT INTO  users VALUES (?, ?, ?, ?, ? )", ({member.id}, f'{member}', 0, 'безработный', 1 ))
                else:
                    pass
        conn.commit()

Dear, please tell me why he writes in an error that 4 only gave values balthough there are 5?

slate swan
paper sluice
honest shoal
#

@slate swan

shrewd apex
#

0xffffff

#

there is nothing called 0xcolo

paper sluice
honest shoal
slate swan
#

sorry ryuga

#

forgib

#

why...

paper sluice
#

int(..., 16)

slate swan
#

themks

shrewd apex
#

i forgot

honest shoal
#

🄲

slate swan
#

and show

shrewd apex
#

šŸ™ˆ

slate swan
#

you probably have something like this

#

!e
print(0x#3DFF00)

unkempt canyonBOT
#

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

001 |   File "<string>", line 1
002 |     print(0x#3DFF00)
003 |            ^
004 | SyntaxError: invalid hexadecimal literal
shrewd apex
#

!e
print(int('0xffffff', 16))

unkempt canyonBOT
#

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

16777215
paper sluice
slate swan
# slate swan ```py @commands.Cog.listener() async def on_member_join(self, member: di...
    @commands.Cog.listener()
    async def on_ready(self):

        cursor.execute("""CREATE TABLE IF NOT EXISTS users(
            id INT,
            name TEXT,
            gems BIGINT,
            work TEXT 
            lvl INT
            )""")
        for guild in self.client.guilds:
            for member in guild.members:
                if cursor.execute(f"SELECT id FROM users WHERE id = {member.id}").fetchone() is None:
                    cursor.execute(f"INSERT INTO  users VALUES (?, ?, ?, ?, ? )", ({member.id}, f'{member}', 0, 'безработный', 1 ))
                else:
                    pass
        conn.commit()

        print("READY!")
        await self.client.change_presence( status= discord.Status.online, activity= discord.Game(".хелп"))

oh. I meant this event

paper sluice
#

0xcolor tries to make in int, it doesn't access the variable colo

#

just do int(colo, 16)

honest shoal
honest shoal
keen grove
#

can someone give me a "say" command code

#

i've been trying for 2 daysand it doesn't work

vale wing
keen grove
#

just that?

vale wing
#

Yeah

keen grove
#

sweet ty

#

so

#
async def say(ctx, *, text)```
vale wing
#

The body of a command is required too

keen grove
#

ah

vale wing
#

If you get that

keen grove
#

aight

#

ty

#

oh and for some reason

#

when i make a command and test it

#

sometimes it works and sometimes it doesn't

vale wing
keen grove
#

the code?

vale wing
#

Yeah

keen grove
#

just that

vale wing
#

I mean say command

keen grove
#

oh

#

dindn't do it yet

#

im working on the help command

vale wing
#

You need to subclass the help command

#

Check the pins for guide

honest shoal
#
    raise HTTPException(response, data)
disnake.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In embeds.0.fields.17.value: This field is required```
it didn't specify which field, I think I filled all the necessary ones ![think](https://cdn.discordapp.com/emojis/887017358600851456.webp?size=128 "think")
vale wing
#

embed.add_field make sure you have all the value kwargs filled

keen grove
#
class MyHelpCommand(commands.HelpCommand):
    async def command_callback(self, ctx, *,command=None):
        if command:
           await ctx.send(f"This the help page for the command {command} ")
        else:
            await ctx.send("This is the front pagea for the bots help command")
bot.help_command=MyHelpCommand()```
slate swan
#

Dear, tell me how to add a new value to the table without deleting the database.

that's how it was

    @commands.Cog.listener()
    async def on_ready(self):

        cursor.execute("""CREATE TABLE IF NOT EXISTS users(
            id INT,
            name TEXT,
            gems BIGINT,
            work TEXT,
            lvl INT,
            )""")
        for guild in self.client.guilds:
            for member in guild.members:
                if cursor.execute(f"SELECT id FROM users WHERE id = {member.id}").fetchone() is None:
                    cursor.execute(f"INSERT INTO  users VALUES (?, ?, ?, ?, ?)", (f'{member.id}', f'{member}', 0, 'безработный', 1))
                else:
                    pass
        conn.commit()

This is how I want it to be. add gold. but so that the values ​​of all participants are preserved

  @commands.Cog.listener()
   async def on_ready(self):

       cursor.execute("""CREATE TABLE IF NOT EXISTS users(
           id INT,
           name TEXT,
           gems BIGINT,
           gold BIGINT,
           work TEXT,
           lvl INT
           )""")
       for guild in self.client.guilds:
           for member in guild.members:
               if cursor.execute(f"SELECT id FROM users WHERE id = {member.id}").fetchone() is None:
                   cursor.execute(f"INSERT INTO  users VALUES (?, ?, ?, ?, ?, ?)", (f'{member.id}', f'{member}', 0, 0, 'безработный', 1))
               else:
                   pass
       conn.commit()
keen grove
#

how do i rename this?

lyric apex
keen grove
lyric apex
#

Go to your file location and rename

vale wing
#

In hierarchy manager

lyric apex
#

Its Weird

keen grove
#

it is

#

kinda

slate swan
#
from discord import app_commands

@app_commands(name = "membercount")
async def membercount(self, ctx):
        embedmem = discord.Embed(title=f"**Members**", description=f"{ctx.guild.member_count}", color = 0x0000)
        embedmem.set_footer(text=f"{ctx.guild.name}")
        await ctx.respond(embed=embedmem)
``` this is correct means import
#

?

slate swan
#

@lyric apex

lyric apex
slate swan
#

2.0

lyric apex
#

Import is correct

slate swan
lyric apex
#

Have a look

lyric apex
slate swan
#

How?

slate swan
#

that's not how you create slash commands

#

hello ash šŸ‘‹

slate swan
#

šŸ‘€

#

hello šŸ‘‹

#

sure

slate swan
# slate swan 2.0

INSTALL DISCORD.PY 2.0 (OR ABOVE)

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

NOTE: If you get an error such as: 'git' not added to path. Visit https://git-scm.com/downloads and install git for your required platform. Go through the required steps for installing git and make sure to enable add to path while in the installation wizard. After installing git you can run pip install -U git+https://github.com/Rapptz/discord.py again to install discord.py 2.0.
If any issues still persist, consider the issue on Stackoverflow (or the web) as help with git is easily found.

Discord.py 2.0 (or above) implements a few breaking changes to the library. Few common examples are-
User.avatar_url has been re-considered as User.avatar.url
Guild.icon_url has been re-considered as Guild.icon.url
Bot.add_cog and Bot.load_extension are now asynchronous methods
You can read the full list of changes here - https://discordpy.readthedocs.io/en/latest/migrating.html

EXAMPLES
Slash Commands - https://gist.github.com/AbstractUmbra/a9c188797ae194e592efe05fa129c57f
Buttons, Select Menus, etcetera - https://github.com/Rapptz/discord.py/tree/master/examples/views
Modals - https://github.com/Rapptz/discord.py/blob/master/examples/modal.py
A complete slash command bot - https://github.com/Rapptz/discord.py/blob/master/examples/app_commands/basic.py

#
embed = discord.Embed(title="title",description="description")
embed.set_footer(text="text")
await ctx.send(embed=embed)
#

@slate swan

#

!d discord.Embed.set_footer

unkempt canyonBOT
#

set_footer(*, text=None, icon_url=None)```
Sets the footer for the embed content.

This function returns the class instance to allow for fluent-style chaining.
slate swan
#

yes

lusty grotto
#

helo
i just want to ask something
can we trigger an event from a cmd?

slate swan
#

u can use hex codes

#

they starts from 0x

#

@slate swan

#

yeah just add the colour kwarg to the embed constructor and pass in a hexcode or a rgb format

slate swan
#

hey asher šŸ‘‹

slate swan
shrewd apex
#

hello everyone

slate swan
#
embed = discord.Embed(title="title",description="description",color= hexcode)
embed.set_footer(text="text")
await ctx.send(embed=embed)
#

i dont have any hex code now sorry

#

u can get them from google

shrewd apex
#

color=0xffffff

#

for white

slate swan
#
embed = Embed(colour=0xffffff) #hexcode
embed = Embed(colour=discord.Colour.from_rgb(255, 200, 100)) #rgb colours
embed = Embed(colour=discord.Colour.random()) #random colour
lusty grotto
slate swan
#

šŸ‘

slate swan
slate swan
shrewd apex
slate swan
slate swan
#

sparky..... šŸ˜”

shrewd apex
#

don't put the hex in. a string btw

slate swan
#

I feel bad for you šŸ˜”

#

code pls

slate swan
#

whole code

brazen raft
#

What is the entire function of this command

shrewd apex
#

it's not even in an command thats like line 1šŸ‘€

slate swan
#

of the cmd / slash cmd

shrewd apex
#

no it's 1

slate swan
#

0 ?

slate swan
shrewd apex
#

see the pic

#

gl sparky

slate swan
shrewd apex
slate swan
#

wait

shrewd apex
#

put it in a comment

slate swan
#

let me check vsc have 0 line or not

brazen raft
shrewd apex
#

lmao Ashley...

slate swan
#

lol

brazen raft
#

What library are you using?

slate swan
#

ye it doesnt

shrewd apex
#
@bot.command()
async def com(ctx):
     #embed stuff
dusky pine
#

com

dusky pine
#

i don't get why people send msesages with just a dot in them

brazen raft
slate swan
#

fine now?

shrewd apex
#

i am trying to keep quiet somehow

dusky pine
shrewd apex
#

pfft

slate swan
slate swan
shrewd apex
#

.

dusky pine
#

you just want attention

shrewd apex
#

yeah

dusky pine
#

you dont want my looooooove

slate swan
#

šŸ’€

brazen raft
dusky pine
#

lmao

shrewd apex
#

f

slate swan
#

hi asher

dusky pine
shrewd apex
#

yes hello sparky

dusky pine
#

what

slate swan
#

lol

slate swan
#

hey MERN man šŸ‘‹

brazen raft
shrewd apex
#

mer-man...

brazen raft
#

Like this

shrewd apex
#

merman

brazen raft
#

With the sole purpose to reply

slate swan
#

šŸ¤”

#

sole?

dusky pine
slate swan
#

imagine making a ppt ;-; - school holiday homework

#

they should give like code projects it will be fun :D

brazen raft
#

If this happens to be how the conversation plays out

dusky pine
#

yeah, it does make sense if you're referring to another message

dusky pine
slate swan
#

Traceback (most recent call last):
File "main.py", line 49, in <module>
from discord.ext.buttons import Paginator
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/buttons/init.py", line 1, in <module>
from .buttons import *
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/buttons/buttons.py", line 194, in <module>
class Paginator(Session):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/buttons/buttons.py", line 228, in Paginator
colour: Union[int, discord.Colour] = discord.Embed.Empty,
AttributeError: type object 'Embed' has no attribute 'Empty'

#

anyone?

dusky pine
#

Embed.Empty doesn't exist anymore i think

slate swan
#

yeah, its None now

dusky pine
#

wait, that error isn't coming from their code

#

that's incompatible libraries!!!

slate swan
#

yeah, 3rd party libs overriding the main package.

dusky pine
#

it may be pycord

slate swan
#

pycord doesnt have that either

#

ext.commands, ext.pages, ext.tasks, ext.bridges is all they have

#
      cursor.execute(f"UPDATE users SET gold = gold + 100 WHERE id = {member.id}")

Dear, tell me how to add a value to all participants on the server?

#

do you save the guild ids too>?

slate swan
#

the button is in class, so what should i use to delete the message the view it sent with?

dusky pine
#

UPDATE users SET gold = gold + 100

will add 100 gold to all users

slate swan
#

kk

#

deletes message

slate swan
#

mhm

#

or you dont even need to pass it in the init, you can make it an attribute directly if its not a slash command

#

and Paginator?

#

!d discord.ext.commands.Paginator

unkempt canyonBOT
#

class discord.ext.commands.Paginator(prefix='```', suffix='```', max_size=2000, linesep='\n')```
A class that aids in paginating code blocks for Discord messages.

len(x) Returns the total number of characters in the paginator.
slate swan
#

broken embed lmao 😳

#
class discord.ext.commands.Paginator(prefix='`\`\`', suffix='`\`\`', max_size=2000, linesep='\n')
dry kelp
#

How can i create a custom URL link to access a member account with a bot??

The purpose of this is for:
It's for the antinuke basically.. if a nuker comes to mass ban what we want to do is to ban the nuker then unban all the members then trying to rejoin with they're accounts

slate swan
placid skiff
slate swan
slate swan
#

great then you can just ```py
view = YourView()
view.message = await send('stuff', view=view)

inside the view;

await self.message.delete() # to delete the message

#
        cursor.execute(f"""ALTER TABLE users DELITE COLUMN {qwer};""")

Oh, did I spell it wrong?

#

yep, DELETE

slate swan
#

what value did you supply for qwer, try changing this to "{qwer}"

dry kelp
#

also this will be just a optional thing

#

they can chose if they want it or not

vale wing
#

Use sqlite injections instead (or whatever ? insertions are called idrk)

slate swan
dry kelp
#

i read somewhere.. u can give perms to the bot to access ur acc / guilds so it can join back

slate swan
placid skiff
unkempt canyonBOT
#

async for ... in bans(*, limit=1000, before=..., after=...)```
Retrieves an [asynchronous iterator](https://docs.python.org/3/glossary.html#term-asynchronous-iterator "(in Python v3.10)") of the users that are banned from the guild as a [`BanEntry`](https://discordpy.readthedocs.io/en/latest/api.html#discord.BanEntry "discord.BanEntry").

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

Changed in version 2.0: Due to a breaking change in Discord’s API, this now returns a paginated iterator instead of a list.

Examples

Usage...
dry kelp
vale wing
dry kelp
#

what im looking for is to join back with the user if they allow the bot perms to access they're guild/acc

dry kelp
vale wing
#

What fields of account do you want to access

dry kelp
#

got enough time

#

all i need should be guild

#

right?... to join back with the user

#

that's my point

slate swan
#
    @commands.command(aliases = ["Гперм", "dperm"])
    async def command_Dperm(self, ctx, qwer):
        cursor.execute(f"""ALTER TABLE users DELETE COLUMN '{qwer}';""")
        conn.commit()
        await ctx.send("УГаленно")

Still doesn't work

placid skiff
#

A bot can't join a guild on it's own, the OAUTH link is required and the owner or an admin of the guild should open it

dry kelp
#

a bot to join a guild?

#

never said that

placid skiff
#

Then what is your problem? D_D

dry kelp
#

just read the entire messages i sent to understand...

slate swan
slate swan
#

Of view?

#

nah, the cmd

#

Using it in default help command šŸ’€

placid skiff
#

I read it 5 times already, you are not giving so much context, and if you want your bot to force a user to join a guild that is not possible either

dry kelp
#

so i own this antinuke bot.. right? some nukers are going to "MASS BAN" or mass kick whatever.. doesn't matter.. what the bot should do is ban the NUKER then unban all the banned members then if the members did allow permission to the bot to manage they're guilds the bot to automatically join with they're account

slate swan
#

Wonder how I join servers which I didn’t even get invited to pithink

dry kelp
#

it is possible ... bots can access users guilds with permissions

#

OAuth2

slate swan
dry kelp
placid skiff
#

He can't.

slate swan
#

can check that from settings>authorised apps

dry kelp
#

so if u just get hit by the nuker.. they will bring u back

slate swan
#

ā€œJoin servers for youā€

placid skiff
#

The bot can only unban the member, it can't force an user to join a server

dry kelp
#

it can if the user allows it lol

placid skiff
#

BRUH

slate swan
#

This guy šŸ’€

placid skiff
slate swan
#

How can you unban an user and force them to join a guild

dry kelp
#

that's where im spending my time to read

placid skiff
#

Read them all and then tell us if you find something to force an user to join a guild

dry kelp
slate swan
dry kelp
#

force a user ? never said forcing a user

#

lol

slate swan
#

make?

placid skiff
#

All you can do is to send them an invitation link to the guild

#

but the bot must see the user, and to see the user they must share a guild

#

otherwise the bot can't even DM the user

slate swan
#

If they have there dms on or have mutual servers

dry kelp
#

not even "make"

slate swan
#

In simple words
Unban them and try if your bot can dm him/her
And send the invite link
Ex:
ā€œ you were banned by a nuker in x guild, please rejoinā€

dry kelp
#

ok so this will make more sense

#

how to make guilds.join work so when a user authorizes a link, you can make them join servers on their behalf

placid skiff
#

Guilds doesn't have a join method D_D

dry kelp
placid skiff
#

That is for the OAUTH process

dry kelp
#

that's what im trying to do lol

placid skiff
#

Bruh OAUTH is used to make a bot join a guild, it doesn't work for users

dry kelp
#

nope because imagine DMing 50 banned members

slate swan
#

Mutual(s)

dry kelp
#

yeah if 50 are mutuals..

#

it's a good idea but i prefer reading to see if i can make this possible

placid skiff
#

Go to the disnake server, there you will find the owner, ask him D_D

#

He will say the same exact thing that i said D_D

slate swan
#
    @commands.command(aliases = ["Гперм", "dperm"])
    async def command_Dperm(self, ctx, qwer):
        cursor.execute(f"""ALTER TABLE users DELETE COLUMN '{qwer}';""")
        conn.commit()
        await ctx.send("УГаленно")

Dear, tell me what could be the problem?

vocal snow
#

Note that this will remove the column itself

#

Not sure if that's what you intend

#

!SQL injection

unkempt canyonBOT
#

SQL & f-strings
Don't use f-strings (f"") or other forms of "string interpolation" (%, +, .format) to inject data into a SQL query. It is an endless source of bugs and syntax errors. Additionally, in user-facing applications, it presents a major security risk via SQL injection.

Your database library should support "query parameters". A query parameter is a placeholder that you put in the SQL query. When the query is executed, you provide data to the database library, and the library inserts the data into the query for you, safely.

For example, the sqlite3 package supports using ? as a placeholder:

query = "SELECT * FROM stocks WHERE symbol = ?;"
params = ("RHAT",)
db.execute(query, params)

Note: Different database libraries support different placeholder styles, e.g. %s and $1. Consult your library's documentation for details.

See Also
• Extended Example with SQLite (search for "Instead, use the DB-API's parameter substitution")
• PEP-249 - A specification of how database libraries in Python should work

vocal snow
#

You should also take care of this

slate swan
dry kelp
#

@slate swan @placid skiff asked in pycord it is possible

slate swan
dry kelp
#

this is what i tried to do

slate swan
dry kelp
#

accessing token

#

as i can read here

placid skiff
#

Most probably you will have to do this through API requests or you can search if hikari has that, btw it requires the user to interact with the OAUTH anyways

dry kelp
placid skiff
#

it's the oauth token for the user

dry kelp
#

yep

slate swan
vocal snow
#

Oh that's true

#

Yeah the placeholders only work for DML commands. Usually you wouldn't dynamically change the schema like that

slate swan
#

oh, are you overriding HelpCommand class?

slate swan
#

Trying to send a button with help embed so the user can delete the embed

#

On interaction

#

show the part where you initialise that view and send the message

#
view = helpowo1()
        view.message = await self.send(embed=embed,view=helpowo1()) 
dry kelp
#

how can i create a list in the models ? im using postgreSQL

dry kelp
#

like a list of ids

slate swan
#

Oh-

dry kelp
#

should be members ids

slate swan
#

mb i didnt notice it

slate swan
#
view = helpowo1()
        view.message = await self.send(embed=embed,view=view())
#
    @commands.command(aliases = ["аперм", "aperm"])
    async def command_Aperm(self, ctx, qwer, rewq, *, amount):
        cursor.execute(f"""ALTER TABLE users ADD COLUMN {qwer} {rewq};""")
        cursor.execute(f"UPDATE users SET gems = {amount}")
        conn.commit()
        await ctx.send("Добавленно")
    @commands.command(aliases = ["баланс"])
    async def command_ballans(self, ctx, qwer):

        gems = cursor.execute("SELECT {} From users WHERE id = {}".format(qwer, ctx.author.id)).fetchone()[0]

        await ctx.send(
            f"""Твой баланс **{gems}** гемов"""
        )

Dear, tell me why, after the command and the output of the balance, it shows that I do not have this value

#

Traceback (most recent call last):
File "main.py", line 55, in <module>
async def membercount(self, ctx):
File "/home/runner/slash-code/venv/lib/python3.8/site-packages/discord/app_commands/commands.py", line 1592, in decorator
return Command(
File "/home/runner/slash-code/venv/lib/python3.8/site-packages/discord/app_commands/commands.py", line 523, in init
self._params: Dict[str, CommandParameter] = _extract_parameters_from_callback(callback, callback.globals)
File "/home/runner/slash-code/venv/lib/python3.8/site-packages/discord/app_commands/commands.py", line 380, in _extract_parameters_from_callback
raise TypeError(f'parameter {parameter.name!r} is missing a type annotation in callback {func.qualname!r}')
TypeError: parameter 'ctx' is missing a type annotation in callback 'membercount'

#

anyone?

vocal snow
slate swan
vocal snow
#

App command callbacks don't get a CTX parameter

slate swan
#
@client.tree.command()
@app_commands.rename(text_to_send='text')
@app_commands.describe(text_to_send='Text to send in the current channel')
async def send(interaction: discord.Interaction, text_to_send: str):
    """Sends the text into the current channel."""
    await interaction.response.send_message(text_to_send)
```@vocal snow this is correct for slash command?
slate swan
#

@vocal snow say please

slate swan
#

if its the help class, you could probably do self.context.send() to get a discord.Message object.

swift pumice
#

does someone know a capybara api?

slate swan
slate swan
#

there's no check for that but

#

!d discord.Client.application_info

unkempt canyonBOT
#

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

Retrieves the bot’s application information.
slate swan
#

!d discord.AppInfo.owner

unkempt canyonBOT
slate swan
#

this might help, if you want it to be dynamic
else use a if statement with manually typed id lol

#

nvm , bot has a is_owner method too

#

you can do that by changing guild settings..

#

sarthak is so smort šŸ˜” I wish we were all like him

past onyx
#

i need help 😦 :
`@tasks.loop()
async def autocircle():
voice_channel = client.get_channel(988413546343841802)
print(voice_channel.members)

for member in voice_channel.members:
    oldmembercount = membercount
    membercount = oldmembercount + one
    if membercount > 3:
        await voice_channel.edit(name="Closed Circle1")
await asyncio.sleep(2)`

error :

[<Member id=456443941169004545 name='Space_Banane' discriminator='5444' bot=False nick=None guild=<Guild id=986758318175449088 name='Losti-Cord' shard_id=None chunked=False member_count=10>>] Unhandled exception in internal background task 'autocircle'. Traceback (most recent call last): File "C:\Users\marku\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\tasks\__init__.py", line 101, in _loop await self.coro(*args, **kwargs) File "e:\Dc bot\Beta.py", line 513, in autocircle oldmembercount = membercount

slate swan
past onyx
#

ok

slow fog
past onyx
#

[<Member id=456443941169004545 name='Space_Banane' discriminator='5444' bot=False nick=None guild=<Guild id=986758318175449088 name='Losti-Cord' shard_id=None chunked=False member_count=10>>] Unhandled exception in internal background task 'autocircle'. Traceback (most recent call last): File "C:\Users\marku\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\tasks\__init__.py", line 101, in _loop await self.coro(*args, **kwargs) File "e:\Dc bot\Beta.py", line 513, in autocircle oldmembercount = membercount UnboundLocalError: local variable 'membercount' referenced before assignment

slate swan
past onyx
#

thats what is there

slate swan
past onyx
#

ok thanks

slow fog
cloud dawn
#

Why is len() not used?

dry kelp
slate swan
dry kelp
#

where are those in the docs? btw it's a thread not a channel

#

i don't know because the names in the docs are pretty weird

#

nice what lol

#

the archive is just confusing me

cloud dawn
#

What do you want to change or archive?

slate swan
#

!d discord.Thread.auto_archive_duration

unkempt canyonBOT
slate swan
#

nvm

dry kelp
#

there's nothing i want to change lol.. i just want to check whenever a change is being made to any of these

#

so the bot is just going to set them back

unkempt canyonBOT
#

discord.on_guild_update(before, after)```
Called when a [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild "discord.Guild") updates, for example:

• Changed name

• Changed AFK channel

• Changed AFK timeout

• etc...
dry kelp
#

the names in pycord docs are just being confusing ... so i don't really know which archive is which šŸ˜‚

#

that's not my question

dry kelp
#

logs

#

every change made lol? that's not the question

cloud dawn
dry kelp
#

u just replied to that

slate swan
#

.....

dry kelp
#

which one is this in the docs?

slate swan
dry kelp
#

auto_archive_duration?

slate swan
#

yes.

#

that's what I said...

dry kelp
#

what about the other one?

slate swan
#

other one?

#

what other one?

dry kelp
shrewd apex
#

u mean change in guild settings?

cloud dawn
unkempt canyonBOT
dry kelp
#

oh my god

slate swan
dry kelp
#

wait..

#

i should ask in pycord about this

cloud dawn
#

It's a permission.

#

People with the manage thread permission can only archive threads when that is disabled.

dry kelp
#

and that's not what im trying to do again..

#

im trying to check if is being changed to true/false by a administrator

shrewd apex
#

audit logs

dry kelp
#

🤦

cloud dawn
#

Nah something else but he can just use the docs or go to the people on pycord.

dry kelp
#

i dont find it in the docs

#

thats why im asking here

cloud dawn
#

And we are trying to help you but you being so impatient and defensive isn't either efficient or nice.

#

!d discord.on_thread_update

unkempt canyonBOT
#

discord.on_thread_update(before, after)```
Called whenever a thread is updated. If the thread could not be found in the internal cache this event will not be called. Threads will not be in the cache if they are archived.

If you need this information use [`on_raw_thread_update()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_raw_thread_update "discord.on_raw_thread_update") instead.

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

New in version 2.0.
cloud dawn
#

!d discord.Thread.locked

unkempt canyonBOT
brave flint
#

why i always got NoneType?
DB is async, Awaited the def
when i tried in a seprate files inpage shown the number

maiden fable
#

Seems like page is None

brave flint
#

arl tested in seprate files and it shown 2 as in the db

maiden fable
brave flint
#

used asyncio.run in seprate files shown value

#

but in main files no value

#

GGs

maiden fable
#

Code

#

Weirddd

#

U got an error handler?

vale wing
#

Might be because you don't have await bot.process_commands in on_message event but not sure if it relates to the slash commands. Anyways try changing @bot.event to @bot.listen()

#

Sorry didn't notice that

#

@slate swan I suspect that you need to actually assign your tree to tree attribute of the client

#

Wait just one command?

cloud dawn
#

No this is good, what I think is happening is because you also sync it to global you need to wait 1 hour ish.

slate swan
#

also, you don't need to wait for 1 hrs anymore wut

sage otter
#

not really relevant, but yerl I thought you said a while ago that you weren’t gonna switch back to dpy and stay on disnake?

cloud dawn
#

Personally I've made it like "cogs".

#

I'm looking at it but I can't see quickly what's wrong.

#

What if you were to do ```py
await tree.sync(guild=guild)

vale wing
#

What on earth is this and how is it related to discord bots

eager bluff
#

is an alt anyway

cloud dawn
#

Isn't that his security cookie lol.

slate swan
#
@app_commands.command(name="top-command") async def my_top_command( interaction: discord.Interaction) -> None: """ /top-command """ await interaction.response.send_message("Hello from top level command!", ephemeral=True)ā€Šā€Šā€Š

#

Correct code?

cloud dawn
#

Tbf I've done cookie injections before.

#

Educational purposes.

slate swan
#

not true you can just opt out to make the library automatically make changes

#

Sarth typing... šŸ‘€

#

sync_commands=False in commands.Bot will stop the library from automatically doing stuff

#

you can do the same for cogs too.

cloud dawn
#

Basically if you want auto sync take disnake else just stick with dpy.

slate swan
#

yeah, the point was just that you still have the control while using disnake

eager bluff
#

anyone know why this happens?

discord.ext.commands.errors.MissingRequiredArgument: username is a required argument that is missing.

vale wing
eager bluff
#

s

grim oar
#

s

sage otter
#

Parse doesn’t seem like the right word there

eager bluff
#
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 855, in invoke
    await self.prepare(ctx)
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 789, in prepare
    await self._parse_arguments(ctx)
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 697, in _parse_arguments       
    transformed = await self.transform(ctx, param)
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 542, in transform
    raise MissingRequiredArgument(param)
discord.ext.commands.errors.MissingRequiredArgument: username is a required argument that is missing.```
#

@vale wing

vale wing
#

Yeah you just didn't provide required argument

vale wing
eager bluff
vale wing
#

Provide it?

#

What's your command and how do you use it in discord

unkempt canyonBOT
#

Hey @slate swan!

It looks like you tried to attach file type(s) that we do not allow (.rar). We currently allow the following file types: .gif, .jpg, .jpeg, .mov, .mp4, .mpg, .png, .mp3, .wav, .ogg, .webm, .webp, .flac, .m4a, .csv, .json.

Feel free to ask in #community-meta if you think this is a mistake.

slate swan
#

tf?

grim oar
#

You can't upload files

slate swan
#

bruh i need help with smth but it wont let me send it so people can see whats wrong with the code

grim oar
#

Send only the relevant code

vale wing
slate swan
#

can i send it to someones dms who knows what they're doing

grim oar
#

No

vale wing
#

Just use pastebin

#

!paste

grim oar
#

Yes

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.

dull terrace
#

I've made two pretty good bots, now what do i do froggy_chill

grim oar
#

paste the code in pastebin and send

dull terrace
vale wing
slate swan
slate swan
#

lmao

dull terrace
#

okay so is this a dumb idea, i've made an art bot, a game bot and now if i make a social bot i could package them all together 7739monkathink

#

make one bot with way too many features

grim oar
#

Yes

vale wing
#

I am bored of making bots and now I am making some stupid game in unity

grim oar
#

I am bored of bots so i went back to depression

dull terrace
#

i'm tempted to try making a 3d game but still only know python sadcat

vale wing
#

C# is a cool language too

grim oar
#

Java copy

#

Go learn c++

dull terrace
#

has anyone tried the new unreal engine 7739monkathink