#discord-bots

1 messages · Page 730 of 1

pliant gulch
#

The same way you'd index a sequence but instead of an index you'd put the key between the two square brackets

slate swan
#

Why would it be needed

small igloo
slate swan
#

It's a key

#

You don't need json to read a dictionary

pliant gulch
#

If you don't even know the basics like accessing a dict via key you should probably go back and check out some articles on it

#

Skipping straight to a discord bot leads to these issues

slate swan
#

Indeed

small igloo
pliant gulch
slate swan
#

I mean , if you try to "learn python" data types are the very first article after print("hello world")

#

atleast how I did

light violet
#

@slate swan

small igloo
slate swan
light violet
#

@slate swan gm

slate swan
#

pithink Morning

polar ice
#

Hello is it possible to create a link on a embed to copy text when clicked, such as an IP address?

polar ice
#

example

cloud dawn
#

No this is something discord would need to implement then

slate swan
#

🏃‍♀️ there's already a copy ip button , use it ez

#

!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.
pliant gulch
#

Yea theres no way to put a link onto someones clipboard through the client

cloud dawn
polar ice
#

@slate swanNo clever ways around like to run a program C:\Program Files (x86)\Steam\Steam.exe -applaunch 513710"

#

wasnt sure thats all, just thought id check 🙂

pliant gulch
#

That would be an even bigger risk

cloud dawn
pliant gulch
#

And doesn't exists

#

Although at one point there was a bug on the client way way back, like 4 years ago where you could do remote execution through an embedded link

cobalt jacinth
#

how can i remote my discord bot from a server with code ?

cobalt jacinth
#

like i want to remove my discord bot from certain server

slate swan
unkempt canyonBOT
#

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

Leaves the guild.

Note

