#discord-bots

1 messages · Page 763 of 1

left crater
#

ah ok

slate swan
#

Send the message to the user before banning the user.

left crater
#

ok

#

it is sending the message before banning them

#

await member.send(message)
await member.ban(reason=reason)

mental kraken
#

Seems like you're responding to a timed out interaction or respond twice
Make sure that your autocomplete function is fast enough

slate swan
#

why add a reason value when you can add a defualt value in params

#

(reason="Being bad!")
has a default value of a string

shy elm
#

Add the module pip install dnspython

slate swan
#

You need help?

sage niche
#

Hey does anyone have a great way to implement a discord bot with a website,
the idea is that u click a button on a website to get a specific role on the discord server

tawdry perch
sage niche
#

hmm yeah this could work… but i’m looking for more efficient ways tbh

tawdry perch
#

what would be the efficient way?

#

You could just trigger a function on your discord bot that would be ran when ever you want

sage niche
#

how do I trigger a command from a website?

tawdry perch
#

The method I was thinking depends a lot of the way you have the web app designed

sage niche
#

the issue is I didn’t design it myself 😖

tawdry perch
#

:/

sage niche
#

im not a web dev

#

so i’m quite clueless rn

tawdry perch
#

you would need a user ID to be passed smh at least

#

you could do that via OAuth2

sage niche
#

yeah… well the easiest way would be to send a message in a discord channel using a simple webhook that the discord bot catches and then assigns the role

#

However im not sure if this can be exploited easily or if it would work 100% of time

tawdry perch
#

gl figuring it out

sage niche
#

thx 😵‍💫

slate swan
#

hello. I want to make a command with 2 buttons and when you press the 1st it starts a timer and when click the 2nd it end and gives that time. I know how to make the buttons but no how to start the timer

tawdry perch
tawdry perch
#

👍.

slate swan
# tawdry perch 👍.

so i did this. ```python
@nextcord.ui.button(label=" ", style=nextcord.ButtonStyle.green)
async def on(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
user = interaction.user
start_time = time.time()
emb2=nextcord.Embed(title="🟢 On Duty", description=f"{user.mention} Μόλις μπήκες σε υπηρεσία. Πάτα το κόκκινο κουμπί για να βγεις.", color=color, timestamp=datetime.now())
emb2.set_author(name=user.name, icon_url=user.avatar.url)
await interaction.response.send_message(embed=emb2, ephemeral=True)

        @nextcord.ui.button(label=" ", style=nextcord.ButtonStyle.red)
        async def off(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
                user = interaction.user
                end_time = time.time()
                time_lapsed = end_time - start_time
                emb2=nextcord.Embed(title="🔴 Off Duty", description=f"{user.mention} βγήκες από υπηρεσία. Ο χρόνος που ήσουν online είναι: {time_lapsed}.", color=color, timestamp=datetime.now())
                emb2.set_author(name=user.name, icon_url=user.avatar.url)
                await interaction.response.send_message(embed=emb2, ephemeral=True)
tawdry perch
#

it worked?

slate swan
tawdry perch
#

nice!

quick gust
#

Nevermind (sorry for the ping The Lost Programmer)

earnest jungle
#

Why this programm is not working

import telebot
token='xxx'
bot=telebot.TeleBot(token)
keybord1 = telebot.types.ReplyKeyboardMarkup(True)
keybord1.row('1','2')
@bot.message_handler(commands=['start'])
def start_message(message):
   bot.send_message(message.chat.id,'Привет')
@bot.message_handler(content_types=['text'])
def send_text(message):
   message.text.lower()
   if message.text == 'Привет':
       bot.send_message(message.chat.id, 'Прив', reply_markup=keybord1)
maiden fable
#

Uhhh

#

U can use isinstance

#

if isinstance(channel, discord.VoiceChannel):

jovial storm
#

how do you sense when a new message is entered by a specific user?

jovial storm
cloud dawn
slate swan
#

Exactly

jovial storm
#

so like

#

if i send a command then it responds and it waits for my response

slate swan
#

bot.wait_for("message", ...)

rocky trench
#
@bot.command()
@commands.has_permissions(administrator = True)
async def unwarn(ctx, member : discord.Member = None, position = None):
    y = json.load(open('warns.json'))
    reasons = y[str(member.id)]['reasons']
    position -= 1
    del reasons[position] ```discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: can only concatenate str (not "int") to str
slate swan
rocky trench
#

I'm trying to pop the reason mentioned out (for example unwarn @rocky trench 1

rocky trench
#

in dpy they ignoring me or sum lol

slate swan
#

convert to int

cloud dawn
#

!d disnake.CategoryChannel.is_nsfw

slate swan
unkempt canyonBOT
rocky trench
#

probably

cloud dawn
#

!d disnake.Guild.rules_channel

unkempt canyonBOT
#

property rules_channel: Optional[disnake.channel.TextChannel]```
Return’s the guild’s channel used for the rules. The guild must be a Community guild.

If no channel is set, then this returns `None`.

New in version 1.3.
slate swan
#

they tend to be less friendly to people who don't bother learning python before making bots

rocky trench
#

so what would I need to change? I'm a self learnt coder and didnt really use that before

slate swan
#

I've observed

rocky trench
slate swan
rocky trench
#

ok

cloud dawn
#

!d disnake.StageChannel

unkempt canyonBOT
#

class disnake.StageChannel```
Represents a Discord guild stage channel.

New in version 1.7.

x == y Checks if two channels are equal.

x != y Checks if two channels are not equal.

hash(x) Returns the channel’s hash.

str(x) Returns the channel’s name.
rocky trench
unkempt canyonBOT
#

class disnake.StoreChannel```
Represents a Discord guild store channel.

x == y Checks if two channels are equal.

x != y Checks if two channels are not equal.

hash(x) Returns the channel’s hash.

str(x) Returns the channel’s name.
rocky trench
#

i wanted it to pop out the first reason

#

so I say 1, pops out first

#

thats why I did position -=1

#
@bot.command()
@commands.has_permissions(administrator = True)
async def unwarn(ctx, member : discord.Member = None, position = None):
    y = json.load(open('warns.json'))
    reasons = y[str(member.id)]['reasons']
    position = int(position)
    position -= 1
    del reasons[position] ```
slate swan
#

what are you doing lol

rocky trench
cloud dawn
slate swan
#

if you want to remove it from a database

rocky trench
#

its json file

slate swan
#

which contains what

#

a dictionary?

cloud dawn
#

Just del the key

rocky trench
#

yh

