#discord-bots

1 messages · Page 1072 of 1

torn sail
#

!d discord.Role.members

unkempt canyonBOT
warped mirage
#

@slate swan thank u so much it all works but i have one more request but idk if u will agree

terse coyote
#

how to mention users who in list of this role?

slate swan
#

But yeah you can ask questions, this is a help channel after all

torn sail
warped mirage
slate swan
#

uh all g

warped mirage
#

g nice

terse coyote
slate swan
#

!d discord.Role.members

unkempt canyonBOT
torn sail
terse coyote
#

idk sorry...

slate swan
#

I have my bot's config stored in a json file which is loaded into the python file. How would I make it so the json config file would be reloaded into the program every x seconds so if the user updated the command prefix for example the bot would not need to restart

torn sail
#

You can get a list of mentions with list comprehension mentions = [member.mention for member in role.members and then use mentions = " ".join(members)

potent spear
slate swan
#

how do I do that?

potent spear
slate swan
potent spear
#

show me how the member would update the command prefix

slate swan
#

no i want it so if the owner updated the config file the bot doenst need to restart

slate swan
potent spear
# slate swan
with open("config.json") as f:
  config = json.load(f)```
potent spear
torn sail
slate swan
torn sail
#

Yeah

slate swan
potent spear
slate swan
#

yes but how

oak wagon
#

can i mak eslash commands with python?

potent spear
#

also, if your bot is in multiple guilds, please use a database instead

slate swan
#

I would If i knew how lol

slate swan
torn sail
#

yeah i completely messed that up

slate swan
#

I think it's also better if mentions as a generator is passed into .join()

torn sail
#

yeah

slate swan
#

so no need to convert it to a list when you can just use the generator obj

#

A generator expr will be slower tho..

#

Wait does a GuildChannel converter exist?

#

Yeah so you can do this

@bot.command()
async def get_channel(ctx, *, channel: discord.abc.GuildChannel):
    await ctx.send(channel.id)

and channel can be any guild channel

potent spear
#

discord.TextChannel

#

since most likely, you don't need categorychannels or voicechannels

slate swan
#

Yeah well that's their choice

#

I think

weak moat
#
def draw_multiple_line_text(image, text, font, text_color, text_start_height):
         draw = ImageDraw.Draw(image)
         image_width, image_height = image.size
         y_text = text_start_height
         lines = textwrap.wrap(text, width=50)
         for line in lines:
            line_width, line_height = font.getsize(line)
            draw.text(((image_width) / 2.56, y_text), line, font=desc, fill=text_color, align="left")
            
            y_text += line_width

How can I make sure that if there is a '\n' sign, then the text wraps to the next line?

warped mirage
#
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'execute'``` guys how do i fix this
sick birch
warped mirage
#
    @commands.command()
    async def wm_del(self, ctx):
        async with aiosqlite.connect("wm.db") as db:
            cursor = await db.commit()
            await cursor.execute("SELECT * FROM wm WHERE guild_id = ?", (ctx.guild.id))
            data = await cursor.fetchone()
            if data is None:
                await ctx.send("This server is not configured for a welcome channel", delete_after = 10)
                return

            if data is not None:
                await cursor.execute("DELETE FROM wm WHERE guild_id - ?", (ctx.guild.id,))
                await db.commit()
                await ctx.send("Disabled Welcome Channel in this server!", delete_after = 10)
                return```
potent spear
#

FYI: this is useless if data is not None:

warped mirage
sick birch
#

await db.commit() doesn't return anything

#

Logically doesn't make sense for it to

#

Also don't create a new connection for every command

potent spear
#

start with fixing the cursor first, then move on (optimization) from there

sick birch
#

^ keep it in mind though

potent spear
#

you're basically guessing code for the past... week?
I highly suggest to learn how to work with libs by reading their docs and examples

warped mirage
#

i been working on this system for 3 days now but since i updated to 2.0 its kinda difficult for me i guess so ill try get help from someone

potent spear
#

this has nothing to do with v2.0

#

literally everything in the command itself isn't related with dpy (except the sending ofc)
It's just "how to fetch data and work with it"
there are tons of examples in aiosqlite on how to do CRUD operations

#

your main focus here is "how to read data from a db"

warped mirage
#

anyways can someone help me code a set welcome message command

potent spear
potent spear
warped mirage
#

i guess i need to learn , i wanna make a command = set_msg welcome to serve {member.mention}

#

custom messages

potent spear
#

mhm, but you have to think about other stuff too

#

like "what if it's not set yet?" or what happens when you overwrite it?
etc etc

potent spear
potent spear
#

the database setup

warped mirage
#

ok lets start with that

potent spear
#

since you'll have to store the welcome message for every guild

#

this question has been asked many times here, maybe a ctrl+f can do wonders

warped mirage
#

what should i type

potent spear
#

bot.db =

warped mirage
#

like exact

potent spear
#

.

warped mirage
#

OHHH

#

u want me to setup the db first

potent spear
#

you'll first have to learn SQL though, since that language is used in databases
once you know basic CRUD operations, you'll know what to do

#

creating tables, getting shit out of it, updating it, deleting stuff out of it, ...

warped mirage
#

can u refer me to a documentation ima try learn

potent spear
#

you'll probably want to use aiosqlite as a starter, an async wrapper of sqlite

warped mirage
#

it will be very hard tho

potent spear
warped mirage
#

ok

potent spear
#

#databases is how to get started and what to look for

slate swan
#

how can i edit a embeded field?

potent spear
slate swan
#

how would I edit a embed after its been sent?

potent spear
slate swan
#

is it the same thing to edit a field?

potent spear
slate swan
#

thank you, how would i remove a field?

potent spear
#

!d discord.Embed.remove_field

unkempt canyonBOT
#

remove_field(index)```
Removes a field at a specified index.

If the index is invalid or out of bounds then the error is silently swallowed.

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

Note

When deleting a field by index, the index of the other fields shift to fill the gap just like a regular list.

Changed in version 2.0: This function now returns the class instance.
oak wagon
#

REPLIT NUKED MY SERVER

slate swan
#

replit is public so any one can see your code and someone probably got your token

#

next time use a env

oak wagon
#

WHATS A ENV

#

SOME RREATRD BANNED ALL MY MEMBERS

slate swan
oak wagon
#

I PUT IT IN THE SCRIPT

warped mirage
#

in replit is it even possible to hide ur token without premium?

warped mirage
#

i use vs code its just much better

#

yep

slate swan
#

how can I send an embed field but with no name?

#

@slate swan u can use * * or _ _

#

perf thanks

#

np

#

_ _

#

@slate swan * * doesn't work so just use the double underscore

#

my bad

#

thanks

warped mirage
#
 File "C:\Users\Dom\Desktop\beta test\cogs\welcome.py", line 54, in wm_del
    await cursor.execute("SELECT * FROM wm WHERE guild_id = ?", (ctx.guild.id))
AttributeError: 'NoneType' object has no attribute 'execute'``` can someone help me fix
#
@commands.command()
    async def wm_del(self, ctx):
        async with aiosqlite.connect("wm.db") as db:
            cursor = await db.commit()
            await cursor.execute("SELECT * FROM wm WHERE guild_id = ?", (ctx.guild.id))
            data = await cursor.fetchone()
            if data is None:
                await ctx.send("This server is not configured for a welcome channel", delete_after = 10)
                return

            if data is not None:
                await cursor.execute("DELETE FROM wm WHERE guild_id - ?", (ctx.guild.id,))
                await db.commit()
                await ctx.send("Disabled Welcome Channel in this server!", delete_after = 10)
                return```
warped mirage
#

oh i fixed

slate swan
warped mirage
#

btw i need help coding a command

shut briar
#

How is this bot able to be online with a mobile status?

slate swan
shut briar
#

why is it verified then .___.

slate swan
#

he probably got verified first lol

shut briar
#

Oh so its against the rules and undocumented

#

he just figured it out somehow

slate swan
#

no

#

its againts the rules, the endpoint was documented or still is

maiden fable
#

Its a Discord API Bug

#

Discord knows about it and still cba to fix it, so no harm in using it since we ain't really using an undocumented endpoint which is not meant for bots

slate swan
maiden fable
#

@slate swan

warped mirage
#

hey @maiden fable guess what

maiden fable
#

U fixed the error?

warped mirage
#

my entire code is fixed lmao

maiden fable
#

Congrats!

slate swan
warped mirage
#

well not quite...

#

welcome system yet 😉

#

i need help

maiden fable
#

Don't expect me to help u rn, its already gonna be 4 AM for me

warped mirage
#

When can u help

maiden fable
#

Idk tbh

ornate kelp
#

Hi!! I am running:
username = urllib.parse.quote_plus('xxx')
password = urllib.parse.quote_plus('xxx') bot.connection_url = pymongo.MongoClient('mongodb://%s:%s@cluster0.ktjws.mongodb.net/?retryWrites=true&w=majority:27017' % (username, password))

and I keep getting the same error: "ValueError: Port must be an integer between 0 and 65535: 27017" -

Any hint on how to solve it?

warped mirage
maiden fable
#

sure ig

#

Wait not then, I have a class. But yea, maybe around that

warped mirage
#

Ok

ornate kelp
slate swan
keen mural
#

anyone know how i can make a bot like rumble royale

#

or a command like dank memer heists

sick birch
#

Well, can you outline how exactly it should work?

#

That in itself is a good starting place

keen mural
#

yeah

sick birch
#

If you can write down step by step what should happen, you're in a good place already when it comes to creating something (planning phase)

keen mural
#

so its kinda like a giveaway where there is one winner

#

but it tells all the events that happens (who kills who)

#

thats basically it

sick birch
#

Would be helpful to be more detailed

keen mural
#

yeah so people react to get entered into the "fight"

sick birch
#

Like what arguments it's going to take, how it determines the winner, how to enter, what events happen, how they happen, etc

keen mural
#

and its a battle royale you watch,

#

all random stuff and it tells you who kills who

#

or if nothing happens

sick birch
#

Is there any user intervention after joining, or is it just random?

keen mural
#

all random

#

so i know how the winner could be picked

sick birch
#

Should be pretty easy then

keen mural
#

but what i dont understand is how you would tell the events that happened

sick birch
#

For the events, pick 2 random users, pick a random event, and cause that event to happen to one of those 2 people by someone else

keen mural
#

example

keen mural
#

(im new to python mostly)

#

would i use smth like for i in range(5):

#

i just answered my own question i guess lol

#

Thanks for the help man the world needs more people like you @sick birch

scarlet sorrel
#

TypeError: The fill character must be exactly one character long
give me one reason at all why this is a thing

#

just let people put more then one character ffs

#

i need to use a ZWJ because discord is stupid with spaces

flint isle
#

how can i list the command and the arguments in an embed.

#

like
$yourmom {arg1} {arg2}

sick birch
#

while you don't have a winner, keep making events and eliminating players

keen mural
#

ok

sick birch
#

You're on the right track with the for loop though

keen mural
#

how would i continue rounds

sick birch
#

what do you mean continue rounds?

keen mural
#

like after i do one round

#

with i in range loop

#

how would i repeat that

sick birch
#

Ah yeah how many rounds do you want per game?

keen mural
#

as many until a winner

sick birch
#

So what do you classify a round as?

#

One event = 1 round?

keen mural
#

the entire loop completed

sick birch
#

1 winner = 1 round?

keen mural
#

no

sick birch
#

I'm not following

keen mural
#

each round some people are eliminated

#

undefined amount of rounds

#

keep going untill there is a winner

sick birch
#

How many people eliminated per round?

keen mural
#

random

sick birch
#

I see

#

So while loop for the round (main while loop)

#

inside figure out how many people should be eliminated in that round

#

for loop for that

keen mural
#

im not following

sick birch
#
winner = None
while not winner:
  number_of_eliminations = random.randint(...) # how many people should be eliminated
  for i in range(number_of_eliminations):
    # eliminate one person here
#

That's the base structure, you might want to add some more stuff in there like checking if there is a winner

keen mural
#

how i was gonna do it is it goes through 2 ppl at a time and decides what happens

#

like u said

#

and 1 guy would kill the other

sick birch
#

Yeah, you'd do that inside the for loop

keen mural
#

oh ok

sick birch
#

number_of_eliminations doesn't necessarily have to be the number of people eliminated

keen mural
#

ill try it out
and i can do sleep at the end of the loop to delay it a bit right

sick birch
#

Yeah yeah always

sick birch
#

I'm guessing you thought that number_of_eliminations is how many people were eliminated per round

#

I meant that if person X kills person Y, that would count as 1 elimination

keen mural
#

ok

flint isle
#

Ignoring exception in on_command_error
Traceback (most recent call last):
  File "C:\Users\Andy\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\client.py", line 612, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\Andy\PycharmProjects\WhiskeyBotMain\cogs\CommandErrorHandler.py", line 60, in on_command_error
    embed.add_field = f'Missing argument: {error.param}'
AttributeError: 'Embed' object attribute 'add_field' is read-only

        if isinstance(error, disnake.ext.commands.MissingRequiredArgument):
            embed = disnake.Embed()
            embed.title = f'Error'
            embed.add_field(name='Error Location', value=f'{ctx.command}', inline=True)
            embed.description = f'A missing argument was missing in {ctx.command}. Please run the command again but including the missing argument'
            embed.add_field = f'Missing argument: {error.param}'
            embed.add_field = f"{ctx.command} {ctx.args}"
            embed.set_footer = 'An Exception has occured ... Details Above.'
            await ctx.send(embed=embed)
            return
torn sail
#

and embed.set_footer(text='', icon_url='optional')

flint isle
#

Omg thanks

slate swan
#
@client.event
async def on_message(message):
    general_channel = client.get_channel(980551403351191595)

    if author.id == 625025751413948436:
        if message.content == 'TEST':
            await general_channel.send('test successful!')```
#

help

#

why wont it work?

sick birch
#

What's the error?

#

If I'm to guess, "author" is not defined

slate swan
#

ye

#

how do I define it?

#

@sick birch

shrewd apex
slate swan
#

where?

shrewd apex
#

and don't forget await client.process_commands(message)

slate swan
#

so

#
@client.event
async def on_message(message):
    general_channel = client.get_channel(980551403351191595)

    if message.author.id == 625025751413948436:
        if message.content == 'TEST':
            await client.process_commands('Test Succesfull')```
sick birch
#

That line should be inside the on_message w/o any nesting

slate swan
#

wrong, process commands take a Message arg, not a string

keen mural
#
sql_params = {
          'userid': interaction.guild.id,
          'member': interaction.user.id
          }
        cur.execute("SELECT Alive FROM Battle WHERE Guild = :userid, User = :member", sql_params)
```they arent allowing the , in the SELECT statement :(
sick birch
#
@client.event
async def on_message(message):
  ...
  # indent here is important
  await client.process_commands(message)

OR

@client.listen() # notice it's listen instead of event?
async def on_message(message):
  ...
  # no need to process commands here
slate swan
keen mural
#

ok thanks

slate swan
#

select * from table where condition1 and condition2

keen mural
#

😄

sick birch
# slate swan ?

I'm providing 2 possible solutions. One is you have to use process_commands, another is you don't. You pick

slate swan
slate swan
#

This is the thing I get in the output in VS Code

#

AttributeError: 'Client' object has no attribute 'listen'

sick birch
#

Well

#

I was thinking you were using commands.Bot instead of discord.Client

#

because most people call a "bot" a "client" for some reason (probably those youtube tutorials)

slate swan
#

yes

#

the tutorials

sick birch
#

I hate them

#

Always the terrible advice...

#

Anyway, you should be using commands.Bot instead of discord.Client

slate swan
#
from asyncore import loop
from multiprocessing.connection import wait
import discord
import time


client = discord.Client()


@client.event
async def on_ready():
    # This is what the bot will do
    garrylogs_channel = client.get_channel(980638552280944662)

    await garrylogs_channel.send('Gary has launched')

@client.event()
async def on_message(message):
    if message.author.id == 625025751413948436:
        if message.content == 'TEST':
            await client.process_commands('Test Succesfull')
        await client.process_commands(message)
        


# Run the bot
client.run('token')```
sick birch
#

Whoa whoa too much stuff in on_ready

#

FYI you shouldn't be doing anything in on_ready except maybe print()ing

slate swan
#

so what should I edit?

sick birch
#

Replace discord.Client with commands.Bot(...) and also add these imports:

from discord.ext import commands
slate swan
#
client = commands.Bot()``` error
sick birch
#

So,

import discord
from discord.ext import commands
# any other imports you may have

bot = commands.Bot(...) # refer to the documentation for appropriate arguments

@bot.event
async def on_ready():
  print("Ready!") # this is all you should do in on_ready. Check the docs for why

@bot.listen()
async def on_message(message):
  # handle message here, don't worry about process_commands

bot.run(...)
#

!d discord.ext.commands.Bot

unkempt canyonBOT
#

class discord.ext.commands.Bot(command_prefix, *, help_command=<default-help-command>, tree_cls=<class 'discord.app_commands.tree.CommandTree'>, description=None, intents, **options)```
Represents a discord bot.

This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") you can do with this bot.

This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.

Unlike [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client"), This class does not require manually setting a [`CommandTree`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.CommandTree "discord.app_commands.CommandTree") and is automatically set upon instantiating the class.
sick birch
#

^ the documentation on what arguments to pass into commands.Bot

slate swan
#

i dont understand a thing

sick birch
#

What are you not understanding?

slate swan
#
C:\Users\Clicks\Desktop\Clicks' Personal Bot\bot.py:1: DeprecationWarning: The asyncore module is deprecated and will be removed in Python 3.12. The recommended replacement is asyncio
  from asyncore import loop
Traceback (most recent call last):
  File "c:\Users\Clicks\Desktop\Clicks' Personal Bot\bot.py", line 13, in <module>
    bot = commands.Bot() # refer to the documentation for appropriate arguments
TypeError: BotBase.__init__() missing 1 required positional argument: 'command_prefix```
#

heh, what

#

this is what I have down:

from asyncore import loop
from multiprocessing.connection import wait
from discord.ext import commands
import discord
import time


client = commands.Bot(command_prefix='g!')


# any other imports you may have

bot = commands.Bot(command_prefix='g!') # refer to the documentation for appropriate arguments

@bot.event
async def on_ready():
  print("Ready!") # this is all you should do in on_ready. Check the docs for why

@bot.listen()
async def on_message(message):
    if message.content == 'Test':
        general_channel = client.get_channel(980551403351191595)
        await general_channel.send('Test Succesfull')
  # handle message here, don't worry about process_commands
#

wait nvm

#

@sick birch py Ignoring exception in on_message Traceback (most recent call last): File "C:\Users\Clicks\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event await coro(*args, **kwargs) File "c:\Users\Clicks\Desktop\Clicks' Personal Bot\bot.py", line 23, in on_message await general_channel.send('Test Succesfull') AttributeError: 'NoneType' object has no attribute 'send'

#

what???

magic pond
#

how to make my bot get the emoji url ?

slate swan
unkempt canyonBOT
slate swan
flint isle
#
        if isinstance(error, disnake.ext.commands.MissingRequiredArgument):
            embed = disnake.Embed()
            embed.title = f'Error'
            embed.add_field(name='Error Location', value=f'`{ctx.command}`', inline=False)
            embed.description = f'A missing argument was missing in {ctx.command}. Please run the command again but including the missing argument'
            embed.add_field(name='Type of Error', value=f'`Missing argument: {error.param}`', inline=False)
            embed.add_field(name='Correct Usage', value=f"`{ctx.command.name} {ctx.args}`", inline=False)
            embed.set_footer(text='An Exception has occured ... Details Above.')
            await ctx.send(embed=embed)
            return
``` how can i get the command and its arguments in the embed like
`$heh {nerdz} {nerdz2}`
slate swan
#

!d discord.ext.commands.Command.usage should do iirc

unkempt canyonBOT
flint isle
# slate swan !d discord.ext.commands.Command.usage should do iirc
Traceback (most recent call last):
  File "C:\Users\Andy\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\client.py", line 612, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\Andy\PycharmProjects\WhiskeyBotMain\cogs\CommandErrorHandler.py", line 61, in on_command_error
    embed.add_field(name='Correct Usage', value=f"`{disnake.ext.commands.Command.usage}`", inline=False)
AttributeError: type object 'Command' has no attribute 'usage'

        if isinstance(error, disnake.ext.commands.MissingRequiredArgument):
            embed = disnake.Embed()
            embed.title = f'Error'
            embed.add_field(name='Error Location', value=f'`{ctx.command}`', inline=False)
            embed.description = f'A missing argument was missing in {ctx.command}. Please run the command again but including the missing argument'
            embed.add_field(name='Type of Error', value=f'`Missing argument: {error.param}`', inline=False)
            embed.add_field(name='Correct Usage', value=f"`{disnake.ext.commands.Command.usage}`", inline=False)
            embed.set_footer(text='An Exception has occured ... Details Above.')
            await ctx.send(embed=embed)
            return```
slate swan
#

no-

#

instead, ctx.command.usage

flint isle
#

oh oops

flint isle
slate swan
#

uhhh nvm, wrong property then

unreal stratus
#

would anyone be able to help me with discord api. #help-chili using .to_dict()

slate swan
#

that'll return an output like it does for the default help

flint isle
#

Correct Usage
<nerdz> <nerdz2>

#

how can i add the $heh

slate swan
#
  File "c:\Users\Clicks\Desktop\Clicks' Personal Bot\bot.py", line 8, in <module>
    client = commands.bot(command_prefix = 'g!')
TypeError: 'module' object is not callable
#

???

flint isle
slate swan
visual island
flint isle
shrewd apex
#

gn

slate swan
#

good night lol, imma sleep too

shrewd apex
#

gn sweet dreams

magic pond
#
    @commands.command(aliases=['WIKI', 'wiki', 'WIKIPEDIA'])
    async def wikipedia(ctx, *, query: str):
      sea = requests.get(
        ('https://en.wikipedia.org//w/api.php?action=query'
         '&format=json&list=search&utf8=1&srsearch={}&srlimit=5&srprop=').format(query)).json()['query']
      if sea['searchinfo']['totalhits'] == 0:
        await ctx.reply('Sorry, your search could not be found.')
      else:
        for x in range(len(sea['search'])):
          article = sea['search'][x]['title']
          req = requests.get(
            'https://en.wikipedia.org//w/api.php?action=query'
            '&utf8=1&redirects&format=json&prop=info|images'
            '&inprop=url&titles={}'.format(
              article)).json()['query']['pages']
          if str(list(req)[0]) != "-1":
            break
          else:
            await ctx.reply('Sorry, your search could not be found.')
            return
            article = req[list(req)[0]]['title']
            arturl = req[list(req)[0]]['fullurl']
            artdesc = requests.get(
            'https://en.wikipedia.org/api/rest_v1/page/summary/'
            + article).json()['extract']
            lastedited = datetime.strptime(req[list(req)[0]]['touched'],"%Y-%m-%dT%H:%M:%SZ")
            embed = discord.Embed(title='**' + article + '**',
                                  url=arturl,
                                  description=artdesc,
                                  color=0x3FCAFF)
            embed.set_footer(text='Wiki entry last modified',
                             icon_url=
                            
#
'https://upload.wikimedia.org/wikipedia/commons/6/63/Wikipedia-logo.png')
            embed.set_author(name='Wikipedia',
                             url='https://en.wikipedia.org/',
                             icon_url=
                             'https://upload.wikimedia.org/wikipedia/commons/6/63/Wikipedia-logo.png')
            embed.timestamp = lastedited
            await ctx.reply('**Search result for:** ***"{}"***:'.format(query),embed=embed)
#
Traceback (most recent call last):
  File "/home/runner/mv/venv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 1329, in invoke
    await ctx.command.invoke(ctx)
  File "/home/runner/mv/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 995, in invoke
    await injected(*ctx.args, **ctx.kwargs)  # type: ignore
  File "/home/runner/mv/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 209, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: wikipedia() takes 1 positional argument but 2 were given
```
visual island
#

!paste | Use this to post long code, so you don't flood the channel

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

slate swan
#

shouldnt use requests and format and the error quite says it all and you should use dict.get

visual island
slate swan
#

good eye cirno

visual island
slate swan
hollow zealot
#

if u can set webhooks avatar by webhook.avatar_url
how do u set a name?

unkempt canyonBOT
#

Hey @slate swan!

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

slate swan
#

what

#

@slate swan

slate swan
#

hmm

#

lemme see

#

this is the fourth time getting a random ping in the last 3 hours

#

and I swear 3 went down as ghost pings

shrewd apex
#

not quailified

slate swan
#

?

shrewd apex
#

Command raised an exception: AttributeError: 'Command' object has no attribute 'quailified_name

#

...

stray carbon
#

i want to use postgresql in my bot but...

maiden fable
#

Rip

stray carbon
#

What could be reason?

#

Can't it be fixed 😭

stone beacon
keen mural
#

do i need 2 values for embed.add_field

maiden fable
#

Yes

shrewd apex
stray carbon
maiden fable
#

@stray carbon can u show the screenshot of last few error lines?

nimble plume
#

help

nimble plume
#

ctx.guild.icon.url return none

#

there is no icon

stray carbon
#

oh :/

nimble plume
#

icon is none

#

how can i

#

disnake

#

embed.set_author(name=f"{ctx.guild.name}", icon_url=f"{ctx.guild.icon.url or }")

stray carbon
#
...
  - CommonProgramFiles: C:\Program Files\Common Files
  - CommonProgramFiles(x86): C:\Program Files (x86)\Common Files
  - CommonProgramW6432: C:\Program Files\Common Files
  - COMPUTERNAME: AKAI-PC
  - ComSpec: C:\Windows\system32\cmd.exe
  - FP_NO_HOST_CHECK: NO
  - HOMEDRIVE: C:
  - HOMEPATH: \Users\Akai
  - LOCALAPPDATA: C:\Users\Akai\AppData\Local
  - LOGONSERVER: \\AKAI-PC
  - NUMBER_OF_PROCESSORS: 1
  - OS: Windows_NT
  - Path: C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Git\cmd;C:\Program Files\nodejs\;C:\Program Files\PostgreSQL\14\bin;C:\Program Files\MySQL\MySQL Shell 8.0\bin\;C:\Users\Akai\AppData\Local\Programs\Python\Python38\Scripts\;C:\Users\Akai\AppData\Local\Programs\Python\Python38\;C:\Users\Akai\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\Akai\AppData\Roaming\npm;C:\Program Files\PostgreSQL\14\bin
  - PATHEXT: .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
  - PGADMIN_INT_KEY: 0ef79d60-9947-4d19-aae3-c6b4553e50a9
  - PGADMIN_INT_PORT: 59854
  - PGADMIN_SERVER_MODE: OFF
  - PROCESSOR_ARCHITECTURE: AMD64
  - PROCESSOR_IDENTIFIER: AMD64 Family 16 Model 6 Stepping 3, AuthenticAMD
  - PROCESSOR_LEVEL: 16
  - PROCESSOR_REVISION: 0603
  - ProgramData: C:\ProgramData
  - ProgramFiles: C:\Program Files
  - ProgramFiles(x86): C:\Program Files (x86)
  - ProgramW6432: C:\Program Files
  - PSModulePath: C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
  - PUBLIC: C:\Users\Public
  - SESSIONNAME: Console
  - SystemDrive: C:
  - SystemRoot: C:\Windows
  - TEMP: C:\Users\Akai\AppData\Local\Temp
  - TMP: C:\Users\Akai\AppData\Local\Temp
  - USERDOMAIN: Akai-PC
  - USERNAME: Akai
  - USERPROFILE: C:\Users\Akai
  - windir: C:\Windows
  - windows_tracing_flags: 3
  - windows_tracing_logfile: C:\BVTBin\Tests\installpackage\csilogfile.log
--------------------------------------------------------
#

Here's the error

nimble plume
#

help me pls

#
 embed.set_author(name=f"{ctx.guild.name}", icon_url=f"{ctx.guild.icon.url or }")
shrewd apex
#

ctx.guild.icon.url if ctx.guild.icon.url else 'default url'

shrewd apex
stray carbon
stray carbon
# stray carbon

` - CHROME_CRASHPAD_PIPE_NAME: \.\pipe\crashpad_5168_DXRMCXVUBFYXQPEC

  • CHROME_RESTART: NW.js|Whoa! NW.js has crashed. Relaunch now?|LEFT_TO_RIGHT`
    Maybe the error was here?
maiden fable
#

Try searching online

nimble plume
#

pls help me

#
 embed.set_author(name=f"{ctx.guild.name}", icon_url=f"{ctx.guild.icon.url}")
#

icon return none

#

what do i do

stray carbon
#

Maybe smth here?

vital glacier
#

With a SQL database, how do I make it so if I mention my bot it'll return the prefix of the server it is mentioned in?

maiden fable
unkempt canyonBOT
#

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

Retrieves the prefix the bot is listening to with the message as a context.

Changed in version 2.0: `message` parameter is now positional-only.
hidden snow
#

hey how do u copy a channel id, i looked it up on google and it doesnt show copy id

keen mural
#

with discord.ui how do i make buttons never time out

keen mural
hidden snow
#

oh ty

slate swan
#

why when i try getting fetched user pfp i get this error

Command raised an exception: AttributeError: 'str' object has no attribute 'url'

I didn't change anything from code that was working

A.K.A. this

author_user = await self.client.fetch_user(ctx.author.id)
embed.set_author(name = author_user.name, icon_url=author_user.avatar.url)
maiden fable
#

also can u print ctx.author.avatar once?

slate swan
slate swan
#

i know

#

yep yep yep

maiden fable
#

discord.Member has all the attrs discord.User has

slate swan
#

ofc its a subclass of User

#

hunter's smorf

#

very

maiden fable
#

Not a direct subclass, but they subclass the common class

slate swan
#

smart

maiden fable
slate swan
#

why are you making a string a string lol

#

it returns a string already lol

#

and Asset.url does as well

slate swan
#

ash go to sleep

maiden fable
slate swan
slate swan
#

🙂

slate swan
#

oh no

maiden fable
#

I didn't

slate swan
slate swan
#

Command raised an exception: AttributeError: 'str' object has no attribute 'url'

#

wait

#

now here is no error about this

#

now i got this

#

Command raised an exception: TypeError: send() got an unexpected keyword argument 'custom_id'

#

i think it is connected to this line of code

#
chose = await ctx.send(embed=embed, components = button_table, custom_id = 'SelectUnban')
#

nevermind i got it in wrong place

vale wing
#

No need to cast str to str bruh

#

@slate swan what library do you have (with version)

slate swan
#

and got another error

vale wing
#

Oh god

slate swan
#

Command raised an exception: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In components.0.components.0.options.2: The specified option value is already used

vale wing
#

Or disnake or nextcord

#

Discord-components is outdated

#

And very inconvenient to use

slate swan
#

I was following tutorial

vale wing
#

What kind of tutorial

slate swan
# vale wing What kind of tutorial

I could not find a good video that explained select menus in python from the beginning to the end so I made this video to hopefully help people. If you have any questions feel free to ask. I am using VS Code as my IDE for this project.

pip install discord-components

View the code:
https://github.com/erobin27/Tutorials/blob/main/DiscordYT/Selec...

▶ Play video
vale wing
#

That guy couldn't find a good video but I know a good guide

slate swan
#

Can you show me what guide it is?

silk fulcrum
#

Aren't utub tutorials bad?

vale wing
#

I am creating a tutorial on github and will put it on site later

silk fulcrum
#

gud

vale wing
slate swan
silk fulcrum
#

those 20% are who reading the docs

vale wing
#

And actually have looked into pep at least once

silk fulcrum
#

xD

silk fulcrum
vale wing
#

For buttons

silk fulcrum
#

Item = Button / Select Menu / TextInput

vale wing
#

Search for other stuff in the examples folder

#

There are plenty of them

silk fulcrum
vale wing
#

Yes

#

I just recommend disnake cause I don't like dpy slash commands and asynchronous cogs/extensions working maybe that's subjective but still

silk fulcrum
#

dpy has slash commands? 😳

vale wing
#

2.0 does

silk fulcrum
#

I missed something

vale wing
#

Yeah but imho their implementation is not user friendly

#

I have no idea wtf for do they subclass Client everywhere tho it's considered a bad practice but that's their business

#

There are gists that describe proper implementation but I don't have links to them

silk fulcrum
#

i dont care about anything, im just happy cus now i can write slash commands on dpy without any problems

#

yey

vale wing
#

K

#

The only problem might be to understand how that thing works

silk fulcrum
#

i tried js and just nothing worked lol

vale wing
#

Disnake has easier slash commands implementation

silk fulcrum
#

only thing i dont like about dpy is that they IP banned me from their server for spamming, i think forever, cus already 5 or more months passed

vale wing
#

With no cogs you just use

@bot.slash_command()
async def nicecmd(inter):
    await inter.send("Hi")

And with cogs it's just like prefix commands but with @commands.slash_command deco

silk fulcrum
#

(also i was spamming in thread called "spam" or smth like this)

vale wing
#

In dpy there's also tree syncing or smth and you gotta load extensions and add cogs asynchronously, I don't like adding all those structures every time I make a bot

silk fulcrum
#

very hard

#

xD

slate swan
# silk fulcrum almost same as dpy?

no, dpy's basic syntax for slashes is like

from discord import app_commands
from discord.ext import commands
import discord

class MyBot(commands.Bot):
  def __init__(self):
    self.test_guild = 1234567890 #replace your guild's id here
    super().__init__(command_prefix="uwu", intents=discord.Intents.default())
  
  async def setup_hook(self):
    self.tree.copy_global_to(guild=self.test_guild)
    await self.tree.sync(guild=self.test_guild)

bot = MyBot()
tree = bot.tree

@tree.command()
async def ping(interaction: discord.Interaction):
    await interaction.response.send_message("Pong!")

bot.run("token")
vale wing
#

And what's not working?

slate swan
#

@vale wing this

vale wing
#

And what the error is

silk fulcrum
#

wait wtf is value=

vale wing
#

A kwarg

silk fulcrum
#

here was correct

#

description

vale wing
#

Ah yes

placid skiff
#

Bruh in embeds fields have a value kwarg

slate swan
#

There

vale wing
#

Ah yes

silk fulcrum
#

a

vale wing
#

Why do you have empty title

silk fulcrum
#

h oh

vale wing
#

Just don't provide the kwarg at all

placid skiff
#

maybe he wants to add the spaces, but it will not work like this

vale wing
#

I see nothing wrong besides that with your code, just stop using replit for bots

placid skiff
#

you'll need an invisible char to set a title or the name of a field to have an empty space in the embed

tough bobcat
#

sorry to interrupt
trying to edit a message that I have previously sent
using await msg.edit(f"edit test")
getting the error: edit() takes 1 positional argument but 2 were given

vale wing
#

content="edit test"

tough bobcat
#

ty

vale wing
#

And avoid f-strings without actual values inside of them

#

f-string without interpolation is a violation of code style

tough bobcat
#

yeah somethings there
i just removed it for sending here oops

placid skiff
#

Python police will arrest you otherwise

tough bobcat
silk fulcrum
vale wing
#

I remember how one dude used to cast objects to str

a = 69
str_a = f"{a}"
tough bobcat
#

heheheheh

silk fulcrum
vale wing
#

😳

#

Are you that one dude

silk fulcrum
tough bobcat
silk fulcrum
#

@strong ibex where is my nitro give it back plss

vale wing
#
a = 69
str_a = str(a)```
is a proper method tho I hope you were kidding
vale wing
silk fulcrum
#

I hope you understood that by :lemao:

silk fulcrum
tough bobcat
#

ty

silk fulcrum
#

8!!!!!

vale wing
#

!pep 8

unkempt canyonBOT
#
**PEP 8 - Style Guide for Python Code**
Status

Active

Created

05-Jul-2001

Type

Process

tough bobcat
#

A Foolish Consistency is the Hobgoblin of Little Minds
this will be a fun read

#

bye all

vale wing
#

Definitely

#

Cya

silk fulcrum
#

bye

robust fulcrum
#

Guys what is use of bot.listen()
?

silk fulcrum
#

it's a listener

#

there are different types

#

it's like when something happens it does something

#

so on_message listener does smth everytime when someone send a message and bot see it

placid skiff
#

They are used to handle events, but unlike the @event decorator which can handle only one coroutine (the first one resolved) @listen and @listeners can resolve more than 1 coroutine

robust fulcrum
placid skiff
#

Yup, you got the point

robust fulcrum
#

Can you give me one example?

#

Cause Google not send good examples

silk fulcrum
#

google is not good for this

robust fulcrum
#

Ye

#

So i asking here

silk fulcrum
#

but im not sure from these examples you can clearly understand ||(BlvckTvrsier is typing)||

wild oxide
#

Traceback (most recent call last): File "main.py", line 5, in <module> bot = discord.ext.commands.Bot(intents=discord.Intents.all()) TypeError: __init__() missing 1 required positional argument: 'command_prefix'

silk fulcrum
placid skiff
#
@bot.event
  async def on_message(message):
    print("Hey")

@bot.event
  async def on_message(message):
    print("Hi")

in the above case, only "Hey" will be printed in the console

@bot.listen("on_message")
async def my_message(message):
    print("Hey")

@bot.listen()
async def on_message(message):
    print("Hi")

in this case instead. both "Hey" and "Hi" will be printed in the console

slate swan
#

Is it still worth it to make a discord bot?

#

Are people still interested that much?

wild oxide
silk fulcrum
placid skiff
#

You will need to declare a prefix anyways

silk fulcrum
#

^ ↓

placid skiff
#

is a required argument

wild oxide
placid skiff
#

The prefix can be wathever you want, slash command prefix doesn't change

slate swan
#

@wild oxide make an application bot.

#
  Could not find a matching version of package client

  at /opt/virtualenvs/python3/lib/python3.8/site-packages/poetry/console/commands/init.py:367 in _find_best_version_for_package
      363│         )
      364365if not package:
      366# TODO: find similar367raise ValueError(
      368"Could not find a matching version of package {}".format(name)
      369│             )
      370371return package.pretty_name, selector.find_recommended_require_version(package)