You cannot leave the guild that you own, you must delete it instead via [`delete()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.delete "discord.Guild.delete").
slate swan
#
"""
If person does not have Staff role: 
"""
#

How would we write this?

#
if not (message.author.role == &439875622626394122):
#

?

#

!d discord.ext.commands.has_role

unkempt canyonBOT
#

@discord.ext.commands.has_role(item)```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member invoking the command has the role specified via the name or ID specified.

If a string is specified, you must give the exact name of the role, including caps and spelling.

If an integer is specified, you must give the exact snowflake ID of the role.

If the message is invoked in a private message context then the check will return `False`.

This check raises one of two special exceptions, [`MissingRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") if the user is missing a role, or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") if it is used in a private message. Both inherit from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").

Changed in version 1.1: Raise [`MissingRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")
slate swan
#

got it thanks

slate swan
#
@commands.has_permissions(manage_messages=True)
#

This works

#

however, what about:

#
manager = discord.utils.get(guild.roles, name="Session Manager")
if not (message.author.has_permissions(manager=True)):
#

wait that says permissions, no way to do it for roles?

#

nvm im stupid 1 sec

#

It's a decorator

#
guild == client.get_guild(904489036582879262)
manager = discord.utils.get(guild.roles, name="Session Manager")
if not (message.author.has_role(manager)):
pliant gulch
#

Just check if manager the role, is inside of member.roles

#

member being the message's author

slate swan
pliant gulch
#

E.g 1 in [1, 2, 3]

slate swan
#

kk lmeme try

slate swan
pliant gulch
#

Because you did ==

slate swan
#

crap

pliant gulch
#

That's to compare the value

slate swan
#

Not getting any more erors but still not working

pliant gulch
#

Perhaps manager is None

#

Try printing it out

slate swan
#

lemme see

slate swan
#
@client.listen()
async def on_message(message):
    if message.channel.id == 912962953484066867:
        if not message.author.bot:
            guild = client.get_guild(904489036582879262)
            manager = discord.utils.get(guild.roles, name="Session Manager")
            if not manager in message.author.roles:
                if not (message.content.startswith('-session')):
                    error = 'https://tenor.com/view/error-computer-warning-gif-8680016'
                    dm = await message.author.create_dm()
                    await dm.send(error)
                    await dm.send('**__Hello! Please do not talk in the notification channel!__**')
                    await message.delete()
#

so its skipping over and deleting the message, and dming the message

#

dk why

pliant gulch
#

It's skipping over the if not (message.content.startswith('-session')):?

pliant gulch
#

It's skipping over the first one, with the manager role

slate swan
#

yes

#

If the message starts with -session its doign what its supposed to

pliant gulch
#

Did you mean to put the not in the if statment for manager?

slate swan
#

yes

#

so if the person doesnt have manager role, it'll continue over to the next if statement

#

@pliant gulch

slate swan
maiden fable
slate swan
maiden fable
#

Ah cool

slate swan
#

Does creating a dm manually make it slower tho?

maiden fable
#

No

slate swan
#

ahh perfect okay

#

its just an extra api request you dont actually need to make

#

Kk perfect

final iron
#

How would I get a members avatar if it was a default one

maiden fable
#

!d discord.Member.display_avatar

unkempt canyonBOT
#

property display_avatar: discord.asset.Asset```
Returns the member’s display avatar.

For regular members this is just their avatar, but if they have a guild specific avatar then that is returned instead.

New in version 2.0.
slate swan
#

@client.event
async def on_member_join(member):
channel1 = client.get_channel(YourChannelID)
if not member.avatar: # If there is no avatar
await member.ban(reason="No avatar!")
else:
await channel1.send("Avatar!")

final iron
#

So
avatar_ = discord.Member.avatar.url or discord.Member.display_avatar?

slate swan
#

just member.avatar seems to work

#

@client.event 
async def on_member_join(member):
    channel1 = client.get_channel(YourChannelID)
    if not member.avatar: # If there is no avatar
        await member.ban(reason="No avatar!")
    else:
        await channel1.send("Avatar!")

#

I found someone’s solution on the internet

final iron
#

It would work for that but in my use-case I'm displaying it

#

So I would need the url attribute

spring flax
#

how do you make buttons with disnake?

maiden fable
unkempt canyonBOT
#

disnake.ui.button(*, label=None, custom_id=None, disabled=False, style=<ButtonStyle.secondary: 2>, emoji=None, row=None)```
A decorator that attaches a button to a component.

The function being decorated should have three parameters, `self` representing the [`disnake.ui.View`](https://docs.disnake.dev/en/latest/api.html#disnake.ui.View "disnake.ui.View"), the [`disnake.ui.Button`](https://docs.disnake.dev/en/latest/api.html#disnake.ui.Button "disnake.ui.Button") being pressed and the [`disnake.MessageInteraction`](https://docs.disnake.dev/en/latest/api.html#disnake.MessageInteraction "disnake.MessageInteraction") you receive.

Note

Buttons with a URL cannot be created with this function. Consider creating a [`Button`](https://docs.disnake.dev/en/latest/api.html#disnake.ui.Button "disnake.ui.Button") manually instead. This is because buttons with a URL do not have a callback associated with them since Discord does not do any processing with it.
maiden fable
#

!d disnake.ui.View

unkempt canyonBOT
#

class disnake.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.
maiden fable
#

!d discord.Asset.url

unkempt canyonBOT
spring flax
#

yeah okay thanks

maiden fable
#

@final iron just do member.display_avatar.url

#

Where member is an instance of discord.Member

#

U can get it from ctx.author or the member arg in the join and leave event

final iron
#

Who said I'm using a join or leave event

final iron
maiden fable
#

It will

#

It will show the avatar u can see in the specific server. It can be the default avatar as well as the guild specific avatar, as mentioned in the docs

spring flax
#

would there be cache issues with role.members?

maiden fable
#

Why do u think there will be?

boreal ravine
#

it already returns the asset URL

maiden fable
boreal ravine
#

the str dunder returns the url

maiden fable
#

Yea...

vast gale
#

@lament ridge what do you use to work with slash commands

spring flax
#

class myButton(disnake.ui.view):
    def __init__(self):
        super().__init__()```
this raises this error
#

it's for the first line, class myButton(disnake.ui.view):

#

@maiden fable could you help please

quick gust
#

isn't it disnake.ui.View?

slate swan
quick gust
#

@spring flax

slate swan
#

since its a class

quick gust
#

yeah

#

your view is uncapitalised

#

it should be View not view

slate swan
light violet
#

@slate swan

#

!d on_member_role_update

slate swan
#

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

slate swan
#

they are docs from discord so...

#

bruh

#

!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.
light violet
slate swan
#

@slate swan 🤯 nice delete

light violet
# slate swan <@456226577798135808> 🤯 nice delete
@client.event
async def on_guild_member_update(before,after):
    
      guild = before.guild
      logs = await guild.audit_logs(limit=1, action=discord.AuditLogAction.member_role_update).flatten()
      logs = logs[0]
      reason = "Updated Member As Non-Whitelisted User"
       
      await after.remove_roles(after.roles)
        
      await logs.user.ban(reason=f"R-Dynamic Protection System | {reason}")```what is the prob in  it
slate swan
#

!d discord.on_member_update

unkempt canyonBOT
#

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

This is called when one or more of the following things change:

• nickname

• roles

• pending...
slate swan
#

!d discord.on_member_update , lets not spam

#

slow

slate swan
light violet
#

hmm

slate swan
light violet
#

on member update

slate swan
honest shoal
#

!d discord.on_member_update

unkempt canyonBOT
#

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

This is called when one or more of the following things change:

• nickname

• roles

• pending...
light violet
# slate swan lets blame robo danny

@client.event
async def on_member_update(before,after):

  guild = before.guild
  logs = await guild.audit_logs(limit=1, action=discord.AuditLogAction.member_role_update).flatten()
  logs = logs[0]
  reason = "Updated Member As Non-Whitelisted User"
   
  await after.remove_roles(after.roles)
    
  await logs.user.ban(reason=f"R-Dynamic Protection System | {reason}")

this?

slate swan
#

who deleted my msg👀

#

am i paranoid or is their a mod here👀

unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

slate swan
#

Why do you remove the user roles and one line later ban the user?

#

Just ban the user.

honest shoal
#

strange

light violet
#
@client.event
async def on_member_update(before,after):
    
      guild = before.guild
      logs = await guild.audit_logs(limit=1, action=discord.AuditLogAction.member_role_update).flatten()
      logs = logs[0]
      reason = "Updated Member As Non-Whitelisted User"
       
      await after.remove_roles(after.roles)
        
      await logs.user.ban(reason=f"R-Dynamic Protection System | {reason}")```
#

what is the problem in it

slate swan
#

You remove the roles and ban the user.

#

Banning the user is the only thing needed.

#

No need to remove roles.

light violet
#

provide them admin then

slate swan
#

Very confusing "protection" system, anyways.

#

Just compare the length of before.roles and after.roles, then you know if a role has been added/removed.

light violet
#

almost complete

#

btw it didnt work

#

bro what to change

#

oohk now i undertsand

light violet
# slate swan Just compare the length of `before.roles` and `after.roles`, then you know if a ...
@client.event
async def on_member_update(before,after):
    
      guild = before.guild
      logs = await after.audit_logs(limit=1, action=discord.AuditLogAction.member_role_update).flatten()
      logs = logs[0]
      reason = "Updated Member Role As Non-Whitelisted User"
      
      if before.roles != after.roles:

        await after.remove_roles(after.roles)
        
        await logs.user.ban(reason=f"R-Dynamic Protection System | {reason}")```now?
light violet
# slate swan Very confusing "protection" system, anyways.

Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "main.py", line 280, in on_member_update
await after.remove_roles(after.roles)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/member.py", line 822, in remove_roles
await req(guild_id, user_id, role.id, reason=reason)
AttributeError: 'list' object has no attribute 'id'
Ignoring exception in on_member_update
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "main.py", line 280, in on_member_update
await after.remove_roles(after.roles)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/member.py", line 822, in remove_roles
await req(guild_id, user_id, role.id, reason=reason)
AttributeError: 'list' object has no attribute 'id'
172.18.0.1 - - [06/Jan/2022 05:32:59] "HEAD / HTTP/1.1" 200 -
this error is coming

hoary gust
#

guys how do i get the unix timestamp using disnake for user account created_at property

slate swan
#

Add .timestamp()

light violet
#

what to do

hoary gust
#

?

slate swan
#

Or .strftime('%s')

#

Yes

light violet
#

@slate swanwhy ignoring me

slate swan
#

Because you ping me 100 times for nothing.

light violet
slate swan
#

Again a ping, and then you wonder why I don't help you..

light violet
#

couldnt understand

#

wott

#

btw i am asking something bro not pinging unessecarily

slate swan
slate swan
#

already told ya

slate swan
#

you cannot remove roles like that
itreate thru after.roles and remove them one by one

#

^

#

if you dont know how to iterate with a list , learn some more python

light violet
#

idk that thing

slate swan
#

It's a simple for loop

#

!e
list = [1, 2, 3]
for element in list:
print(element)

unkempt canyonBOT
#

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

001 | 1
002 | 2
003 | 3
slate swan
light violet
#

hm

hoary gust
#

@slate swan not working

slate swan
#

One of the first things you learn if you learn Python correctly.

slate swan
#

I sadly can't see your screen like you see yours.

hoary gust
#

@slate swan

                
    @commands.slash_command(name='user', description='command to get info of a server', options=[Option(name='member', description='mention the member whose info you want', required=False, type=OptionType.user)])
    async def user(inter, member= None): 
        if member is None: member = inter.user
        em= disnake.Embed(description=f'Account Created : <t:{member.created_at.timestamp()}:d>\nAccount ID : {member.id}')
        em.set_author(name=f"{member.name}#{member.discriminator}")
        return await inter.response.send_message(embed=em)

light violet
slate swan
slate swan
hoary gust
#

its not being that

#

but why

honest shoal
light violet
#

i told that too

honest shoal
#

I can quote the message

light violet
#

i shifted to py cuz i heard it is better

honest shoal
#

nvm, also I don't get any sense of banning members on role updates

hoary gust
slate swan
hoary gust
#

@slate swan now its like this

light violet
#

js

hoary gust
#

i found some mistakes and fixed it

slate swan
hoary gust
honest shoal
#

bruh

light violet
hoary gust
#

python is the most slow language bruh

honest shoal
#

^

light violet
slate swan
#

int(member.created....)

hoary gust
light violet
#

bro it is faster than js , js literally hangs a lot resisting a antinuke py can even stop threads in seconds

honest shoal
#

I want to ask a question, how much are you experienced with python @light violet

hoary gust
#

@slate swan oh thanks it worked now

#

lol

hoary gust
hoary gust
#

djs 13 is really a bit confusing tbh

light violet
hoary gust
#

like it is very different from djs 12

hoary gust
#

but node is faster

light violet
#

ya

slate swan
#

Based on same algorithms and they are testing speed.

hoary gust
#

as much as i know

light violet
#

i tried it my self

honest shoal
slate swan
#

Well, it is by facts way faster.

#

Sometimes the developer is the reason why the program is slow :p

slate swan
#

🏃‍♂️ javascript is faster than python in general

light violet
#

not in discord btw ;aw;

slate swan
#

it is

#

depends on many things , like : operations , resources , network latency

light violet
# slate swan it is

lmao btw actually i tries where py antinukes resist threaded nuke at 50 bans js literally hangs a lot and 1k bans are done without getting ban

#

i saw with my eyes

slate swan
#

the bot would have been coded in a not-too-good way

#

ive used both dpy and djs , js is faster

light violet
#

hmm ya

#

maybe

honest shoal
#

lib. doesn't matter much

light violet
#

;

light violet
oblique adder
#

anyone here using digital ocean for a music bot ? how was it ? I am planning to move to a new server. recommend me one (vps)

slate swan
light violet
#

hm

slate swan
#

@oblique adder

oblique adder
#

which one should I choose for hongkong / japan / singaporean server ?

slate swan
#

That's up to you, I'd recommend one close to the location on where your bot is most used.

#

Especially for bots going in voice channels, since the connection to the voice servers of Discord are based on location.

#

Which means, if your server is close to the server the user is connecting to when joining a voice channel, it gets less latency.

oblique adder
#

might be out of topic, If i finish the 100 $ that digital give for 60 days do I get autocharge or does it ask me like what google cloud does ?

slate swan
#

No idea, you probably can see when getting the plan.
I'd say you get automatically charged.

hoary gust
#

@slate swan hey need bit more help

#
                
    @commands.slash_command(name='user', description='command to get info of a server', options=[Option(name='member', description='mention the member whose info you want', required=False, type=OptionType.user)])
    async def user(inter, member= None): 
        if member is None: member = inter.user
        em= disnake.Embed(color=disnake.Color.green(), timestamp=datetime.utcnow())
        em.set_author(name=f"{member.name}#{member.discriminator}", icon_url=member.avatar)
        em.set_field_at(index=0, name="Name", value=f"{member.name}#{member.discriminator}", inline=True)
        em.set_field_at(index=1, name="ID", value=f"{member.id}", inline=True)
        em.set_field_at(index=2, name='Bot', value=member.bot, inline=True)
        return await inter.response.send_message(ephemeral=True, embed=em)    



#

whats the issue in this

#

like its not working

#

interaction failed

slate swan
#

For the embed author it's member.avatar.url

#

And I would just use add_field instead of set_field_at, then you can also remove the index kwarg.

hoary gust
#

i am using disnake

slate swan
#

?

serene lynx
#

when is py-cord version 2 released on pypi?

slate swan
#

This is the wrong server to ask in.

#

Ask in the pycord server :p

#

i'm wondering how does discord.py make the @object.command() decorator PES_Think

#

You can look at the source code :)
And rip the ghost ping gophercrying

#

yeah lmao still trying to find it in the source code but couldnt

#

Which one are you searching for?

#

i dont understand your question

#

@bot.command or @commands.command

#

bot.command

#

stuff is a bit confusing

#

black sometimes make code harder to read sweating

#

!e
print("x")

unkempt canyonBOT
#

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

x
slate swan
#

Niceeee it works

quick gust
#

Use #bot-commands Btw

spring flax
#

Anyone mind helping with this? I'm by no means familiar with buttons, butpy class myButton(disnake.ui.View): def __init__(self): super().__init__() @disnake.ui.button(label="Role Members", style=disnake.ButtonStyle.green) async def button(self, role, interaction: disnake.Interaction) -> None: listed_members = [member.mention for member in role.Members] if len(listed_members) > 50: member_mentions = listed_members[:50] else: member_mentions = listed_members await interaction.response.send_message(member_mentions, ephemeral = True)
it raised button object has no attribute members, for listed_members = [member.mention for member in role.Members]

maiden fable
#

role is an instance of ui.Button

#

U gotta do interaction.author.role or smth

unique breach
#

how to disable buttons after they are used?

worldly bane
gusty horizon
#

Can someone help me with my bot? I am getting

TypeError: 'NoneType' object is not subscriptable

unique breach
# worldly bane `button.disabled = True`
buttons = [
                create_button(style=ButtonStyle.blue, custom_id="back", emoji=leftbuttonemoji,
                              disabled=left_button),
                create_button(style=ButtonStyle.blue, custom_id="forward", emoji=rightbuttonemoji,
                              disabled=right_button),
            ]
            action_row = create_actionrow(*buttons)```
#

this is how a created the buttons

#

so ofc, button.disabled = True doesnt work...

gusty horizon
# worldly bane code and full traceback?
    """ Returns a list of the most recent banned players, default 10 players.
        Returns an empty list if request went wrong.
    """
    try:
        response = requests.get(url, headers=headers)
    except Exception as e:
        print(e)
        return []

    banList = response.json()

    tempServer, tempBanner = dict(), dict()
    for include in banList["included"]:
        if include["type"] == "server":
            tempServer[include["id"]] = include["attributes"]["name"]
        elif include["type"] == "user":
            tempBanner[include["id"]] = include["attributes"]["nickname"]

    playerNames, steamIds, banReasons, timeBanned, timeUnbanned, server, banner = ([] for i in range(7))
    for ban in banList["data"]:
        playerNames.append(ban["meta"]["player"])
        steamIds.append(ban["attributes"]["identifiers"][0]["metadata"]["profile"]["steamid"])
        banReasons.append(ban["attributes"]["reason"].replace(" ({{duration}} ban) - Expires in {{timeLeft}}.", ""))
        timeBanned.append(ban["attributes"]["timestamp"].replace("T", " ")[:-5])
        expires = ban["attributes"]["expires"]
        timeUnbanned.append(expires.replace("T", " ")[:-5] if expires != None else "Indefinitely")
        server.append(tempServer[ban["relationships"]["server"]["data"]["id"]])
        banner.append(tempBanner[ban["relationships"]["user"]["data"]["id"]])

    returnList = []
    for l in list(zip(playerNames, steamIds, banReasons, timeBanned, timeUnbanned, server, banner)):
        returnList.append(dict(zip([0,1,2,3,4,5,6], l)))
    return returnList
olling from Battlemetrics API...
06.01 02:04:38 [Bot] URL: https://api.battlemetrics.com/bans?filter[banList]=9ce88d10-69c6-11ec-adea-f365fcc3340f&include=user,server
06.01 02:04:38 [Bot] Exception in thread Thread-1:
06.01 02:04:38 [Bot] Traceback (most recent call last):
06.01 02:04:38 [Bot] File "/usr/lib/python3.9/threading.py", line 973, in _bootstrap_inner
06.01 02:04:38 [Bot] self.run()
06.01 02:04:38 [Bot] File "/usr/lib/python3.9/threading.py", line 910, in run
06.01 02:04:38 [Bot] self._target(*self._args, **self._kwargs)
06.01 02:04:38 [Bot] File "/discordBotBattlemetricsBanNotifier.py", line 89, in polling_thread
06.01 02:04:38 [Bot] self.update()
06.01 02:04:38 [Bot] File "/discordBotBattlemetricsBanNotifier.py", line 95, in update
06.01 02:04:38 [Bot] banList = get_banlist(URL, HEADERS)
06.01 02:04:38 [Bot] File "/discordBotBattlemetricsBanNotifier.py", line 164, in get_banlist
06.01 02:04:38 [Bot] steamIds.append(ban["attributes"]["identifiers"][0]["metadata"]["profile"]["steamid"])
06.01 02:04:38 [Bot] TypeError: 'NoneType' object is not subscriptable
06.01 02:04:40 [Bot] Logged on as Golden Eye#8221
unique breach
worldly bane
unique breach
#

sad

fluid spindle
#

Is there any way to get this system messages channel of a server?

velvet tinsel
#

disnake

heady skiff
#

I just started making discord bots in python and i have a question, is there a way to speed up things because right now, my code is full of like, if else statements like in js... kinda annoying . What i am trying to ask is, can you code a discord bot without a new if else statement for every new command

unique breach
heady skiff
#

yeah

velvet tinsel
fluid spindle
unique breach
#

ok..

heady skiff
velvet tinsel
#

using message.startswith() is annoying, better to use async def command(ctx, ....)

fluid spindle
velvet tinsel
#

@fluid spindle try guild.system_channel using the on_guild_join event

heady skiff
#

because most of my code, apart from some being on_message() is like, if user_message.lower() == 'something'..... then someething happens

velvet tinsel
gusty horizon
#

@worldly bane Any luck?

velvet tinsel
#

how empty :/

spring flax
#
Ignoring exception in view <myButton timeout=180.0 children=1> for item <Button style=<ButtonStyle.success: 3> url=None disabled=False label='Role Members' emoji=None row=None>:
Traceback (most recent call last):
  File "C:\Users\tenuk\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\disnake\ui\view.py", line 368, in _scheduled_task
    await item.callback(interaction)
TypeError: button() missing 1 required positional argument: 'role'

this gets raised when ```py

class myButton(disnake.ui.View):
def init(self, role : disnake.Role):
super().init()
@disnake.ui.button(label="Role Members", style=disnake.ButtonStyle.green)
async def button(self, _,interaction: disnake.Interaction, role) -> None:
listed_members = [member.mention for member in role.Members]
if len(listed_members) > 50:
member_mentions = listed_members[:50]
else:
member_mentions = listed_members
embed=disnake.Embed(description=member_mentions)
await interaction.response.send_message(embed=embed, ephemeral = True)```

slate swan
#

Thanks but it's not, api of the website , like bot send a joke. So he needs a api for sending the joke .
Can you get the point , what I wanna say?
Thank you so much in advance

spring flax
#

anyone know how to get from where the error is being raised from? Like the line

spring flax
velvet tinsel
spring flax
#

im not that familiar with buttons, also I don't think that's the issue

foggy current
#

i'm almost certain that the async def button function will be called only with self, button, and interaction parameters

fluid spindle
spring flax
foggy current
maiden fable
spring flax
nocturne bone
#

yo dm

foggy current
#

what you should do is set the button label and custom id to the name of the role

velvet tinsel
foggy current
#

then when someone presses the button, you can set role_name = interaction.data["custom_id"]

#

though that's if your library works the same as discord.py

#

ymmv

foggy current
#

when you declare the button through the decorator, you can put custom_id = "Role Members"

#

like how you have label = "Role Members"

spring flax
#

okay, i'll leave that for now though.

#

class myButton(disnake.ui.View):
    def __init__(self, role : disnake.Role):
        super().__init__()
    @disnake.ui.button(label="Role Members", style=disnake.ButtonStyle.green)
    async def button(self, _,interaction: disnake.Interaction, role) :
        listed_members = [member.mention for member in role.Members]
        if len(listed_members) > 50:
            member_mentions = listed_members[:50]
        else:
            member_mentions = listed_members
        embed=disnake.Embed(description=member_mentions)
        await interaction.response.send_message(embed=embed, ephemeral = True)

this raises this raises TypeError: button() missing 1 required positional argument: 'role', but the thing is it doesn't say the exact line

foggy current
#

yes, because async def button() is called with (self, button, interaction) parameters

#

so it's not getting a 4th parameter to set to role

spring flax
#

oh

#

i see

foggy current
#

should be async def button(self, button, interaction)

#

you have to get role a different way

foggy current
maiden fable
#

@spring flax get some sleep 😐

You never did these sorta mistakes before, so ig u r just tired

spring flax
#

yes very tired

#

haven't got proper sleep in days

#

but

#

i want to finish this

maiden fable
#

Well I think I have a few minutes to help u rn, if u ain't going to sleep

spring flax
#

i can't if I tried to

#

actually, i'll just recollect myself and try and do it myself

maiden fable
#

Ah cool. Best of Luck!

velvet tinsel
#

morning hun......ter....

maiden fable
#

Hi there. Morning

spring flax
#

it works now

#

thanks hunter

gusty horizon
#

Can anyone assist with an error

TypeError: 'NoneType' object is not subscriptable

manic wing
#

where

#

what is the nonetype

gusty horizon
#
[Bot] steamIds.append(ban["attributes"]["identifiers"][0]["metadata"]["profile"]["steamid"])
[Bot] TypeError: 'NoneType' object is not subscriptable```
manic wing
#

one of those is None

#

figure out which one

gusty horizon
#

Thanks

exotic patrol
#

can I read member's activity by the bot?

manic wing
unkempt canyonBOT
#

property activity: Optional[Union[disnake.activity.Activity, disnake.activity.Game, disnake.activity.CustomActivity, disnake.activity.Streaming, disnake.activity.Spotify]]```
Returns the primary activity the user is currently doing. Could be `None` if no activity is being done.

Note

Due to a Discord API limitation, this may be `None` if the user is listening to a song on Spotify with a title longer than 128 characters. See [#1738](https://github.com/DisnakeDev/disnake/issues/1738) for more information.

Note

A user may have multiple activities, these can be accessed under [`activities`](https://docs.disnake.dev/en/latest/api.html#disnake.Member.activities "disnake.Member.activities").
exotic patrol
maiden fable
pastel mango
#

Does anyone know of a way to add a tui to a hikari-lightbulb bot? I've been trying to use the cmd module, but so far have gotten stuck on the fact that it has it's own event loop and stops the bot from running. Any advice would be greatly appreciated.

slate swan
#

Can anyone tell what is wrong?

oblique adder
#

does using discord bot mobile status against the discord Tos ? please ping

slate swan
slate swan
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
#

ok

exotic patrol
#

how do we get all guild members in a list?

slate swan
unkempt canyonBOT
#

property members: List[discord.member.Member]```
A list of members that belong to this guild.
exotic patrol
slate swan
#

Np

slate swan
#

why it not work?

velvet tinsel
slate swan
#

should I put a link to go to the text channel?

heavy folio
#

!d discord.ext.commands.Bot.get_channel

unkempt canyonBOT
heavy folio
#

!d discord.TextChannel.mention then this

unkempt canyonBOT
velvet tinsel
slate swan
#

how to get a bot to add a role to a user using ctx, member: discord.Member

haughty quartz
#
@bot.command()
async def test(self,ctx, message : discord.Message):
  await message.add_reaction('\U00002705')```any way to fix `discord.ext.commands.errors.MissingRequiredArgument: ctx is a required argument that is missing.` ?
maiden fable
#

....?

maiden fable
unkempt canyonBOT
#

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

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

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, and the added [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
honest shoal
#

nvm

haughty quartz
# maiden fable Remove `self`

i now get raise MissingRequiredArgument(param) discord.ext.commands.errors.MissingRequiredArgument: message is a required argument that is missing

maiden fable
#

U didn't supply the message arg while invoking the cmd

#

U should do something like !test <msg-id>

haughty quartz
#

okay

maiden fable
#

Or remove the message arg and change it to ctx.message.add_reaction

haughty quartz
#

thank you :)

#

works perfectly

spring flax
#

When making buttons, how do I do something like

if not something:
  #do not show the button
else:
  #code here that shows buttons ```
#

I'm talking about the do not show button part

visual island
#

!d discord.ui.View.remove_item maybe?

unkempt canyonBOT
slate swan
#
@bot.command()
async def role(ctx, member: discord.Member):
    await ctx.send("get")
    mute_role = discord.utils.get(ctx.message.guild.roles, id=928342068261158972)
    await member.add_roles(mute_role)

?

velvet tinsel
#

You’re missing permissions

#

*your bot

upbeat otter
maiden fable
#

Lol

maiden fable
unkempt canyonBOT
velvet tinsel
#

Hello Hunter

tough lance
#

Hun.....ter

analog nova
#

log:

Ignoring exception in command tip:
Traceback (most recent call last):
  File "/home/niko/.local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "/home/niko/nimbot/-TPET-bot/main.py", line 234, in tip
    if amount > bal[0]:
TypeError: 'int' object is not subscriptable

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

Traceback (most recent call last):
  File "/home/niko/.local/lib/python3.9/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/home/niko/.local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/home/niko/.local/lib/python3.9/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: 'int' object is not subscriptable

code:

@client.command()
async def tip(ctx, member : discord.Member, amount = None):
    await open_account(ctx.author)
    await open_account(member)
    bal = await update_bank(ctx.author)
    if amount == None:
        await ctx.send("Amount cannot be empty! ||(valid amounts: `a number for ex. 3` or `all` to send all funds)||", delete_after=3)
        return

    if amount == 'all':
        amount = str(bal(0))

    amount = (amount)

    if amount > bal[0]:
        await ctx.send('You do not have sufficient funds to process the transaction', delete_after=3)
        return
    if amount < 0:
        await ctx.send("Amount shouldn't be negative!", delete_after=3)
        return

    await update_bank(ctx.author, -1 * amount, 'wallet')
    await update_bank(member,amount,'wallet')
    await ctx.send(f'{ctx.author.mention}, successfully gave {member} {amount} $TPET')
slate swan
#

See the difference?

analog nova
#

still nada

slate swan
#

Well, opposite.

ebon island
#

Say I have a server class object for a Discord server, is there a clean and efficient way to return the server object that refers to the server? I have my own method but it seems messy and I think there's the potential that something better is out there. Any ideas? Thanks!

slate swan
#

Since the error is for bal[0]

turbid brook
#

raise APIError(response)
gspread.exceptions.APIError: {'code': 404, 'message': 'Requested entity was not found.', 'status': 'NOT_FOUND'} why i get this

#

i wanna link my sheet Id

analog nova
# slate swan Since the error is for `bal[0]`

Ignoring exception in command tip:
Traceback (most recent call last):
File "/home/niko/.local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/home/niko/nimbot/-TPET-bot/main.py", line 234, in tip
if amount > str(bal(0)):
TypeError: 'int' object is not callable

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

Traceback (most recent call last):
File "/home/niko/.local/lib/python3.9/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/home/niko/.local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/home/niko/.local/lib/python3.9/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: 'int' object is not callable

ebon island
#

This is a custom server class Within my application

slate swan
jaunty wraith
#

I have a command that dumps a users id into a json file if they get blacklisted
Does anyone know how to make it so if there id is in the json file the bot needs to ignore them

ebon island
#

Probably load the contents of Json into memory and then check if argument in Contents

jaunty wraith
#

Ok

cold sonnet
#

not with brackets, neither with square brackets

#

I think all that you want is
amount = bal

#

amount = (amount)
is the most unnecessary thing I've ever seen

turbid brook
#

any help? wanna link sheet_ID

maiden fable
cold sonnet
#

please search yourself the right channel to ask this

turbid brook
#

it right channel

cold sonnet
#

no

turbid brook
#

because it a discord bot

cold sonnet
#

you're getting toaster tagged

turbid brook
#

im making a discord bot that read sheet ID

maiden fable
#

what's even happening

velvet tinsel
silk mauve
#

Does member has banner_url?

cold sonnet
#

Just because you're doing whatever this is inside of a bot does not make it dpy related. #python-help
"i have a toaster in my house, do i ask a carpenter how to fix it?" - Laggy

analog nova
tidal hawk
#

Can i see list of users who used certain invitation link?

silk mauve
#

I know that it has avatar

maiden fable
#

!d discord.Member.banner

#

!d discord.User.banner

unkempt canyonBOT
#

property banner: Optional[discord.asset.Asset]```
Returns the user’s banner asset, if available.

New in version 2.0.

Note

This information is only available via [`Client.fetch_user()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client.fetch_user "discord.Client.fetch_user").
velvet tinsel
maiden fable
#

Ah

cold sonnet
velvet tinsel
#

:hmmGe:

maiden fable
#

just do member.banner.url @silk mauve

velvet tinsel
maiden fable
#

!d discord.Asset.url

unkempt canyonBOT
dusky pelican
#

Am i allowed to find people who will do a bot for money here or is that not allowed?

silk mauve
unkempt canyonBOT
#

9. Do not offer or ask for paid work of any kind.

turbid brook
silk mauve
#

ember' object has no attribute 'banner'

velvet tinsel
dusky pelican
maiden fable
dusky pelican
#

How do i check if a dm recived contains a command ';confess'

cold sonnet
silk mauve
# maiden fable Show code

@bot.command() async def banner(ctx, member: discord.Member=None): if not member: member = ctx.author embed = discord.Embed(title=f"{member}'s Banner!", url=str(member.banner_:url), color=discord.Color.purple()) embed.set_image(url=str(member.banner_url)) await ctx.reply(embed=embed, mention_author=False)

cold sonnet
#

you can check if the command was invoked in dm's

silk mauve
turbid brook
# velvet tinsel which API is it?

google api , i fix it but i got another issue gspread.exceptions.APIError: {'code': 403, 'message': 'The caller does not have permission', 'status': 'PERMISSION_DENIED'}

#

need to make api in google cloud.

dusk trout
#
@commands.command()
async def test(ctx):
    test = get(ctx.guild.members, name='test')
    async def on_message(message):
        await message.channel.send(f" test:\n{test.mention} do your QOTD") 
        await asyncio.sleep(6)```
analog nova
#

Ignoring exception in command tip:
Traceback (most recent call last):
File "/home/niko/.local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/home/niko/nimbot/-TPET-bot/main.py", line 242, in tip
await update_bank(ctx.author, -1 * amount, 'wallet')
File "/home/niko/nimbot/-TPET-bot/main.py", line 51, in update_bank
users[str(user.id)][mode] += change
TypeError: unsupported operand type(s) for +=: 'int' and 'str'

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

Traceback (most recent call last):
File "/home/niko/.local/lib/python3.9/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/home/niko/.local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/home/niko/.local/lib/python3.9/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: unsupported operand type(s) for +=: 'int' and 'str'

dusk trout
#

can someone help me with this

maiden fable
silk mauve
silk mauve
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.

dusk trout
#

I dont have an error I forgot how to defien a coammnd name

cold sonnet
#

both of your errors are simple python niko

dusk trout
#

so like I want to execute that when I say ?QOTD

#

I havent coded in a while

maiden fable
#

!d discord.Member.banner

unkempt canyonBOT
#

property banner```
Equivalent to [`User.banner`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.banner "discord.User.banner")
maiden fable
#

Ah

#

U should do member.banner only

#

str() will automatically return the url

silk mauve
#

Oh

#

Alright

dusk trout
silk mauve
# maiden fable str() will automatically return the url

``@bot.command()
async def banner(ctx, member: discord.Member=None):
if not member:
member = ctx.author
embed = discord.Embed(title=f"{member}'s Banner!", url=str(member.banner), color=discord.Color.purple())
embed.set_image(url=str(member.banner))
await ctx.reply(embed=embed, mention_author=False)

``

silk mauve
#

remove test

dusk trout
#

thanks

silk mauve
#

wait

#

mhmm

dusk trout
silk mauve
dusk trout
# silk mauve send code
import discord
from discord.ext import commands
from discord.utils import get
import asyncio
from asyncio import sleep
bot = commands.Bot(command_prefix="?",description='Test for the QOTD pinger in LFS')
client= discord.client


@commands.command()
async def QOTD(ctx):
    test = get(ctx.guild.members, name='test')
    async def on_message(message):
        await ctx.send(f" test:\n{test.mention} do your QOTD") 
        await asyncio.sleep(6)
  
bot.run```
dusk trout
#

Ignoring exception in command None:
discord.ext.commands.errors.CommandNotFound: Command "QOTD" is not found
^C

grim oar
#

I only see error

dusk trout
#

this is what I get

silk mauve
#

wait

dusk trout
#

Ill add more text

silk mauve
#

The sleep does nothing because the messages already send

dusk trout
#

its unused

silk mauve
grim oar
#

You should check out tutorial pinned in the channel, there's a lot of thing wrong in it

slim ibex
#

Why is the on_message event inside a command

dusk trout
#

still

silk mauve
#

wait

grim oar
silk mauve
#

do

dusk trout
silk mauve
#

nvm

hexed turtle
slate swan
severe tundra
#

anyone here versed in the new slash commands? =^)

slim ibex
#

for which library\

severe tundra
#

Okay so basically i can create em, but idk how to catch the users input: ```@slash.slash(
name="Add_deadline",
description="Add a deadline",
guild_ids=[],
options=[
create_option(
name="title",
description="The title of the deadline",
required=True,
option_type=3
),
create_option(
name="date",
description="The date of the deadline",
required=True,
option_type=3
),
create_option(
name="channel",
description="The channelID of the deadline",
required=True,
option_type=3
)
]
)

dusky pelican
#

Anyone able to make or help make a discord bot for me (little to no experience)

cold sonnet
#

we told you already logan

#

rule 9

dusky pelican
#

I’m not paying

cold sonnet
#

you came here to ask something, to then ignore all the answers

dusky pelican
#

Just asking for help making

#

Not ignoring i just got no idea how to do that stuff

slim ibex
#

You need to create an interaction

severe tundra
#

as in, they activate the slash command and fill in the fields (? englando bery good)

severe tundra
hexed turtle
slate swan
#

Yes, but don't ask people here to go in your help channel.

dusk trout
#
import discord
from discord.ext import commands
client = discord.Client()
bot = commands.Bot(command_prefix=".",description='Test for the QOTD pinger in LFS')


@bot.event
async def on_ready():
 print(f"I am ready")

@bot.event
async def on_message(message):
    if message.content.startwith('?QOTD'):
      await message.channel.send("f<{@550370780245000200}>, Do your QOTD") 
jaunty wraith
#

Does anyone know why im getting this error

dusk trout
#

I get an indentation error on line 10

#

there is nothing on line 10

dusk trout
jaunty wraith
#

Yes

dusk trout
#

send the code

jaunty wraith
#

import discord
from discord.ext import commands
from discord_slash import SlashCommand, SlashContext
from discord_slash.utils.manage_commands import create_choice, create_option
import os
from keep_alive import keep_alive

brazen raft
jaunty wraith
#

Ohhh

brazen raft
#

And name your variable bot for good practice

jaunty wraith
#

Seems like a mistake i would make lol

#

Ok

dusk trout
#

@brazen raft can you take a look at my code

#
import discord
from discord.ext import commands
client = discord.Client()
bot = commands.Bot(command_prefix=".",description='Test for the QOTD pinger in LFS')


@bot.event
async def on_ready():
 print(f"I am ready")

@bot.event
async def on_message(message):
    if message.content.startwith('?QOTD'):
      await message.channel.send("f<{@550370780245000200}>, Do your QOTD") 
brazen raft
#

discord.Client is different than discord.ext.commands.Bot but you can instantiate from both classes

sweet geyser
#
  File "/media/Storage/Projects/Discord-Bots/Shell bot/bot.py", line 12, in on_message
    async with ctx.typing():
AttributeError: 'Message' object has no attribute 'typing'
brazen raft
#

So just name your variables right

dusk trout
#

yes

#

the thing is

sweet geyser
#

also

#

instead of using bot.event

slim ibex
#

You either use client or bot

dusk trout
#

I get an indentation error in line 10

sweet geyser
#

you could use @bot.command

dusk trout
#

there is nothing on line 10

slim ibex
#

what is line 10

brazen raft
dusk trout
slim ibex
#

Any code @sweet geyser ?

sweet geyser
#

Sure

#
@bot.event
async def on_message(ctx):
    if ctx.author.bot:
        return
    if ctx.channel.id == 927847608406384671:
        async with ctx.typing():
        output = os.popen(ctx.content).read()
        cwd = os.popen('echo "${PWD##*/}"').read().replace("\n", "")
        await ctx.channel.send(f"[clerickx@gentoo {cwd}]$ {ctx.content}\n{output}")
dusk trout
#
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix=".",description='Test for the QOTD pinger in LFS')


@bot.command
async def on_ready():
 print(f"I am ready")

@bot.command
async def on_message(message):
    if message.content.startwith('?QOTD'):
      await message.channel.send("f<{@550370780245000200}>, Do your QOTD") 
        
bot.run
brazen raft
slim ibex
#

bot.run()

dusk trout
#

the second @slate swancommand is giving me an error

dusk trout
sweet geyser
#

i mean the token

dusk trout
#

ye

slim ibex
jaunty wraith
#

The bot is online but the / command doesnt show up
@slash.slash(name="hello", description="says hello",guild_ids=[890566405773226014])
async def hello(ctx,SlashContext):
await ctx.reply(f"hello {ctx.author.user}")

sweet geyser
#

I erased my old code

slim ibex
#

Lmao

jaunty wraith
#

Ooof

brazen raft
#

@dusk trout basically, you need to have a consistent indentation for every indented statement

cold sonnet
#

does somebody use replit

severe tundra
jaunty wraith
#

Ive deleted my entire repl before

slim ibex
brazen raft
#

You have one space in the first command but then you have a different amount of spaces in the second command, that's inconsistent

jaunty wraith
cold sonnet
#

god

sweet geyser
slim ibex
#

Ok, imma say first off y’all need to get off discord.py

jaunty wraith
sweet geyser
#

it is outdated af

jaunty wraith
sweet geyser
#

But what other library i can choose?

slim ibex
jaunty wraith
slim ibex
severe tundra
slim ibex
#

there is a new one called Pincer, but it is in alpha and not 100% stable

#

But it is very promising and I would look out for it

dusk trout
brazen raft
slim ibex
brazen raft
#

You need to keep a consistent amount of spaces to add for each level of indentation

#

You can't have code like this

if False:
   print("Uh")
else:
 print("False!")
#

It needs to be consistent:

if False:
    print("Oh!")
else:
    print("False!")
dusk trout
#
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix=".",description='Test for the QOTD pinger in LFS')