#
@bot.command()
@commands.has_permissions(administrator = True)
async def unwarn(ctx, member : discord.Member = None, position = None):
    y = json.load(open('warns.json'))
    reasons = y[str(member.id)]['reasons']
    position = int(position)
    position -= 1
    reasons.pop(position) ```
#

pop is for txt file tho ig?

slate swan
#

pop deletes an elem and returns it

#

I believe

rocky trench
#

well it didnt work either

slate swan
#

idk what the best approach is but I'd personally remove the warning and then rewrite the json file to contain the edited data

quaint epoch
#

is there a on_message_edit event? and if so what does it return?

rocky trench
slate swan
quaint epoch
#

wait im confused

#

so what does it return?

rocky trench
#

'before edit' and 'after edit'

quaint epoch
slate swan
#

i mean it doesn't return anything, that's for you to do

slate swan
#

are you asking about the parameters

slate swan
rocky trench
#

not sure what the point is of that

quaint epoch
#

so is it async def on_message_edit(old_message, new_message):?

slate swan
#

when you do reasons.remove it doesn't edit the file

#

it edits reasons

rocky trench
#

So I need to write it back to the file

slate swan
#

yes

rocky trench
#

But I dont want my entire file to change, just the "reasons"

cloud dawn
#
@bot.command()
@commands.has_permissions(administrator = True)
async def unwarn(ctx, member: discord.Member, position: int):
    with open('warns.json', mode='r+') as f:
        y = json.load(f)

        y[str(member.id)]['warns'] -= 1
        del y[str(member.id)]['reasons'][position - 1]

        f.write(json.dumps(y, sort_keys=True, indent=4))
rocky trench
slate swan
#

ye, but it would be the same

cloud dawn
slate swan
#

the only thing different would be reasons

rocky trench
#

lemme see

cloud dawn
#

And warn amount

rocky trench
#

you guys know I got multiple 'reasons' in there right

cloud dawn
slate swan
#

ye

rocky trench
#

didnt notice it smh

slate swan
cloud dawn
#

I also don't recommend using json

rocky trench
cloud dawn
#

As a dutch person i'm very disappointed.

slate swan
#

nice reason nonetheless

rocky trench
#

I support lgbtq+ 😅

slate swan
#

jk

rocky trench
rocky trench
#

now it didnt wipe the file, but added an entire overwrite to it

cloud dawn
#

You mean it appended

rocky trench
#

yh

#

what does sort_keys do?

cloud dawn
#

Alphabetically

rocky trench
#

ah that way

#

but how do I not make it append?

wary ice
#
Traceback (most recent call last):
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "c:\Users\user\.vscode\extensions\ms-python.python-2021.12.1559732655\pythonFiles\lib\python\debugpy\__main__.py", line 45, in <module>
    cli.main()
  File "c:\Users\user\.vscode\extensions\ms-python.python-2021.12.1559732655\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 444, in main
    run()
  File "c:\Users\user\.vscode\extensions\ms-python.python-2021.12.1559732655\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 285, in run_file
    runpy.run_path(target_as_str, run_name=compat.force_str("__main__"))
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 268, in run_path
    code, fname = _get_code_from_file(run_name, path_name)
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 237, in _get_code_from_file
    with io.open_code(decoded_path) as f:
FileNotFoundError: [Errno 2] No such file or directory: 'c:\\Users```
#

what is this error ?

cloud dawn
# rocky trench but how do I not make it append?
@bot.command()
@commands.has_permissions(administrator = True)
async def unwarn(ctx, member: discord.Member, position: int):
    with open('warns.json', mode='r+') as f:
        y = json.load(f)

        y[str(member.id)]['warns'] -= 1
        del y[str(member.id)]['reasons'][position - 1]

        f.truncate(0)
        f.write(json.dumps(y, sort_keys=True, indent=4))
quaint epoch
#

btw, for the check i recommend changing it to @commands.has_permisions(view_audit_log=True)

rocky trench
#

nul nul nul

quaint epoch
rocky trench
#

me neither lol

quaint epoch
#

it's kinda scary tbh

#

i wouldn't want that happening to me

rocky trench
#

xd

#

@cloud dawn

cloud dawn
#

Open it in a normal text editor

rocky trench
#

wdym normal text editor

#

r?

quaint epoch
#

notepad

rocky trench
#

but the file is json

quaint epoch
#

it doesn't matter

rocky trench
#

I would need to change everything in my scripts?

rocky trench
#

I see

#

Its not in notepad, the nul nul nul

#

but I always use visual studio code

quaint epoch
cloud dawn
rocky trench
#

why it spams that

quaint epoch
cloud dawn
#

json is strange

quaint epoch
#

programming in general is strange

cloud dawn
#

life is strange

#

Pretty good game btw

quaint epoch
#

for ME, if i ran a print statement of a json_file.read(), the json file apparently wasn't set, that's just messed up (even tho i did set it)

rocky trench
#

is there also a way to wipe all 'reasons' at once?

manic crescent
#

Does somebody know whats wrong here?