exit status 1
#

Do:

bot = commands.ApplicationBot
silk fulcrum
wild oxide
robust fulcrum
#

Can anyone help me how ca we make button interaction?

silk fulcrum
placid skiff
#

It isn't a thing in fact D_D

silk fulcrum
#

uhm, i dont think this is it, you have error related to some client that is nor finding a matching version

silk fulcrum
#

i mean that's code not related to an error

#

or that's all code you have in your bot?

slate swan
#

nope

slate swan
#

I thought you are using disnake.

silk fulcrum
#

lol

slate swan
#

NVM idk about discord disnake is just easier.

placid skiff
slate swan
#

There is.

silk fulcrum
#

lol

slate swan
#

I used it.

placid skiff
#

You were drunk probably D_D

silk fulcrum
#

i found two of these words

#

im genius

wild oxide
#

Traceback (most recent call last):
File "main.py", line 6, in <module>
bot = discord.ext.commands.Bot(intents=discord.Intents.all())
TypeError: init() missing 1 required positional argument: 'command_prefix'

slate swan
#

Yes

#

This is it.

placid skiff
#

!d disnake.ApplicationCommandInteraction.bot

unkempt canyonBOT
#

property bot```
The bot handling the interaction.

Only applicable when used with [`Bot`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.Bot "disnake.ext.commands.Bot"). This is an alias for [`client`](https://docs.disnake.dev/en/latest/api.html#disnake.ApplicationCommandInteraction.client "disnake.ApplicationCommandInteraction.client").
silk fulcrum
silk fulcrum
#

Class requires the parameter

silk fulcrum
#

not as the var outside it :D_D:

silk fulcrum
#

i wrote commands_prefix

#

it is without s

#

if you copied

placid skiff
#

!d disnake.ext.commands.InteractionBot this one allows only slash commands D_D

unkempt canyonBOT
#

class disnake.ext.commands.InteractionBot(*, sync_commands=True, sync_commands_debug=False, sync_commands_on_cog_unload=True, test_guilds=None, **options)```
Represents a discord bot for application commands only.