@bot.command
async def on_ready():
    print(f"I am ready")

@bot.command
async def on_message(message):
    if message.content.startwith('?QOTD'):
     await message.channel.send("f<{@550370780245000200}>, Do your QOTD") 
        
bot.run

slim ibex
#

bro messed up the backticks

dusk trout
#

now

#

?

brazen raft
#

Put more spaces before it

slim ibex
#

why do an on_message event for a command when you can just make the command?

final iron
slim ibex
#

lmao the tutorial even talks about discord.py being discontinued

final iron
#

I mean it still works

slim ibex
#

ik

brazen raft
#

Yeah just use PyCord or something

dusk trout
#

now it doesnt find the discord module although its installed

#

wtf is this

slim ibex
#

but doesn’t have any new things like slash commands, interactions or buttons without needing extra shit

final iron
slim ibex
#

^

brazen raft
dusk trout
#

visual studio

slim ibex
#

Id use nextcord or disnake

final iron
#

^

slim ibex
#

visual studio and visual studio code are different

brazen raft
#

Which one do you recommend to this fella

slim ibex
#

which one?

slim ibex
dusk trout
#

visaul studio code my bad

slim ibex
#

But as I said, watch out for pincer

brazen raft
#

!PyPi nextcord

unkempt canyonBOT
slim ibex
#