cloud dawn
cloud dawn
rocky trench
# cloud dawn ```py y[str(member.id)]['reasons'] = [] ```
@bot.command()
async def clearwarns(ctx, member : discord.Member = None):
    with open('warns.json', mode='r') as f:
        y = json.load(f)
        y[str(member.id)]['reasons'] = []
        y[str(member.id)]['warns'] -= y[str(member.id)]['warns']
        f.truncate(0)
        f.write(json.dumps(y, sort_keys=True, indent=4))```
#

would this do it? imma have to add if .. is none too now

#

I got no idea

cloud dawn
rocky trench
#

isnt it the same tho lol

cloud dawn
#

0xFFFFFF is white

#

Replace # with 0x

cloud dawn
rocky trench
#

idk xd

slate swan
#

hello. Sorry for the interupting. I have this code but i get this error ```python
@nextcord.ui.button(label=" ", style=nextcord.ButtonStyle.green)
async def on(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
user = interaction.user
start_time = time.time()
emb2=nextcord.Embed(title="🟢 On Duty", description=f"{user.mention} Μόλις μπήκες σε υπηρεσία. Πάτα το κόκκινο κουμπί για να βγεις.", color=color, timestamp=datetime.now())
emb2.set_author(name=user.name, icon_url=user.avatar.url)
await interaction.response.send_message(embed=emb2, ephemeral=True)

        @nextcord.ui.button(label=" ", style=nextcord.ButtonStyle.red)
        async def off(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
                user = interaction.user
                end_time = time.time()
                time_lapsed = end_time - start_time
                emb2=nextcord.Embed(title="🔴 Off Duty", description=f"{user.mention} βγήκες από υπηρεσία. Ο χρόνος που ήσουν online είναι: {time_lapsed}.", color=color, timestamp=datetime.now())
                emb2.set_author(name=user.name, icon_url=user.avatar.url)
                await interaction.response.send_message(embed=emb2, ephemeral=True)

NameError: name 'start_time' is not defined

tawdry perch
#

start_time = time.time() can't be accessed outside the function

#

you could use self.start_time = ... which should work, but I'm not sure

sacred sigil
#

how would I go about making an invite checker?

#

I'm aware of guild.invites() but could I use member.guild.invites()?

slate swan
#

but i want to split it ine hours:mins:sec

coral vessel
#

Can't run discord.py via VS code
i try reinstall python still got this message:

Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.

tawdry perch
#

That is nice for formatting datetime strings

rocky trench
#

@cloud dawn

#

my warn command doesnt work anymore for sum reason

#
@bot.command()
@commands.has_permissions(administrator = True)
async def warn(ctx, member : discord.Member = None, *, reason = None):
    y = json.load(open('warns.json'))
    if member ==None:
        embed = discord.Embed(
            title = '**Error**',
            description = 'Please provide a member to warn!',
            color = (0x3498db)
        )
        return await ctx.send(embed=embed)
    if reason == None:
        if str(member.id) in y:
            y[str(member.id)]["reasons"].append('Unknown')
            y[str(member.id)]['warns'] +=1 
            print(y)
            json.dump(y, open('warns.json','w'), indent = 4)
            embed = discord.Embed(
                title = '**Warned**',
                description = f'Succesfully warned {member}',
                color = (0x3498db)
            )
            embed.add_field(name =  '**Reason:**', value = 'unknown', inline = False )
            await ctx.send(embed=embed)

        
        else:
            y = json.load(open('warns.json'))
            y[str(member.id)] ={"warns": 1, "reasons": ['Unknown']}
            print(y)
            json.dump(y, open("warns.json",'w'), indent = 4)
            embed = discord.Embed(
                title = '**Warned**',
                description = f'Succesfully warned {member}',
                color = (0x3498db)
            )
            embed.add_field(name =  '**Reason:**', value = 'unknown', inline = False )
            await ctx.send(embed=embed)
    else:
        if str(member.id) in y:
            y[str(member.id)]["reasons"].append(reason)
            y[str(member.id)]['warns'] +=1 
            json.dump(y, open('warns.json','w'), indent = 4)
            embed = discord.Embed(
                title = '**Warned**',
                description = f'Succesfully warned {member}',
                color = (0x3498db)
            )
            embed.add_field(name =  '**Reason:**', value = reason, inline = False )
            await ctx.send(embed=embed)
        
        else:
            y = json.load(open('warns.json'))
            y[str(member.id)] ={"warns": 1, "reasons": [reason]}
            json.dump(y, open("warns.json",'w'), indent = 4)
            embed = discord.Embed(
                title = '**Warned**',
                description = f'Succesfully warned {member}',
                color = (0x3498db)
            )
            embed.add_field(name =  '**Reason:**', value = reason, inline = False )
            await ctx.send(embed=embed)```
#

it used to work

#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: JSONDecodeError: Expecting value: line 1 column 1 (char 0)

#

its bc of the nul nul 100%

slate swan
#

but i get this error

#

TypeError: unsupported operand type(s) for -: 'str' and 'str'

#

hello

#

can someone help me with this problem in discord.py

#

@bot.command()
async def insult(ctx):
  async with aiohttp.ClientSession() as session:
      request = await session.get('https://evilinsult.com/generate_insult.php?lang=en&type=text')
      insultjson = await request.json(content_type='text/html')

  await ctx.send(url=insultjson['insult'])
tawdry perch
slate swan
quaint epoch
#

!d disnake.Message.delete

unkempt canyonBOT
#

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

Deletes the message.

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

Changed in version 1.1: Added the new `delay` keyword-only parameter.
tawdry perch
slate swan
honest shoal
honest vessel
#

why the heck this aint working? ```py
@commands.command()
@commands.is_owner()
async def changenick(self, ctx, *, nickname):
print("Changing nick on bot.")
await ctx.guild.me.edit(nick=nickname)

slate swan
honest vessel
#

oh it sais i dont own the bot

tawdry perch
#

Ok so it returns a float...

#

I can't really help any further but I suggest asking the time and strftime in #python-discussion

final iron
#

No

#

!rule 5

unkempt canyonBOT
#

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

slate swan
#

!rule 1

unkempt canyonBOT
honest vessel
#

guys explain to me why:
owner_id=os.getenv("IRL_OWNER") has my id but refuse

#
    @commands.command()
    @commands.is_owner()
    async def changenick(self, ctx, *, nickname):
        print("Changing nick on bot.")
        await ctx.guild.me.edit(nick=nickname)
#

suddenly stopped

#

my .env == IRL_TOKEN=<censored> IRL_OWNER=<censored but correct>

tawdry perch
slate swan
# tawdry perch Are you the owner of bot account?

sorry for bothering you again. I have this command, it works but i want to make it like refresh every one min so it can update the status. Do you know how?? ```python
em = nextcord.Embed(title=':green_circle: Server Is Online!', description=f"Για να συνδεθείτε στον {name}Ανοίγεται FiveM, πατάτε F8 και γράφεται connect {ip}:{port}", color=orange, timestamp=datetime.now())
em.set_author(name=name)
em.add_field(name = 'Online Playes:', value= str(events['clients'])+"/"+str(events['sv_maxclients']), inline = True)
em.add_field(name = 'Server Ip:', value= f"{ip}:{port}", inline = True)
await ctx.send(embed=em)
commandscha = self.client.get_channel(int(config['commandslogs']))
user10 = ctx.author
user = ctx.author
channel10 = ctx.message.channel
prefix10 = config["prefix"]
emb6=nextcord.Embed(title="New Commands Use!", description=f"", color=orange, timestamp=datetime.now())
emb6.set_author(name=user.name, icon_url=user.avatar.url)
emb6.add_field(name="User: ", value=f"{user10.mention}")
emb6.add_field(name='Channel: ', value=f"{channel10.mention}")
emb6.add_field(name='Command: ', value=f"{prefix10}status")
await commandscha.send(embed=emb6)

tawdry perch
#

Sorry, I'm not able to help atm

slate swan
final iron
unkempt canyonBOT
#

discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True, loop=...)```
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/master/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
upbeat dirge
#

Quick question if Discord.py has been archived and doesn't support / cmd's what do people use?

unkempt canyonBOT
upbeat dirge
slate swan
#

my code

#

help

slate swan
#

!d discord.Role.delete

unkempt canyonBOT
#

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

Deletes the role.

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

pithink does the role exist?

#

Show your code

#

The topmost role is the everyone role and cannot be deleted

#

List indexing

#

Skip the everyone role with list indexing

#

If you're wondering how
ctx.guild.roles returns a list of the roles

#

You can, do [1:] to ignore the everyone role

#

No

#

Its there

#

Hehe

knotty gazelle
slate swan
#

Welcomeeee

slate swan
knotty gazelle
#

`Nah

slate swan
#

No?

knotty gazelle
#

cuz it says @commands.is_owner()

#

that means owner of the guild

slate swan
#

Uh

#

I see

honest vessel
tawdry perch
#

!d discord.ext.commands.is_owner

unkempt canyonBOT
#

@discord.ext.commands.is_owner()```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that checks if the person invoking this command is the owner of the bot.

This is powered by [`Bot.is_owner()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.is_owner "discord.ext.commands.Bot.is_owner").

This check raises a special exception, [`NotOwner`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NotOwner "discord.ext.commands.NotOwner") that is derived from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
slate swan
tawdry perch
#

Ye owner of bot

slate swan
#

Welp

honest vessel
#

😄

#

guess it has it owns life now 😄

knotty gazelle
#

oh ok

honest vessel
#

but bot runs as normal

knotty gazelle
#

sorry i didnt now

honest vessel
#

kek

knotty gazelle
#

cuz always when i tested it did cuz i was owner of the guild and the bot

slate swan
#

Lmao, jk, dont take it seriously

honest vessel
#

lol its funny tho

#

like wtf

#

only 1 running

knotty gazelle
#

and

#

what da problem?

#

@cedar smelt

slate swan
#

Use the isinstance function

knotty gazelle
#
if channel.id == "your channel id":
  ...
#

is this it? @cedar smelt

slate swan
#

Idk about announcements, but you can check for sytem channels, text channels and voice channels and nsfw channels using the isinstance method

knotty gazelle
#

soo

#
nextcord.utils.get(ctx.guild.channels, name="channel name")
``` this @cedar smelt
#

so like```py
nextcord.utils.get(ctx.guild.channels, name="rukes")

slate swan
knotty gazelle
#

and what does that mean?

#

@cedar smelt i dont get what your trying to do

#

oh

#
#

like this?

#

like a database is needed i think

slate swan
#

Use the xenon bot, easy

#

Or just copy server template link

pseudo crystal
#
    code = "".join(random.choices(string.ascii_uppercase + string.digits + string.ascii_lowercase,k=16))
     return f'{passwort}' ``` 
How to fix this? i wanna use this in a ctx message
knotty gazelle
#
@client.command()
async def restore(ctx):
  guild = ctx.guild
  RulesChannel = await guild.create_text_channel(name="Rules")
``` @cedar smelt
#

something like this

knotty gazelle
jovial storm
#

how do you check for roles in a user?

forest beacon
#

how can i freeze all channels in a server?

slate swan
unkempt canyonBOT
#

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

These roles are sorted by their position in the role hierarchy.
knotty gazelle
knotty gazelle
slate swan
#

You're misguiding people

jovial storm
knotty gazelle
#

yes but you wanna fix errors here for full commands you should watch tutorials

slate swan
forest beacon
knotty gazelle
# forest beacon how can i freeze all channels in a server?

Hey!
Thanks for watching todays video, todays video I really hope you enjoyed and join my discorddd :) Also thank you SO MUCH for 1350 subscribers!!

LINKS -
Join my Discord - https://discord.gg/twHW4UUJGq

Nextcord Server - https://discord.gg/Ucmae5Kbwb

Set Up VSC - https://www.youtube.com/watch?v=KpzkP...

Set Up PYTHON - https://youtu.be/h4...

▶ Play video
forest beacon
#

Like the silence command here

slate swan
forest beacon
#

Sorry. Basically what silence does here is remove send_messages permissions from every channel. I have code that works for the channel the command is sent in but trying to recycle that could with a for loop didnt work.

knotty gazelle
forest beacon
#

Dude its an 8 minute video.

knotty gazelle
#

so?

knotty gazelle
slate swan
#

Iterate thru guild.channels and use channel.set_permissioms

forest beacon
#

I havent made it through it. Im not meteor man.

forest beacon
slate swan
#

@knotty gazelle Stop
Misguiding
Try
To
HELP

forest beacon
#

Doesn't work

slate swan
#

Not for other ones

forest beacon
knotty gazelle
slate swan
#

True*

#

That means u r giving them the perm

forest beacon
#

blobfacepalm I copied the wrong function. Thank you lmao

slate swan
#

!d discord.Guild.system_channels

forest beacon
#

Changed that, only works for the channel it was sent in.

slate swan
#

If that was it?

knotty gazelle
#

!d discord.Guild

unkempt canyonBOT
#

class discord.Guild```
Represents a Discord guild.

This is referred to as a “server” in the official Discord UI.

x == y Checks if two guilds are equal.

x != y Checks if two guilds are not equal.

hash(x) Returns the guild’s hash.

str(x) Returns the guild’s name.
knotty gazelle
#

oh this works not as Mr.Danny 😅

slate swan
#

!d discord.TextChannel.is_nsfw

unkempt canyonBOT
#

is_nsfw()```
[`bool`](https://docs.python.org/3/library/functions.html#bool "(in Python v3.9)"): Checks if the channel is NSFW.
slate swan
#

Click on it , it will take u to all other checks

cold sonnet
#

discord.Guild

slate swan
#

Ow

cold sonnet
#

!d discord.Guild.system_channel

unkempt canyonBOT
#

property system_channel: Optional[discord.channel.TextChannel]```
Returns the guild’s channel used for system messages.

If no channel is set, then this returns `None`.
slate swan
#

Welp

knotty gazelle
slate swan
#

Lol

knotty gazelle
slate swan
knotty gazelle
#

y?

slate swan
#

Huh?

knotty gazelle
#

why?

#

but less characters

slate swan
knotty gazelle
#

It was very useful right or is my nick right>

slate swan
knotty gazelle
#

ooh ok

#

ty 😢

slate swan
#

Welcome

#

What's the point to joining the string lol , it returns the same thing

#

!e print("".join("loser"))

knotty gazelle
slate swan
#

Ahan

knotty gazelle
#

🙂

slate swan
#

Suits me

knotty gazelle
slate swan
#

It's rust

knotty gazelle
#

oh lol

quaint epoch
#

if a message contains a link like @joe, i found an exploit in the snekbox, here it is https://www.youtube.com/watch?v=dQw4w9WgXcQ how to i find and pull just the link from it?

slate swan
slate swan
cold sonnet
#

prolly check all the words and only save that that contains https://, or any link stuff

cold sonnet
#

what's that

#

who's that

slate swan
#

Lmao, dont be ru

#

Rude*

cold sonnet
#

WHAT

slate swan
#

Regex our beloved

#

Lmao

sage otter
#

Dia how are you a programmer and you don’t know what regex is.

cold sonnet
#

idk

#

I'm a meh

slate swan
cold sonnet
#

it's a he

slate swan
#

what's regex

cold sonnet
#

well, I'm gonna google it

slate swan
#

How do I spell it 😔

sage otter
#

He learned d.py before actually learning python. So you know. It do tend to be that way.

cold sonnet
#

yes, I did

slate swan
#

Welp

sage otter
#

regex is a built in

slate swan
#

I had to install it welp

cold sonnet
sage otter
#

Idk then. It’s part of pythons standard package library.

slate swan
cold sonnet
#

I didn't even know what it is, yet I can do what I want in programming anyways

cold sonnet
#

my ways might suck

#

but they work vibing

slate swan
#

Lol its fine, your convenience

cold sonnet
#

and I know most about dpy so that's why I'm here

slate swan
#

hello gentlemen

cold sonnet
#

hi

slate swan
#

i'd have a question,

i want my bot to send a message to a specific channel where the user used that command.
I'm using / commands and the discord-py-slash-command library, and it's a kick command.

async def kick(ctx:SlashContext, user, reason:str = "None"):
    await user.kick()
    await user.send(f"Kicked from {ctx.guild.name} for {reason}")
    kicked = user.mention
    embed = discord.Embed(title = "Kicked a user", description = f"Kicked {kicked} for reason: {reason}")
    await ctx.send(embed)
    print(f"{user} used: kick")

this should kick the user (which it does) and then send a message in the chat where the command was used (which it does NOT)

#

perhaps i could associate the channel to a variable beforehand, but as i'm new to this i'm kinda lost

slate swan
cold sonnet
#

await ctx.send(embed=embed) is how it's used everywhere else

#

embed is not a positional argument indeed

slate swan
#

Oh yeah

#

And the kick method should contain a reason argument?

cold sonnet
#

no

sage otter
#

It’s optional.

slate swan
#

mhm

#

i applied a correction to the embed

#

i got why it's wrong

cold sonnet
#

print(f"{user} used: kick") is just kicking my eyes

slate swan
#

oof

slate swan
slate swan
slate swan
cold sonnet
#
    await user.send(f"Kicked from {ctx.guild.name} for {reason}")``` switch these two lines
#

they might cause an error

#

if you won't have a shared guild with this person anymore, you can't send a message to him

#

so send before kick

slate swan
#

Oh yeah, the user will be none

#

Or

#

oh yes that's my problem, and that fixes it, i don't know how i haven't thought about it before..

#

;-;

#

Welcome

slate swan
slate swan
#

it's for respect, especially here since i'm speaking with more knowledgeable people

#

i have one problem now

#

Mhm go ahead

#

in the terminal it says "<the name of the kicked user> used: kick"

#

it's supposed to say the name of the person issuing the command

#

here is how i changed the code:

#
async def kick(ctx:SlashContext, user, reason:str = "no reason nerd XD"):
    await user.send(f"Kicked from {ctx.guild.name} for {reason}")
    await user.kick()
    kicked = user.mention
    embed = discord.Embed(title = "Kicked a user", description = f"Kicked {kicked} for reason: {reason}")
    await ctx.send(embed = embed)
    print(f"{user} used: kick")
#

how can i address the user using the command instead?

cold sonnet
#

print(f"{ctx.author} used: kick")

slate swan
#

author

cold sonnet
#

yes

slate swan
#

thank you, i will have to remember these things

#

could you tell me the specific meaning of ctx?

cold sonnet
#

!d discord.ext.commands.Context

unkempt canyonBOT
#
class discord.ext.commands.Context(*, message, bot, view, args=..., kwargs=..., prefix=None, command=None, invoked_with=None, invoked_parents=..., invoked_subcommand=None, ...)```
Represents the context in which a command is being invoked under.

This class contains a lot of meta data to help you understand more about the invocation context. This class is not created manually and is instead passed around to commands as the first parameter.

This class implements the [`Messageable`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable "discord.abc.Messageable") ABC.
cold sonnet
#

docs 😄

slate swan
#

ooo i should have checked the docks 🤦‍♂️

#

thanks again, sorry for bothering for such simple things but i am still learning

cold sonnet
#

you're welcome

upbeat dirge
#

!d discord

unkempt canyonBOT
#

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.

upbeat dirge
#

Just curious in NodeJs there was a .on - when the bot was running does such a command exist with disnake?

kindred epoch
#

how do i get all the cog names?

upbeat dirge
#

@bot.event
async def on_ready

#

!d help

unkempt canyonBOT
#

help([object])```
Invoke the built-in help system. (This function is intended for interactive use.) If no argument is given, the interactive help system starts on the interpreter console. If the argument is a string, then the string is looked up as the name of a module, function, class, method, keyword, or documentation topic, and a help page is printed on the console. If the argument is any other kind of object, a help page on the object is generated.

Note that if a slash(/) appears in the parameter list of a function when invoking [`help()`](https://docs.python.org/3/library/functions.html#help "help"), it means that the parameters prior to the slash are positional-only. For more info, see [the FAQ entry on positional-only parameters](https://docs.python.org/3/faq/programming.html#faq-positional-only-arguments).

This function is added to the built-in namespace by the [`site`](https://docs.python.org/3/library/site.html#module-site "site: Module responsible for site-specific configuration.") module.
tough bobcat
#

!d discord.Message

unkempt canyonBOT
#

class discord.Message```
Represents a message from Discord.

x == y Checks if two messages are equal.

x != y Checks if two messages are not equal.

hash(x) Returns the message’s hash.
worn moss
upbeat dirge
#

!pypi disnake

unkempt canyonBOT
upbeat dirge
#

I am new but this is what someone recommend so I am going to use it.

unkempt canyonBOT
#

Hey @tough bobcat!

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

tough bobcat
#

argh

#

I have the

@bot.event
async def on_command_error(ctx, error):

set to dm me when an error is raised, but i am getting the attatched error logged to the console instead of going into the event function
https://paste.pythondiscord.com/erenijoqov.sql

slate swan
#

can you invoke a command within on_message event?

#

invoke is only based around context but how can i gain context within on_message

#

nvm

sage otter
#

I was gonna say
Bot.get_context(Message) exists.

slate swan
#

you can use ctx.author

tough bobcat
#

no i mean it works for normal errors like just doing

@bot.command(name='div0')
async def _div0(ctx):
    # type: (commands.Context) -> None
    1/0

but for this other error it just doesnt work

slim ibex
#

it’s -> None:

tough bobcat
#

what

#

im saying that this works fine

pliant gulch
#

Any reason why you do the type in a command rather than the actual signature itself, E.g ```py
async def _div0(ctx: commands.Context) -> None: ...

#

Backwards compatibility I assume?

#

Also your error you sent in the hastebin has something to do with your network configurations? Or the network security configurations either or not sure

cloud dawn
#

!d disnake.abc.Messageable.send

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

Sends a message to the destination with the content given.

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

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

To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://docs.disnake.dev/en/latest/api.html#disnake.Embed "disnake.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`Embed`](https://docs.disnake.dev/en/latest/api.html#disnake.Embed "disnake.Embed") objects. **Specifying both parameters will lead to an exception**.
upbeat dirge
cloud dawn
#

Just channel/guild.send

upbeat dirge
#

So - Discord.JS is where I am coming from - to define a specific guild by ID you would do something like

#
        global.guild = await discordClient.guilds.fetch("834851020524748840", true, true);
``` Do you know if there is a python equivalent - I know how to set it as a global | just I don't know the specifics for getting it to set the guildID.
full lily
#

there's also a fetch equivalent

upbeat dirge
#

Gotcha - Did you just find this in the documentation?

cloud dawn
unkempt canyonBOT
#

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

Tries to get the user from the cache. If fails, it tries to fetch the user from the API.
full lily
upbeat dirge
#

Yeah - I don't want the user - ultimately I want to be able to send a message to a specific channel

#

Thx. Bones.

full lily
#

my understanding is that fetch would send an api request to get the id, and get would look for it in the cache. In what cases is each applicable?

#

It says here that For general usage, consider get_guild(), though I would have thought it'd be the opposite

#

When would the id not be in the cache?

vapid anchor
#

Well that's more because of the design patterns of discord.py

#

Hikari (a much better python discord lib) can work without a cache so fetching is recommended there

upbeat dirge
#

Okay - clearly this is going way over my head - if I want to message a specific channel in a guild - how would I go about doing that - in Python?

vapid anchor
#

You don't need the guild to send a message

slim ibex
#

^

vapid anchor
#

The API just needs the channel id

upbeat dirge
#

Oh - really. Thats easier.

vapid anchor
#

hikari.RESTClient.create_message(channel_id, "content") if you're using a good library

#

Otherwise you gotta get a partial messagable or fetch the channel with dpy

slim ibex
#

lmao

#

“If you’re using a good library”

vapid anchor
#
channel = bot.get_partial_messageable(channel_id)
await channel.send("content")
slim ibex
#

all you need is ctx.channel

vapid anchor
slim ibex
#

yeah it is but some dpy forks are great too

vapid anchor
vapid anchor
slim ibex
#

👀

#

rly?

vapid anchor
#

Yeah

slim ibex
#

nice

slim ibex
#

I don’t actually use disnake, I use nextcord but I have heard disnake is great

full lily
#

in dpy you would need the channel object iirc

slim ibex
#

but I found this new discord api wrapper. It isn’t a fork of dpy and has stuff like middleware (you can customize it)

#

!pypi pincer

vapid anchor
#

dpy kinda sucks with this though 😔

unkempt canyonBOT
upbeat dirge
#

I was using - disnake | all I need is to be able to message to specific channels and do / cmd's

vapid anchor
slim ibex
#

Pincer is still in alpha and planning phase

vapid anchor
#

use hikari mate

slim ibex
#

I’ll check it out

#

mainly got my eyes on pincer rn doh

#

but it’s good to know multiple libs

vapid anchor
full lily
#

where are you getting a partial massageable from?

vapid anchor
vapid anchor
full lily
#

where from

vapid anchor
#

Build it with a bot method

slim ibex
#

but def won’t make a production bot with it yet

pliant gulch
unkempt canyonBOT
#

get_partial_message(message_id, /)```
Creates a [`PartialMessage`](https://discordpy.readthedocs.io/en/master/api.html#discord.PartialMessage "discord.PartialMessage") from the message ID.

This is useful if you want to work with a message and only have its ID without doing an unnecessary API call.

New in version 1.6.
vapid anchor
#

Wait

#

Yeah nvm then

#

Damn this server needs some slash commands god damn

#

It's not a partial message tho

full lily
#

what's the diff between this and get_channel

upbeat dirge
#

How is partial messageable able to send a message when it calls for a an id of a message

vapid anchor
#

get_channel uses the cache to get full channel data

#

get_partial_messageable creates a dummy object with just the id

#

Both can be used to send messages

full lily
pliant gulch
# vapid anchor Damn this server needs some slash commands god damn

How so? Slash commands are very under powered compared to regular commands... If this server switched to slash commands for an example one command such as eval would be completely eradicated. This bot is also not gonna get verified as It's only for this guild, no point

vapid anchor
vapid anchor
#

And yeah stuff like eval will probs have to stay as a prefix command for now, that's unavoidable

pliant gulch
#

Unless discord adds multiline support which a lot of us have been asking for. I doubt they would deliver though

vapid anchor
#

Didn't we already get a preview for it

#

And if multiline options don't come first we'll at least have modals

pliant gulch
#

The text input components?

vapid anchor
#

Yup

#

Though eval still seems better as a prefix command even for its more niche features like rerunning code on message edit n stuff

upbeat dirge
#
global channelBeta1 ; await bot.get_partial_messageable("883737072454750269")
    channelBeta1.send()``` - Pretend the second line is in another file - this should work right? | then I can just follow the (https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send)
pliant gulch
full lily
#

don't forget to await .send()

pliant gulch
#

One of the main reasons from discord at least is adding slash commands would make it easier for developers

#

When in-fact slash commands have quite a layer of complexity behind them, depending on the user of the API.

#

Although API wrappers can just make simple builders for said commands the implementation is humongous

full lily
#

I don't understand the partial_messageable approach. I would use get or fetch channel with your channel id

vapid anchor
#

Honestly I'm just glad there's some standardization now

pliant gulch
#

Not well designed for python styled libraries, clearly aimed for javascript

upbeat dirge
vapid anchor
full lily
pliant gulch
#

Errr, not designing anymore just rewriting my previous almost completed one

vapid anchor
#

A notable example here is the fact you are for some reason encouraged to fetch a full channel object when all you need is the id to make a request for sending a message

vapid anchor
pliant gulch
#

discord.py also pretty much has outdated code, I have yet to see a lot of refactors

vapid anchor
#

Yup definitely

pliant gulch
#

The get_channel is O(n)

#

😔

full lily
#

I'll have a look at this hikari later

vapid anchor
#

So much better man

pliant gulch
#

My old wrapper was basically from scratch wrapper with discord.py semantics

#

But now my new rewrite is different from discord.py semantics

#

Going good so far I'd say

vapid anchor
#

while hikari has less abstraction it also has a lot of less questionable code. discord.py is already starting to fall apart with the new features

#

for example banners not being present on user objects in cache

#

That one's a whole lotta fun to debug I bet

pliant gulch
#

Wouldn't be to hard to patch it yourself

#

GUILD_CREATE sends out the member datas'

vapid anchor
#

dpy is fun because the ridiculous amount of try/excepts all around the project ensure that everything works no matter what

#

Even when it means it won't work as intended

#

The horrors one has to go through to maintain a fork

#

Hikari's a project I look up to and I actively try to steer disnake in such a way so we can become more like hikari

pliant gulch
#

Mmmm I've never understand maintaining a fork

vapid anchor
#

Honestly, some things are just meant to die

pliant gulch
#

I'd much rather create from scratch. I'd be more familiarised with the codebase, as I wrote it myself

#

Along with code chocies

vapid anchor
#

I learned a lot about signature parsing while working at disnake though

#

Wrote shitty code for disnake so I could later write pretty code for hikari

pliant gulch
#

Signature parsing? Is this for commands

vapid anchor
#

yeah, disnake's slash commands

#

I was the one who designed them

#

I tried to make it resemble the familiar dpy commands while following fastapi semantics

pliant gulch
#

Compare and contrast with my old slash commands parser? I need more inspiration as my rewrite wrapper will be fully native, thus not using commands-extension

#

Oh actually nevermind, I'll just rewrite the slash command parser from scratch

vapid anchor
slate swan
#

I need help

@bot.command()
@commands.has_permissions(kick_members=True)
async def kick(ctx, member: discord.Member, *, reason=None):
    await member.kick(reason=reason)
    embed = discord.Embed(color=color, description=f'{member} was kicked')
    await ctx.send(embed=embed)

@kick.error
async def kick_error(ctx, error, member: discord.Member):
  if isinstance(error, commands.MissingPermissions):
    embed = discord.Embed(color=color, description=f'{member} You do not have the permission to use this command')
    await ctx.send(embed=embed)```

The kick error message is not sending
pliant gulch
#

mmmm I def do not like the identical implementation every fork as right now

slate swan
#

someone pls help me 😭

vapid anchor
#

Well it's the modern way

#

The main distinction are the minor features rn

slate swan
pliant gulch
#

The modern way is a poorly designed way that only allows for more space to be taken up in my opinion

#

If this is the "modern" way, the forks def need a rework

#

Poorly designed that is depending on the fork itself

#

I'm mostly talking about the decorators, etc

#

Its quite obvious an attempt to stick with the old commands format

#

but that won't be scalable for larger commands

vapid anchor
#
  • pycord - places metadata into annotations making it impossible to use mypy (LOVE IT!)

  • nextcord - little features, all metadata in defaults

  • disnake - everything discerned from a valid annotation, descriptions taken from docstrings

  • edpy (draft) - classes with an options attribute for raw option data and a callback method

  • d-interactions - option parameter in decorators for raw option data

  • hikari-tanjun - decorator chains

  • hikari-tanchi - signature parsing same as disnake (cause I did both lmao)

#

There's diversity alright

pliant gulch
#

The maintainer of pyright is quite fast and professional

#

Mypy doesn't even support Self in annotations

vapid anchor
#

Mypy has a strict flag too idk what you're talking about

pliant gulch
#

I never said it didnt...

#

I just said pyright has a strict flag

vapid anchor
pliant gulch
#

Was it for a reason or just randomly?

vapid anchor
#

Idk

#

Lemme send it

#

Issue is fixed when using a venv btw

#

Because the site package wouldn't be there

#

But that's such an annoying detail

pliant gulch
#

But where you not using a venv before?

vapid anchor
#

I used to not use a venv

#

I have been forced to because of this bug though

#

I kinda never bothered to tbh

pliant gulch
#

At least it's a good practice to use a venv when developing

vapid anchor
#

Yeah it is but I never had an actual need for it

#

Didn't have any conflicting dependencies because I kept everything up-to-date

pliant gulch
#

Quite a lot of stuff

#

I could not develop well without my poetry environment

#

Also includes building packages in itself, no need for all that building manually

vapid anchor
#

Python version control is so damn messy man, there needs to be some actual standard instead of a lot of backwards compatible nonsense

pliant gulch
vapid anchor
#

Huh

#

Alright then

#

Already using that so that's cool

vapid anchor
#

Gotta switch to 3.10 at some point

unkempt canyonBOT
#

pyproject.toml lines 13 to 16

[tool.poetry.dependencies]
python = "^3.9"
aiohttp = "^3.8.1"
typing-extensions = "^4.0.1"```
pliant gulch
#

I accidentally switched to 3.10 😔 It automatically updated when I did pacman -Syu and I wasn't prepared for it

vapid anchor
#

Worst thing about pinning dependencies is that I gotta remember to update them 💀

pliant gulch
#

Github dependabot

vapid anchor
#

Or setup some GitHub bot

#

Yeah that annoying little fucker

pliant gulch
#

The PRs are quite floody though

vapid anchor
#

Yeah I've unfortunately noticed

icy shell
slate swan
#

so im in 3.9.9

zealous dagger
#
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "main.py", line 172, in help
    await ctx.send("Testing selects for help command!",embed=embed_hm,view=view)
TypeError: send() got an unexpected keyword argument 'view'

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

Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1353, in invoke
    await super().invoke(ctx)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: send() got an unexpected keyword argument 'view'```
#

@slate swan

#

I was

#

It was working before

zealous dagger
#

1.7.3

slate swan
#

!d discord.ui.View

unkempt canyonBOT
#

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

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

New in version 2.0.
slate swan
#

New in version 2.0.

zealous dagger
#

Ok

heavy radish
#

What are these callef?

zealous dagger
#

buttons

slate swan
#

!d discord.ui.Button

unkempt canyonBOT
#

class discord.ui.Button(*, style=<ButtonStyle.secondary: 2>, label=None, disabled=False, custom_id=None, url=None, emoji=None, row=None)```
Represents a UI button.

New in version 2.0.
slate swan
#

its a class @zealous dagger

heavy radish
#

Ok

#

Thank You

slate swan
#

whats your lib?

heavy radish
#

I believe

slate swan
#

youll need 2.0

heavy radish
slate swan
#

Use a fork , or clone the master branch

#

the repo has info

#

You'd need git for that

heavy radish
#

Alright

slate swan
#

yeah i recommend a fork tbh

heavy radish
#

Hmm

slate swan
#

forks have slash commands

heavy radish
#

Let me open the link

prisma spoke
slate swan
prisma spoke
#

disnake prolly does

slate swan
#

yes , but forks like Disnake and nextcord have slash commands and are recommended

#

your friends fork doesnt count lol

heavy radish
#

It's looks the same

heavy radish
#

The BOT example

slate swan
prisma spoke
slate swan
#

Disnake's server?

prisma spoke
#

ooo

slim ibex
#

nextcord > disnake

heavy radish
#

What do I do here?

slate swan
#

cant compare

slim ibex
#

not replit ohb no

slate swan
#

For me , it's hikari>forks

slim ibex
#

true

prisma spoke
#

ty

slim ibex
#

or pincer

#

!pypi pincer

unkempt canyonBOT
prisma spoke
slate swan
#

i want to try hikari ngl

slate swan
prisma spoke
slate swan
slim ibex
#

imma try hikari also, but pincer is promising, wathc out for it

prisma spoke
slate swan
#

well ,I tried hikari and it's really better in speed and cache features than dpy

slate swan
prisma spoke
edgy finch
#

hi

#

hi

slate swan
#

Hi

#

hi

edgy finch
#

hi

prisma spoke
#

ok

edgy finch
#

!resources

slate swan
#

for personal use, use this channel^

edgy finch
#

are u all getting the resources option

#

?

#

im not getting

slate swan
#

wdym

#

!d discord.TextChannel.is_news

unkempt canyonBOT
#

is_news()```
[`bool`](https://docs.python.org/3/library/functions.html#bool "(in Python v3.9)"): Checks if the channel is a news channel.
quick gust
#

yep

red sundial
#

you have that option if you make a community server

#

not sure

#

check the docs

spring flax
#

The bottom one here

slate swan
#

they can

maiden fable
#

!d discord.Guild.edit

unkempt canyonBOT
#
await edit(*, reason=..., name=..., description=..., icon=..., banner=..., splash=..., discovery_splash=..., community=..., region=..., afk_channel=..., owner=..., ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the guild.

You must have the [`manage_guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_guild "discord.Permissions.manage_guild") permission to edit the guild.

Changed in version 1.4: The rules\_channel and public\_updates\_channel keyword-only parameters were added.

Changed in version 2.0: The discovery\_splash and community keyword-only parameters were added.

Changed in version 2.0: The newly updated guild is returned.
maiden fable
#

community kwarg

slate swan
#

create_text_channel

maiden fable
#

!d discord.Guild.create_text_channel

unkempt canyonBOT
#

await create_text_channel(name, *, reason=None, category=None, position=..., topic=..., slowmode_delay=..., nsfw=..., overwrites=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Creates a [`TextChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.TextChannel "discord.TextChannel") for the guild.

Note that you need the [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to create the channel.

The `overwrites` parameter can be used to create a ‘secret’ channel upon creation. This parameter expects a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") of overwrites with the target (either a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")) as the key and a [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/master/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite") as the value.

Note

Creating a channel of a specified position will not update the position of other channels to follow suit. A follow-up call to [`edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.TextChannel.edit "discord.TextChannel.edit") will be required to update the position of the channel in the channel list...
maiden fable
#

Where's the news kwarg

slate swan
#

02bored using channel.edit py edit(type=ChannelType.news) should work too right?

maiden fable
#

Weird... Imagine making two API Calls 1_egg_rip

slate swan
#
ch = await Guild.create_text_channel(name='name')
await ch.edit(type=ChannelType.news)
#

it works , im not sure if there's any other way of doing that with a single request

maiden fable
slate swan
#

lemme try with an eval using create_text_channel

maiden fable
#

Thanks

slate swan
#
await _ctx.guild.create_text_channel(name='test' , type=disnake.ChannelType.news)

TypeError: Guild.create_text_channel() got an unexpected keyword argument 'type'

unkempt canyonBOT
#

discord/guild.py line 1095

name, overwrites=overwrites, channel_type=ChannelType.text, category=category, reason=reason, **options```
maiden fable
#

So it manually sets the channel type

#

Weirddd

slate swan
#

see the message below that codeblock

slate swan
#

yes , it works

maiden fable
#

Also why set it to None/MISSING first in the function definition and then use if statements??? I don't know why devs don't set it directly

#

Sure

slate swan
#

yep , it needs to be TextChannel obj

maiden fable
#

iirc it can take a snowflake too

#

I don't really know

slate swan
#

maybe , it just needs to id property of the object

#

its a callable

#

is_news()

maiden fable
#

Lol

elder pike
#

Can't you just select the channel to edit by ID?

slate swan
#

nope

boreal ravine
#

you need its object in dpy

#

you cant just edit an integer, that makes no sense

slate swan
#

TextChannel "object" has the edit method , and "int" wont have it

#

*method

elder pike
#

fair enough thanks

maiden fable
#

You know... When I was making the private wrapper for revolt, I was thinking... Why not associate every method with the bot or the ctx object... Like bot.send(channel-id, *args, **kwargs and so on haha... You know, associate everything with the IDs itself. No need for the objects lol

slate swan
#

hikari does something similar :p

maiden fable
#

Hahaha

slate swan
#
await BotApp/GatewayBot.rest.create_message(channel_id, content, ...)```
maiden fable
#

I never looked into that tbh...

boreal ravine
maiden fable
#

I just think getting and fetching objects is just useless and wastes resources (though negligible)

pliant gulch
visual island
pliant gulch
#

Not really

visual island
#

and that's to make the wrapper cleaner

pliant gulch
#

The objects is just library abstraction

#

You can make the request entirely with IDs and payloads, that being the case of discord.py

pliant gulch
maiden fable
#

Hmm well I did make them afterwards ngl

pliant gulch
#

Unless you inject the object into a caching layer of the bot

slate swan
#

what if you provided a wrong id , just a request failure 02bored by get/fetch u actually know that the object with that id exists or not

maiden fable
#

Hmm

pliant gulch
#

Thus the opposite means an ID exists

#

Unless that was what you meant

#

😔

slate swan
pliant gulch
#

Sure, but that requests bucket will fill up pretty quickly depending on the X-Ratelimit-reset-after

#

Anyways most of the objects in discord.py are from the gateway

#

As you receive most things through it such as members from GUILD_CREATE payloads

slate swan
#

rules_channel=None

visual island
slate swan
#

a community guild without rules channel?/

pliant gulch
#

Nothing here on objects is required

#

It's all library abstraction

visual island
pliant gulch
#

I'm not endorsing it

#

I'm saying it isn't required

#

Like my original statement

slate swan
#

whats that

#

what library are you using

#

and its an event

#

!d disnake.Guild.create_scheduled_event

unkempt canyonBOT
#

await create_scheduled_event(*, name, scheduled_start_time, entity_type, privacy_level=..., channel_id=..., entity_metadata=..., scheduled_end_time=..., description=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Creates a [`GuildScheduledEvent`](https://docs.disnake.dev/en/latest/api.html#disnake.GuildScheduledEvent "disnake.GuildScheduledEvent").

New in version 2.3.
slate swan
#

well this is an event..

quick gust
#

events aren't channels

quick gust
slate swan
#

Guild.edit(public_updates_channel=)

karmic lintel
#

if user.reaction == randomchoiceofbot:
print('')
else:
print('')
nothing can be like this?

spring verge
#

Anyone here used cyberduck?

karmic lintel
spring verge
karmic lintel
#

\👍

#

,helper

slate swan
#

mmh?

#

Selfbot? KryptonBlanket

jaunty bear
#

!resources

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
#

Guys, I have made a private leaderboards bot for my server which fetch the leaderboards from a url and updates it every 4 seconds (asyncio.sleep) so now I want to make a public version of the bot. but the problem is that I want it to update leaderboards in every server, it is in, every 10 seconds. but if it is in many servers then first it update leaderboards in every server and then sleeps for 10 seconds, but it will slow it down and will then take more than 10 seconds, so is there a way? that it fetch leaderboards every 10 seconds but update in servers within the same 10 seconds e.g.
it fetch leaderboards and then sleeps for 10 seconds before sending another request but while the bot is in sleep mode, it update the other servers and when the 10 seconds complete, it will send another request and then sleeps again

edgy finch
#

k

slate swan
maiden fable
#

Second, just iterate through bot.guilds and get the leaderboard for every guild

slate swan
#

but the fetch is ok, but when the bot send message to all guilds, it become a bit slow and then after when I make it sleep for 10 seconds, its been more than 10 seconds(10 seconds sleep + time taken when sending to other guilds)

maiden fable
#

Could be it's getting ratelimited? In how many guilds is it sending?

visual island
slate swan
#

after all edited it will then sleep for 10 secs

#

then it will edit the leaderboards of 1st server after all this time (10 secs + time taken in other servers)

pine crown
#
import disnake
from disnake.ext import commands
import json
import os

client = commands.Bot(command_prefix='-', intents=intents, case_insenstivive = True)


client.warnings = {
  guild_id : {}
}

why does it say guild_id not defined?

visual island
slate swan
#

kk

visual island
#

But if you're talking about how to edit/send it simultaniously, you cant

#

cause ratelimit stuff

#

for example, you have 1000 guilds, it will take 1000/50 (20 seconds) to edit everything

slate swan
#

hello is there a way like in discord.py to see the commands u have and add it to help command …

#

bc i don’t wanna add all my commands manually i have many commands

visual island
#

!d discord.ext.commands.Bot.commands

unkempt canyonBOT
#

property commands: Set[discord.ext.commands.core.Command[discord.ext.commands.core.CogT, Any, Any]]```
A unique set of commands without aliases that are registered.
visual island
#

use this

slate swan
#

kk

#

ok

#

uhh i didn’t find anything that can help me @visual island

#

oh get_command?

#

or idk

visual island
#

@slate swan what do you use for the help command? a normal @bot.command() or MinimalHelpCommand or ?

boreal ravine
maiden fable
slate swan
#

Normal

#

@bot.command()

#

Oops

karmic lintel
#

how to fetch users reaction?

#

like fetch_message is there anything like fetch_reaction?

maiden fable
#

!d discord.Message.reactions @karmic lintel

unkempt canyonBOT
maiden fable
#

!d discord.Reaction is what it returns

unkempt canyonBOT
#

class discord.Reaction```
Represents a reaction to a message.

Depending on the way this object was created, some of the attributes can have a value of `None`.

x == y Checks if two reactions are equal. This works by checking if the emoji is the same. So two messages with the same reaction will be considered “equal”.

x != y Checks if two reactions are not equal.

hash(x) Returns the reaction’s hash.

str(x) Returns the string form of the reaction’s emoji.
slate swan
#

no messages for more than an hourwhyyyyy

vale wing
#

You broke inexistent no messages chain

spring verge
#

anyone uses mongo db here? is it good if a bot is in one server only?

quaint scaffold
#

No

#

MongoDB is for document data whereas just about everything you do with Discord is relational data

#

Use the appropriate tools

spring verge
#

I personally use postgreSQL for storing data like user ids etc but my client on fiverr wants me to use mongodb

slate swan
#

Why not just use Sqlite if it's for a single server

#

It serves the purpose well

spring verge
slate swan
quaint scaffold
#

Oh, if your client wants MongoDB, then you could recommend a SQL based db but if they still decline, use Mongo in that case. It still works, in fact, Invite Tracker used it until 6 months ago.

slate swan
#

Ah

#

they asked u to use mongo

spring verge
#

yes

#

I will try to negotiate with them again into using RDBMS

slate swan
#

Well , it's okay if you do that

spring verge
quaint scaffold
#

Absolutely

spring verge
#

yep its the best

shell wing
#

error

Ignoring exception in command invite:
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "/home/runner/LuminousAquaCopycat/selfroles.py", line 28, in invite
    await ctx.send(embed=link, components=components)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord_components/dpy_overrides.py", line 350, in send_override
    return await send(channel, *args, **kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord_components/dpy_overrides.py", line 275, in send
    components = _get_components_json(components)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord_components/utils.py", line 27, in _get_components_json
    return [row.to_dict() for row in lines] if lines else []
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord_components/utils.py", line 27, in <listcomp>
    return [row.to_dict() for row in lines] if lines else []
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord_components/component.py", line 484, in to_dict
    "components": [component.to_dict() for component in self.components],
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord_components/component.py", line 484, in <listcomp>
    "components": [component.to_dict() for component in self.components],
AttributeError: 'dict' object has no attribute 'to_dict'
#

whats the issue ??

vale wing
#

You already have a dict and you are trying to turn it into dict waitwhat

quaint scaffold
#

Read it again, it can't get more simple than what he said

shell wing
#

the same code is working on other bot of mine..

shadow wraith
#

yeah i dont see a dict either, use a fork for buttons then.

#

it seems like the error comes from where the package location is

quaint scaffold
#

You are creating the button the wrong way in the first place, have a look at that code, it's from the developer of discord.py

shell wing
#

i just copy pasted it

earnest wolf
#

someone help

#

this is not working for some reason

#
@bot.event
async def on_command_error(ctx, error):
  if isinstance(error, commands.CommandNotFound ):
    await ctx.reply("command not found nig")
#

@help-python

spring flax
#

channel.history doesn't have a check kwarg?

#

if not, how do I get the messages of a member in a channel to get it into a list?

potent spear
potent spear
spring flax
potent spear
spring flax
#

Put in a file

potent spear
# spring flax Put in a file

alright, you basically have to check the first example in the docs, it's doing what you want it to do, but instead of the count, you do your stuff

spring flax
#

ah okay

#

[message.content for message in ctx.channel.history(limt=100) if message.author == member]

#

i thought there was a check kwarg, though it could be for something else

potent spear
#

don't make it a one liner per se, you're only confusing yourself with it

spring flax
#

what's wrong?

potent spear
#

in the example on the docs, you'll see that it's an ASYNC loop

spring flax
#

[message.content for message in (await ctx.channel.history(limt=100).flatten()) if message.author == member] this?

potent spear
#

second note: try and see
third note: limit

spring flax
#

yeah i will try when on pc it should work

#

and its not confusing lol

potent spear
#

also, know that a txt isn't a db

#

a better way of "storing" history of a member can be done via

  1. directly in on_message
  2. in every iteration of a message, add it as a db row with the info you like (message_id, member_id, content,...)
spring flax
potent spear
#

then why are you storing it in a txt?

spring flax
#

To view them

potent spear
#

why don't you just store it as a local variable?

maiden fable
potent spear
#

nice

maiden fable
#

Rip I forgot the event name

#

!d discord.on_bulk_message_delete

unkempt canyonBOT
#

discord.on_bulk_message_delete(messages)```
Called when messages are bulk deleted. If none of the messages deleted are found in the internal message cache, then this event will not be called. If individual messages were not found in the internal message cache, this event will still be called, but the messages not found will not be included in the messages list. Messages might not be in cache if the message is too old or the client is participating in high traffic guilds.

If this occurs increase the [`max_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") parameter or use the [`on_raw_bulk_message_delete()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_bulk_message_delete "discord.on_raw_bulk_message_delete") event instead.

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

There