This class is a subclass of [`disnake.Client`](https://docs.disnake.dev/en/latest/api.html#disnake.Client "disnake.Client") and as a result anything that you can do with a [`disnake.Client`](https://docs.disnake.dev/en/latest/api.html#disnake.Client "disnake.Client") you can do with this bot.

This class also subclasses InteractionBotBase to provide the functionality to manage application commands.
wild oxide
#

Traceback (most recent call last):
File "main.py", line 5, in <module>
bot = discord.ext.command.Bot(commands_prefix='$', intents=discord.Intents.all())
AttributeError: module 'discord.ext' has no attribute 'command'

silk fulcrum
#

not in commands.Bot

#

bot = discord.ext.commands.Bot(command_prefix='$', intents=discord.Intents.all())

#

just bruh

wild oxide
#

File "main.py", line 113, in <module>
@bot.slash_command(guild_ids=[settings["guildID"]], name="whitelist", description="Whitelist a person to use the bot.")
AttributeError: 'Bot' object has no attribute 'slash_command
i told my bot use slash cmds

silk fulcrum
#

that's not how you use slash_commands in dpy

slate swan
placid skiff
#

Don't give him weird ideas

slate swan
silk fulcrum
#

yeah, Bot > Client

silk fulcrum
placid skiff
#

what?

silk fulcrum
#

i mean wdym

placid skiff
#

i was answering to ash

slate swan
#

I didn't even ask anything....

silk fulcrum
#

oh kay

paper sluice
silk fulcrum
paper sluice
#
    bot = discord.ext.commands.Bot()
AttributeError: module 'discord' has no attribute 'ext'
warped mirage
#

Guys can someone help me work on my welcoming system or nah

paper sluice
#

ext is a dir, discord is a module

#

so it looks for a object named ext in the file

silk fulcrum
#

oh yeah

#

maybe then he imported discord.ext.commands

#

or even with .Bot

silk fulcrum
robust fulcrum
#

Guys i have a python code of sending pie chart can anyone help me to convert to command in discord.py pls


from matplotlib import pyplot as plt

import numpy as np
 
 
cars = ['AUDI', 'BMW', 'FORD',

        'TESLA', 'JAGUAR', 'MERCEDES']
 

data = [23, 17, 35, 29, 12, 41]
 

fig = plt.figure(figsize =(10, 7))

plt.pie(data, labels = cars)
 
plt.show()
paper sluice
robust fulcrum
#

Can you tell me do i need to remove plt.show?

paper sluice
#

plt.savefig('<name of file>.png') ig

robust fulcrum
paper sluice
#

i dont think so

robust fulcrum
#

Ok

paper sluice
#

but if u r using it with a bot, u probably dont want random plots popping up while ur bot is running. so just save and send

robust fulcrum
#

It worked thak u

robust fulcrum
warped mirage
#

ValueError: invalid literal for int() with base 10: '10s'

The above exception was the direct cause of the following exception: guys how do i fix

#
@client.command(aliases=["slowmo", "sm"])
async def slowmode(ctx,time:int):
        if (not ctx.author.guild_permissions.manage_messages):
            await ctx.send('This command requires ``Manage Messages``')
            return
        try:
            if time == 0:
                await ctx.send('Slowmode turned off')
                await ctx.channel.edit(slowmode_delay = 0)
            elif time > 21600:
                await ctx.send('You cannot set the slowmode above 6 hours!')
                return
            else:
                await ctx.channel.edit(slowmode_delay = time)
                await ctx.send(f'Slowmode set to {time} seconds!')
        except Exception:
            print('Hmmmm..')``` code
silk fulcrum
#

so you typed ?slowmode 10s right?

warped mirage
silk fulcrum
#

show full traceback pls

warped mirage
#
Ignoring exception in command None:
discord.ext.commands.errors.CommandNotFound: Command "slow" is not found
Ignoring exception in command slowmode:
Traceback (most recent call last):
  File "C:\Users\Dom\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\converter.py", line 1188, in _actual_conversion
    return converter(argument)
ValueError: invalid literal for int() with base 10: '10s'

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

Traceback (most recent call last):
  File "C:\Users\Dom\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 1329, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\Dom\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 987, in invoke
    await self.prepare(ctx)
  File "C:\Users\Dom\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 904, in prepare
    await self._parse_arguments(ctx)
  File "C:\Users\Dom\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 811, in _parse_arguments
    transformed = await self.transform(ctx, param, attachments)
  File "C:\Users\Dom\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 681, in transform
    return await run_converters(ctx, converter, argument, param)  # type: ignore
  File "C:\Users\Dom\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\converter.py", line 1297, in run_converters
    return await _actual_conversion(ctx, converter, argument, param)
  File "C:\Users\Dom\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\converter.py", line 1197, in _actual_conversion
    raise BadArgument(f'Converting to "{name}" failed for parameter "{param.name}".') from exc
discord.ext.commands.errors.BadArgument: Converting to "int" failed for parameter "time".```
silk fulcrum
#

no, you typed something wrong, cus it says that it could not convert time to int

warped mirage
#

well i showed code , idk

silk fulcrum
#

im about command

#

probably you used {prefix}slowmode 10s

warped mirage
carmine hearth
#

sus

loud junco
#

=.=

slate swan
carmine hearth
slate swan
carmine hearth
#

sssssssssuuuuuuuuuuuussssssssssss

loud junco
#

slowmode settings =.=

carmine hearth
#

ok:)