!pypi pincer

unkempt canyonBOT
brazen raft
#

Install this one @dusk trout

#

What the hell is pincer

#

Never heard of it

slim ibex
#

a new api wrapper for discord

obsidian ledge
#

how do i make a command that edits the channel topic

slim ibex
#

it looks rlly nice even though it’s in alpha

obsidian ledge
#

with the next word i put to it

slim ibex
#

it has things like middleware, and slash commands

#

it’s more advanced than the others ones I have seen

#

It has web sockets.

#

Haven’t seen that with other ones

dusk trout
#

I installed pincer still wont detect discord module

brazen raft
#

No, install nextcord

slim ibex
#

^

#

pincer is still in alpha so I wouldn’t make a full scale bot with it yet

brazen raft
#

@dusk trout do

pip install nextcord

And in your code, change discord to nextcord

proven ore
#

disnake or pycord?

#

or nextcord

dusk trout
#

wont detect nextcord

jaunty wraith
dusk trout
#
from nextcord.ext import commands
bot = commands.Bot(command_prefix=".",description='Test for the QOTD pinger in LFS')


@bot.command
async def on_ready():
    print(f"I am ready")

@bot.command
async def on_message(message):
    if message.content.startwith('?QOTD'):
      await message.channel.send("f<{@550370780245000200}>, Do your QOTD") 
        
bot.run
brazen raft
jaunty wraith
brazen raft
jaunty wraith
#

Ok

dusk trout
#

why are you doign this to me visual code

slim ibex
#

do you have the right interpreter selected

#

I would restart VSCode after installing a module too

dusk trout
#

I did

slim ibex
#

this is why you use a venv lol

brazen raft
brazen raft
#

You're on Windows, right?

jaunty wraith
dusk trout
#

Okay so my code is good
I umistalled discord and discord.py

#

I installed nextcord

#

and still my module doesnt get detected

#

in replit it doesnt give any errors but simply doesnt run

slim ibex
#

replit lmao

spring flax
#

how do I check discord.Forbidden errors on disnake?

slate swan
#

!d disnake.Forbidden

unkempt canyonBOT
#

exception disnake.Forbidden(response, message)```
Exception that’s raised for when status code 403 occurs.

Subclass of [`HTTPException`](https://docs.disnake.dev/en/latest/api.html#disnake.HTTPException "disnake.HTTPException")
dusk trout
#

what should I use

brazen raft
#

@dusk trout go to their Discord server

spring flax
#

typo*

slate swan
#

*made a typo

dusk trout
#

if not visual code

spring flax
#

bruh what did I even write

slate swan
#

It was understandable :0

cold sonnet
#

'mayd' even sounds right

cold sonnet
#

not replit

#

if you installed nextcord, maybe you forgot restarting VSC or you installed it on another python version, not what you use in VSC

boreal ravine
#

ot but vsc should add a button where you can install modules/packages from certain package websites (pypi, npm, crates, etc)

cold sonnet
#

bolb

spring flax
cold sonnet
#

it's in commands innit

boreal ravine
#

!d disnake.ext.commands.MissingRequiredArgument

unkempt canyonBOT
#

exception disnake.ext.commands.MissingRequiredArgument(param)```
Exception raised when parsing a command and a parameter that is required is not encountered.