#

guys do u like cactus?

slate swan
loud junco
slate swan
#

one of you telling them that the question is OT, was ENOUGH

worn folio
#

Hi Everyone! I am trying to get the daily discord total members, new members joined on a server and then store in the db for historical info. Can anyone please confirm how can i do that? I am a moderator on this server and i am totally new.

#

i am following some online resources but i am going no where, if you know some resources. please help! thank you

unkempt canyonBOT
#

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

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

this is for new member joining

#

!d discord.on_member_remove

unkempt canyonBOT
#

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

If the guild or member could not be found in the internal cache this event will not be called, you may use [`on_raw_member_remove()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_raw_member_remove "discord.on_raw_member_remove") instead.

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

this is for member leaving

#

not sure about total member

silk fulcrum
unkempt canyonBOT
#

property member_count```
Returns the member count if available.

Warning

Due to a Discord limitation, in order for this attribute to remain up-to-date and accurate, it requires [`Intents.members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.members "discord.Intents.members") to be specified.

Changed in version 2.0: Now returns an `Optional[int]`.
worn folio
#

alright, thank you : ) and if i want to get the counts of daily communicator, how can i do that?

silk fulcrum
#

wdym daily communicator?
If you want to save member count of server every day then you can store it in DB or JSON

worn folio
#

a member who talked

slate swan
slate swan
worn folio
#

is there any way to scrape the info from server insight?

maiden fable
unkempt canyonBOT
maiden fable
#

Be vary that it's blocking and u will have to use asyncio.loop.run_in_executor

worn folio
#

okay thank you

maiden fable
#

!d asyncio.loop.run_in_executor

unkempt canyonBOT
#

awaitable loop.run_in_executor(executor, func, *args)```
Arrange for *func* to be called in the specified executor.

The *executor* argument should be an [`concurrent.futures.Executor`](https://docs.python.org/3/library/concurrent.futures.html#concurrent.futures.Executor "concurrent.futures.Executor") instance. The default executor is used if *executor* is `None`.

Example:
carmine hearth
#

how to make kick command?

maiden fable
#

!d discord.Guild.kick

unkempt canyonBOT
#

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

Kicks a user from the guild.

The user must meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.

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

!d discord.Member.kick

unkempt canyonBOT
#

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

Kicks this member. Equivalent to [`Guild.kick()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.kick "discord.Guild.kick").
maiden fable
#

@carmine hearth

cloud dawn
# unkempt canyon

Using this plus snowflake would be the most elegant solution. Less resources.

warped mirage
#

Yo @maiden fable

#

How u doing .

terse blade
#

How tf do you add a discord bot now

#

like it jst dosent give a link

carmine hearth
#

oh

terse blade
#

liek bro i dont have one of these

dapper tendon
#

why this error ?

silk fulcrum
#

because bot has no attr slash command

cloud dawn
dapper tendon
terse blade
silk fulcrum
cloud dawn
silk fulcrum
terse blade
#

it dont work monkey

#

i fixed it anyways

cloud dawn
dapper tendon
cloud dawn
silk fulcrum
dapper tendon
silk fulcrum
#

you need to install it from github

slate swan
dapper tendon
silk fulcrum
#

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

maiden fable
# dapper tendon

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

silk fulcrum
#

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

maiden fable
#

Install git

silk fulcrum
slate swan
#

/downloads *

silk fulcrum
#

oh maybe it is not linux

#

yeah... sry

maiden fable
#

It's windows

#

There's winget but don't install Python with it (idk about git)

cloud dawn
#

I've never needed to explain it before...

silk fulcrum
#

that's why people feel clueless

#

because they dont understand how is panda looking simple to monkey

maiden fable
#

Might as well drop this convo now

dapper tendon
#

@silk fulcrum

cloud dawn
#

I honestly thought he was still going on about it not being linux 😂

cloud dawn
unkempt canyonBOT
#

class discord.Intents(value=0, **kwargs)```
Wraps up a Discord gateway intent flag.

Similar to [`Permissions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions "discord.Permissions"), the properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools.

To construct an object you can pass keyword arguments denoting the flags to enable or disable.

This is used to disable certain gateway features that are unnecessary to run your bot. To make use of this, it is passed to the `intents` keyword argument of [`Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client").

New in version 1.5.
slate swan
#

I just finished^ a python course by CS50, so am I eligible to start making bots now or am I not?

cloud dawn
maiden fable
#

Huh?

cloud dawn
slate swan
#

for being a novice

warped mirage
#

Hi hunter

cloud dawn
maiden fable
silk fulcrum
maiden fable
# warped mirage Hi hunter

Please don't depend on me to ask yr problem please. Just ask the question and any person online, wil help you

slate swan
maiden fable
#

I'm on and off nowadays and u won't be able to finish ur bot if u depend on me

silk fulcrum
warped mirage
#

I don’t depend

silk fulcrum
warped mirage
#

Anyways , I need help fixing 2 commands , coding 2 commands

cloud dawn
#

dpy servers gonna eat him raw

maiden fable
#

Agreed

silk fulcrum
#

oof

maiden fable
#

@slate swan I would prefer u ask the questions here tbh

#

Cz, uhh, reasons

silk fulcrum
#

yeah, good people from dpy are also here

#

bad people from dpy are on dpy

#

oh wait what?

warped mirage
#

Well um

#

I need to make 2 commands NWbruh

maiden fable
#

What... do u mean

silk fulcrum
#

go make 'em

warped mirage
#

….. ok

cloud dawn
#

I got a java problem.

maiden fable
silk fulcrum
#

this is python server tbh :lemao:

dapper tendon
warped mirage
#

!d how to code welcome message

cloud dawn
silk fulcrum
dapper tendon
mellow cloak
#

大家好

silk fulcrum
unkempt canyonBOT
#

class discord.ext.commands.Bot(command_prefix, *, help_command=<default-help-command>, tree_cls=<class 'discord.app_commands.tree.CommandTree'>, description=None, intents, **options)```
Represents a discord bot.

This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") you can do with this bot.

This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.

Unlike [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client"), This class does not require manually setting a [`CommandTree`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.CommandTree "discord.app_commands.CommandTree") and is automatically set upon instantiating the class.
cloud dawn
warped mirage
#

I need help making a set welcome message command

silk fulcrum
#

oof, every1 have probs with welcome

silk fulcrum
warped mirage
#

I legit asked

silk fulcrum
#

you mean you did nothing and want us to help?

warped mirage
cloud dawn
warped mirage
cloud dawn
#

Is it a welcome message event or welcome command?

warped mirage
cloud dawn
warped mirage
#

So I have a command that sets the welcome channel , then u can also delete it

#

And I want to set the welcome message with that channel like when someone joins

cloud dawn
silk fulcrum
mellow cloak
#

Everyone, I'm new here, please take care

warped mirage
silk fulcrum
warped mirage
#

I use aiosqlite if interested lol

mellow cloak
#

thanks

cloud dawn
silk fulcrum
warped mirage
#

I’ll show code rq ?

silk fulcrum
#

k

dapper tendon
# silk fulcrum ```py client = commands.Bot(command_prefix= '2') status = cycle(['MaDe By CHiVaz...

Traceback (most recent call last):
File "c:\Users\CHIVAZ\Desktop\botdiscord\main.py", line 74, in <module>
client.run("my token")
File "C:\Users\CHIVAZ\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 736, in run
asyncio.run(runner())
File "C:\Users\CHIVAZ\AppData\Local\Programs\Python\Python310\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\Users\CHIVAZ\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 646, in run_until_complete
return future.result()
File "C:\Users\CHIVAZ\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 733, in runner
await self.start(*args, **kwargs)
File "C:\Users\CHIVAZ\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 707, in start
await self.connect(reconnect=reconnect)
File "C:\Users\CHIVAZ\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 644, in connect
raise PrivilegedIntentsRequired(exc.shard_id) from None
discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead.
Exception ignored in: <function _ProactorBasePipeTransport.del at 0x0000023D1D87A200>
Traceback (most recent call last):
File "C:\Users\CHIVAZ\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 116, in del
self.close()
File "C:\Users\CHIVAZ\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 108, in close
self._loop.call_soon(self._call_connection_lost, None)
File "C:\Users\CHIVAZ\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 750, in call_soon
self._check_closed()
File "C:\Users\CHIVAZ\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 515, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Exception ignored in: <function _ProactorBasePipeTransport.del at 0x0000023D1D87A200>
Traceback (most recent call last):
File "C:\Users\CHIVAZ\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 116, in del
File "C:\Users\CHIVAZ\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 108, in close
File "C:\Users\CHIVAZ\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 750, in call_soon
File "C:\Users\CHIVAZ\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 515, in _check_closed
RuntimeError: Event loop is closed

Discord Developer Portal

Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.

cloud dawn
cloud dawn
# dapper tendon Traceback (most recent call last): File "c:\Users\CHIVAZ\Desktop\botdiscord\ma...

Please read the error before consulting. The issue is clearly stated "Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead."

Discord Developer Portal

Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.

silk fulcrum
warped mirage
silk fulcrum
#

select your bot -> bot -> these

cloud dawn
loud junco
#

can i reload my bot's cog without restarting the bot?
i saw someone talking about that before

warped mirage
#

I know u can do it for events for sure

cloud dawn
loud junco
#

my bot is now stopping forever :D

silk fulcrum
#

bruh wanted to say something about spoonfeeding but lost in thoughts

silk fulcrum
cloud dawn
unkempt canyonBOT
#

await reload_extension(name, *, package=None)```
Atomically reloads an extension.

This replaces the extension with the same extension, only refreshed. This is equivalent to a [`unload_extension()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.unload_extension "discord.ext.commands.Bot.unload_extension") followed by a [`load_extension()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.load_extension "discord.ext.commands.Bot.load_extension") except done in an atomic way. That is, if an operation fails mid-reload then the bot will roll-back to the prior working state.
loud junco
#

alright thanks

dapper tendon
loud junco
cloud dawn
dapper tendon
loud junco
silk fulcrum
#

bruh wanted to send some helpful link for MasterKnots but lost in thoughts after seeing his code

cloud dawn
austere yoke
#

Hi! Do you know if there is a ready-made bot for the lottery? Ticket issuance, leaderboard and ga based on number of tickets?

dapper tendon
warped mirage
silk fulcrum
#

or pip3

#

or python3 -m pip

#

or py -3 -m pip

#

or bruh im stupid

cloud dawn
austere yoke
loud junco
#

is this normal

cunning flicker
#

guys where to dowload python? which channel

dapper tendon
#

@silk fulcrum@cloud dawn

cunning flicker
#

!python

cunning flicker
#

nothing happened

loud junco
cunning flicker
#

ty

loud junco
#

np

cunning flicker
#

i have image logger and stuff

loud junco
#

just google python download tbh =.=

cunning flicker
#

but i need nuker

eager beacon
#

...

silk fulcrum
#

...

dapper tendon
loud junco
#

what on earth is going on

cloud dawn
loud junco
silk fulcrum
cunning flicker
vale wing
loud junco
dapper tendon
#

@silk fulcrum

silk fulcrum
#

this is how u do ^

vale wing
loud junco
#

its working already

#

dont ask how but it is working

vale wing
#

Ok

loud junco
#
@bot.command()
async def reload(ctx, arg):
  bot.reload_extension(arg)
  ctx.send('reloaded')  
#

will this work?

loud junco
#

ei

loud junco
#

what about this

cloud dawn
cloud dawn
silk fulcrum
#

ah

loud junco
silk fulcrum
dapper tendon
cloud dawn
loud junco
#

oo ya i forgot

paper sluice
loud junco
#

mb

silk fulcrum
loud junco
#
@bot.command()
async def reload(ctx, arg):
  await bot.reload_extension(arg)
  await ctx.send('reloaded')
cloud dawn
loud junco
#

like this?

cloud dawn
# loud junco like this?

If you use 2.0+ then yeah. But you do want to use seom try/except, you'll notice why pretty fast.

loud junco
#

alright

cloud dawn
#

To go around this I used to use get all the cog names and just put the relative path in front of the name.

#

So you only need to put in the cog name as arg.

dapper tendon
vale wing
#

How bots work or how programming works

cloud dawn
cloud dawn
vale wing
#

Works how it works 😃

loud junco
#

except ExtensionNotLoaded:?

cloud dawn
vale wing
loud junco
silk fulcrum
loud junco
#

:/
programming = 10% copy pasta for me

vale wing
#

Same

cloud dawn
loud junco
#

i only copt pasta some very specific or technical thing

vale wing
#

I only copypaste from my own projects

silk fulcrum
#

yeah

silk fulcrum
vale wing
#

Well sometimes I copypaste java code cause it's readable only in IDE 😩

silk fulcrum
#

lol

loud junco
#

what does this 2 means

#

what setup function

vale wing
#

All extensions must have setup function that adds cogs to the bot

loud junco
#

is it even possible to define this thing =.=

vale wing
unkempt canyonBOT
#

utils/bot.py lines 121 to 129

def auto_setup(self, module_name: str):
    module = sys.modules[module_name]
    members = inspect.getmembers(
        module, lambda x: inspect.isclass(x) and issubclass(x, commands.Cog)
    )
    for member in members:
        self.add_cog(member[1](self))

    self.log.ok("%s loaded", module_name)```
loud junco
#

bot.ExtensionNotLoaded or error.ExtensionNotLoaded??

vale wing
#

Nah it's discord.ExtensionNotLoaded I think

loud junco
#

alright

silk fulcrum
#

!d discord.ext.commands.ExtensionNotLoaded

unkempt canyonBOT
#

exception discord.ext.commands.ExtensionNotLoaded(name)```
An exception raised when an extension was not loaded.

This inherits from [`ExtensionError`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.ExtensionError "discord.ext.commands.ExtensionError")
loud junco
#

=.=

silk fulcrum
#

bruh

vale wing
#

Ok this

loud junco
#

its so long

#

discord.ext.commands.ExtensionNotLoaded?

cloud dawn
#

Cmon namespaces guys

vale wing
#

You could've pressed the link in docs tho

loud junco
#

what is namespace

silk fulcrum
#

i think

vale wing
# loud junco its so long

Nah it's

from discord.ext import commands

commands.ExtensionNotLoaded```
@silk fulcrum's method is valid too
loud junco
#

alright

vale wing
#

But you usually do import commands so it's more common

cloud dawn
silk fulcrum
#

has*

#

oh wait it's not find a mistake app

vale wing
#

In some languages it is just a folder with classes

vale wing
silk fulcrum
#

oh im even dumber

#

ok im outta here ||what ice cream will i choose today||

loud junco
#
from discord.ext import commands
import discord

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

prefixxx  = ['rpm ', 'Rpm ', 'RPM ', 'RPm ']
bot = commands.Bot(command_prefix = prefixxx, case_insensitive=True, activity=discord.Game(name="rpm start"),intents=intents)

class Reload(commands.Cog):
  def __init__(self, bot):
    self.bot = bot

  @commands.command()
  async def reload(self, ctx, arg):
    try:
      if ctx.author.id == 757508305256972338:
        await bot.reload_extension(arg)
        await ctx.send('reloaded')
      else:
        await ctx.send('shoo shoo go away')
    except commands.ExtensionNotLoaded:
      await ctx.send('cogs not loaded')
    except commands.ExtensionNotFound:
      await ctx.send('cogs not found')

def setup(bot):
    bot.add_cog(Reload(bot))
loud junco
slate swan
#

@loud junco what theme is that?

loud junco
#

what theme

slate swan
#

in the bottom image

#

your ide looks nice

vale wing
loud junco
#

what ide

#

im confused

loud junco
#

?

slate swan
#

what code editor do you use?

loud junco
#

replit

slate swan
#

oh bruh

loud junco
#

im ashamed to say this