This inherits from [`UserInputError`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.UserInputError "disnake.ext.commands.UserInputError")
boreal ravine
#

that?

cold sonnet
#

this has a param

#

unlike BadArgument

#

it still doesn't make sense

spring flax
#

wdym?

cold sonnet
#

!d disnake.ext.commands.BadArgument

unkempt canyonBOT
#

exception disnake.ext.commands.BadArgument(message=None, *args)```
Exception raised when a parsing or conversion failure is encountered on an argument to pass into a command.

This inherits from [`UserInputError`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.UserInputError "disnake.ext.commands.UserInputError")
cold sonnet
#

you can't get the param that raised this

#

you asked this yesterday

slate swan
#

v2.x

spring flax
#

Yeah, I was tricked by autocomplete when I thought I put my function

#

error.param returns the typehint of the param too?

slate swan
#

happy three kings day guys and girlspithink

slate swan
unkempt canyonBOT
#

class inspect.Parameter(name, kind, *, default=Parameter.empty, annotation=Parameter.empty)```
Parameter objects are *immutable*. Instead of modifying a Parameter object, you can use [`Parameter.replace()`](https://docs.python.org/3/library/inspect.html#inspect.Parameter.replace "inspect.Parameter.replace") to create a modified copy.

Changed in version 3.5: Parameter objects are picklable and hashable.
cold sonnet
#

yes

spring flax
#

ah

#

so i'll just split it then

slate swan
#

Gg

dusk trout
#
from nextcord.ext import commands

bot = commands.Bot(command_prefix=".", description='Test for the QOTD pinger in LFS')


@bot.command
async def on_ready():
    print(f"I am ready")


@bot.command
async def on_message(message):
    if message.content.startwith('?QOTD'):
        await message.channel.send("f<{@550370780245000200}>, Do your QOTD")

bot.run
#

everything is fine modules work

cold sonnet
#

functions don't exist

dusk trout
#

just wont do anything

brazen raft
#

Does it print?

slate swan
#

Cause bad code

brazen raft
#

Oh yeah

slate swan
#

event lol

dusk trout
cold sonnet
#

would be funny if it would

brazen raft
#

on_ready should be after @bot.event, not @bot.command()

slate swan
#

use commands and not on msgs

brazen raft
#

ons should follow @bot.event

cold sonnet
#

and @bot.command should be @bot.command()

#

whenever it's actually a command

slate swan
#

yah

dusk trout
#

still

#

its says i am ready

#

but wont do anyting when I do ?QOTD

slate swan
#

do you have many on msgs?

cold sonnet
#

on_message is also an event

brazen raft
honest vessel
#

how can i change nick on the bot it self?

slate swan
cold sonnet
#

in a specified server

slate swan
#

or the nickname ^

honest vessel
#

username i guess

cold sonnet
#

dev portal

slate swan
#

dev portal

#

🧍‍♂️

cold sonnet
slate swan
#

jinx

honest vessel
#

oh ok then nickname for server

slate swan
dusk trout
#

bot = commands.Bot(command_prefix=".", description='Test for the QOTD pinger in LFS')


@bot.event
async def on_ready():
    print(f"I am ready")


@bot.event
async def on_message(message):
    if message.content.startwith('?QOTD'):
        await message.channel.send("f<{@550370780245000200}>, Do your QOTD")


bot.run(
cold sonnet
#

guild_object.me.edit(nick=... )

dusk trout
#

AttributeError: 'str' object has no attribute 'startwith'

#

line 414, in _run_event
await coro(*args, **kwargs)

#

2 errors

slate swan
#

startswith

honest vessel
#

@cold sonnetthanks

slate swan
#

^

dusk trout
#

It works but it wont ping me

cold sonnet
#

the f is outside of the string

dusk trout
#

I reomved the f

brazen raft
cold sonnet
#

spoonfeed

#

message.user?

slate swan
#

no even need for that f str

#

@dusk trout
isnt that enough

dusk trout
cold sonnet
#

message.author

slate swan
dusk trout
#

I dont want it to be the author

brazen raft
#

Move this into an actual command

cold sonnet
slate swan
#

im gonna spoodfeed

#

🧍‍♂️

cold sonnet
#

no you're not

brazen raft
#
@bot.command()
async def qotd(ctx):
    await ctx.send(ctx.author.mention + " hello")
#

That's a start

slate swan
cold sonnet
#

NO

dusk trout
#

i dont want it to be the author tho

slate swan
#

you failed

cold sonnet
#

add an argument

polar ice
#

If i use an enum does that work the same as a global var?

grim oar
#

No

polar ice
#

i can update its values anywhere in the code?

brazen raft
dusk trout
#

if I were to put a paranthesis at the end and add my name then define it would it work

slate swan
#
@bot.command()
async def qotd(ctx, member: discord.Member):
    await ctx.send(f"{member.mention} hello")
#

🧍‍♂️

cold sonnet
brazen raft
#

No need for the f-string

slate swan
#

im boredpithink

slate swan
#

dont say it

cold sonnet
#

but f-strings are cool

brazen raft
#

member.mention + " hello"

slate swan
#

im not using +

#

🧍‍♂️

grim oar
cold sonnet
#

bruh

slate swan
#

smh

#

you on 2.0?

brazen raft
#

You use f-strings when you have other data types than strings

slate swan
grim oar
#

👋

brazen raft
#

If it's just strings, concatenating with + is just fine

slate swan
polar ice
#

@grim oar So i cant change them? Im used to C+ where i use them a lot. just trying to get my head around them in python?

brazen raft
#

It wasn't their intended use

cold sonnet
#

"{} hello".format(member.mention)

slate swan
brazen raft
#

And it's dumb doing this with two string objects

dusk trout
#

how do i resolve ctx reference

slate swan
brazen raft
#

What do you mean

cold sonnet
#

what does that mean

slate swan
#

ctx means context

#
@bot.command()
async def qotd(ctx: commands.Context, member: discord.Member) -> None:
    await ctx.send(f"{member.mention} hello")

makes sense

dusk trout
#

when I type anything with ctx it says unresolved reference ctx

brazen raft
#

The decorator @bot.command() passes a Context object as the first argument to the function

brazen raft
dusk trout
#

but ctx into it

slate swan
#

he thinks ctx is a nonetype arg

#

lmao

brazen raft
dusk trout
#

time to rewrite

grim oar
spring flax
#

wait because error.param returns what you typehinted the param too, you can't remove the typehint?

brazen raft
#

The entire point of events is that their context is their event type and the arguments their handling function is getting

polar ice
#

@grim oarCould you give an example please? 🙂

brazen raft
#

@polar ice enums in Python is just a class (mimicking a namespace) subclassing enuns.Enum or whatever

spring flax
grim oar
unkempt canyonBOT
#

@grim oar :white_check_mark: Your eval job has completed with return code 0.

001 | 2
002 | 6
honest vessel
#

when i setup slashcommands on my first server i didnt use test_guilds=[] does that mean i cant get same slashcommands in the new server i let bot create so bot can be serverowner?

#

or is it just taking alot of time for discord to set it up

jaunty wraith
#

I have this code i wrote for a / command that just replies with hello but every time i run the command it gives me the error in the screenshot

@slash.slash(name="hello", description="says hello",guild_ids=[890566405773226014])
async def say(ctx,SlashContext):
await ctx.reply(f"hello {ctx.author.name}")

cold sonnet
#

didn't you mean to typehint

brazen raft
#

Just a guess, but remove the second argument

cold sonnet
#

instead of setting two arguments

tawdry perch
#

how can I make a global checks? like that check(s) is ran before command is executed

polar ice
#

So it isnt possible to do something like this?

class server_setting(Enum):
    logo = None
    pName = None
    Password = None
    Salt = None
    PasswordFails = None


def load_authini():
    #connect to SQL and load settings
    server_setting[logo] = "logo.png"```
cold sonnet
#

what even is that

grim oar
#

ofc not, I told you it's immutable

brazen raft
#

What is your intention with that code?

cold sonnet
#

that's not discord bots -_-

grim oar
slate swan
#

and isnt he missing the static method decorator?

tawdry perch
polar ice
#

Just wanted to clarify, thats how i did it in C+ 🤔

brazen raft
#

An enum is used like server_setting.logo in your case, but all of your enums are None so what's the point?

cold needle
#

yo

#

embed.add_field(name="hello", value='', inline=False)

polar ice
cold needle
cold sonnet
cold needle
dusk trout
#
from nextcord.ext import commands
from discord.utils import get
import discord


bot = commands.Bot(command_prefix=".", description='Test for the QOTD pinger in LFS')


client = discord.Client


@bot.event
async def on_ready():
    print(f"I am ready")


@bot.command()
async def qotd(ctx):
    sus = get(ctx.guild.members, name='sus')
    await ctx.send(f"\n Sus:\n{sus.mention}" + "Do your QOTD")

bot.run
cold sonnet
#

maybe use an invisible character to outplay the system

dusk trout
#

AttributeError: 'NoneType' object has no attribute 'mention'

polar ice
#

@cold needle use

embed.add_field(name="\u200b", value=f"\u200b", inline=False)```
brazen raft
cold sonnet
#

now that's f-strings and + mixed

dusk trout
brazen raft
#

And from code

#

It should be documented

dusk trout
grim oar
slate swan
#

and why are you using client and bot?

#

delete client

tawdry perch
#

!d disnake.ext.commands.check | is there a global version that makes a check for every command without needing to decorate it

unkempt canyonBOT
#

@disnake.ext.commands.check(predicate)```
A decorator that adds a check to the [`Command`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.Command "disnake.ext.commands.Command") or its subclasses. These checks could be accessed via [`Command.checks`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.Command.checks "disnake.ext.commands.Command.checks").

These checks should be predicates that take in a single parameter taking a [`Context`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.Context "disnake.ext.commands.Context"). If the check returns a `False`-like value then during invocation a [`CheckFailure`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.CheckFailure "disnake.ext.commands.CheckFailure") exception is raised and sent to the [`on_command_error()`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.disnake.ext.commands.on_command_error "disnake.disnake.ext.commands.on_command_error") event.

If an exception should be thrown in the predicate then it should be a subclass of [`CommandError`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.CommandError "disnake.ext.commands.CommandError"). Any exception not subclassed from it will be propagated while those subclassed will be sent to [`on_command_error()`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.disnake.ext.commands.on_command_error "disnake.disnake.ext.commands.on_command_error").
brazen raft
#
intents = nextcord.Intent.default()
intents.members = True
bot = commands.Bot(command_prefix="whatever", intents=intents)
oblique adder
#

how do I check if a message id is still exist in the text channel

tawdry perch
#

can I make check that applies to whole cog then?

brazen raft
#

I'm not sure though, might be nextcord.Intents.default()

cold sonnet
slate swan
unkempt canyonBOT
#

add_check(func, *, call_once=False)```
Adds a global check to the bot.

This is the non-decorator interface to [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.check "discord.ext.commands.Bot.check") and [`check_once()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.check_once "discord.ext.commands.Bot.check_once").
cold sonnet
#

one by one

tawdry perch
cold sonnet
#

oh, lucky you, there is one

tawdry perch
#

indeed

brazen raft
#

A cog_check

tawdry perch