#discord-bots
1 messages · Page 1072 of 1
property members```
Returns all the members with this role.
@slate swan thank u so much it all works but i have one more request but idk if u will agree
how to mention users who in list of this role?
Please stop mentioning me btw
But yeah you can ask questions, this is a help channel after all
You could individually mention but it’s better just to use role.mention
mybad please accept my apology
uh all g
g nice
i want to get all users with this role and mention each one in the message
!d discord.Role.members
property members```
Returns all the members with this role.
Then you can use member.mention on each member in role.members
i get a list of users, how should i mention them?
idk sorry...
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
You can get a list of mentions with list comprehension mentions = [member.mention for member in role.members and then use mentions = " ".join(members)
you just update the json file AND refresh the config when that command is invoked..
how do I do that?
show how you load in the config AND what your current set_prefix command looks like
show me how the member would update the command prefix
no i want it so if the owner updated the config file the bot doenst need to restart
you can just use the generator object for the join, if youre not gonna use the list and i would use map for the list comp and youre missing the closing brackets lol
with open("config.json") as f:
config = json.load(f)```
why would you do that manually? do it via a command ofc
Yeah I just thought it might be a bit simpler
fair tbh
yeah it is but a bit slow 😅
Yeah
how could I make it so if the member changes the prefix it changes it in the config file as well?
you write to that config file...
yes but how
can i mak eslash commands with python?
that's basic python, and that's also on google 😉
also, if your bot is in multiple guilds, please use a database instead
I would If i knew how lol
How are you doing " ".join(members)? Did you mean mentions?
I think it's also better if mentions as a generator is passed into .join()
yeah
yeah as said on top str.join accepts an iterable
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
discord.TextChannel
since most likely, you don't need categorychannels or voicechannels
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?
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'execute'``` guys how do i fix this
Provide code please, I can't tell much off the error itself
@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```
FYI: this is useless if data is not None:
what shall i do mr
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
start with fixing the cursor first, then move on (optimization) from there
^ keep it in mind though
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
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
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"
anyways can someone help me code a set welcome message command
@bot.event
async def on_guild_join(guild):
any_channel = guild.text_channels[0]
await any_channel.send("sup")```
for multiguild
yup
i guess i need to learn , i wanna make a command = set_msg welcome to serve {member.mention}
custom messages
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
could u help me make it
I'm quite busy, you'll just have to ask one question at a time here to keep on getting relevant / useful help
since this command is a step process
what shall i start with
the database setup
ok lets start with that
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
what should i type
bot.db =
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, ...
can u refer me to a documentation ima try learn
you'll probably want to use aiosqlite as a starter, an async wrapper of sqlite
it will be very hard tho
not if you know what you're looking for
ok
#databases is how to get started and what to look for
how can i edit a embeded field?
embed.fields[0].name = "shit"
how would I edit a embed after its been sent?
msg = await ctx.send(embed=embed)
embed.title = "shit"
await msg.edit(embed=embed)```
is it the same thing to edit a field?
msg = await ctx.send(embed=embed)
embed.fields[0].name= "shit"
await msg.edit(embed=embed)```
thank you, how would i remove a field?
do you look at the docs sometime? xd
!d discord.Embed.remove_field
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.
REPLIT NUKED MY SERVER
Repl.it can't nuke your server.
replit is public so any one can see your code and someone probably got your token
next time use a env
I PUT IT IN THE SCRIPT
in replit is it even possible to hide ur token without premium?
^ it doesnt
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
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```
cursor returns None yk
well as db is your database connection you would use that to execute queries
i would recommend you check docs as well https://aiosqlite.omnilib.dev/en/stable/
btw i need help coding a command
its done by manipulating the api which shouldnt be done and is against tos.
why is it verified then .___.
he probably got verified first lol
Not really against ToS
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
i doubt the api would have such a bug for such time
@slate swan
hey @maiden fable guess what
U fixed the error?
my entire code is fixed lmao
Congrats!
mhm
Don't expect me to help u rn, its already gonna be 4 AM for me
When can u help
Idk tbh
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?
How about in like 8 hours
Ok
Thanks
I thought you had to edit something in the actual d.py code to get it like this
anyone know how i can make a bot like rumble royale
or a command like dank memer heists
Well, can you outline how exactly it should work?
That in itself is a good starting place
yeah
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)
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
Would be helpful to be more detailed
yeah so people react to get entered into the "fight"
Like what arguments it's going to take, how it determines the winner, how to enter, what events happen, how they happen, etc
and its a battle royale you watch,
all random stuff and it tells you who kills who
or if nothing happens
Is there any user intervention after joining, or is it just random?
Should be pretty easy then
but what i dont understand is how you would tell the events that happened
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
example
ik it sounds dumb but how would i loop that
(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
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
how can i list the command and the arguments in an embed.
like
$yourmom {arg1} {arg2}
Sort of, a while loop might be better for you though
while you don't have a winner, keep making events and eliminating players
ok
You're on the right track with the for loop though
how would i continue rounds
what do you mean continue rounds?
Ah yeah how many rounds do you want per game?
as many until a winner
the entire loop completed
1 winner = 1 round?
no
I'm not following
each round some people are eliminated
undefined amount of rounds
keep going untill there is a winner
How many people eliminated per round?
random
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
im not following
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
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
Yeah, you'd do that inside the for loop
oh ok
number_of_eliminations doesn't necessarily have to be the number of people eliminated
ill try it out
and i can do sleep at the end of the loop to delay it a bit right
Yeah yeah always
wdym
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
ok
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
its meant to be used like embed.add_field(name='', value='')
and embed.set_footer(text='', icon_url='optional')
Omg thanks
@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?
where?
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')```
like this?
That line should be inside the on_message w/o any nesting
wrong, process commands take a Message arg, not a string
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 :(
@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
and is what you are looking for
ok thanks
?
select * from table where condition1 and condition2
😄
I'm providing 2 possible solutions. One is you have to use process_commands, another is you don't. You pick
if you want a more descriptive information read this
https://discordpy.readthedocs.io/en/stable/faq.html#why-does-on-message-make-my-commands-stop-working
do I have to add "import <idk>" for the client.listen?
This is the thing I get in the output in VS Code
AttributeError: 'Client' object has no attribute 'listen'
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)
I hate them
Always the terrible advice...
Anyway, you should be using commands.Bot instead of discord.Client
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')```
Whoa whoa too much stuff in on_ready
FYI you shouldn't be doing anything in on_ready except maybe print()ing
so what should I edit?
Replace discord.Client with commands.Bot(...) and also add these imports:
from discord.ext import commands
client = commands.Bot()``` error
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
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.
^ the documentation on what arguments to pass into commands.Bot
i dont understand a thing
What are you not understanding?
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???
how to make my bot get the emoji url ?
!d discord.Emoji.url first get the Emoji object and use the url propert on it
property url```
Returns the URL of the emoji.
general channel is returning None, try restarting the bot instead
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}`
!d discord.ext.commands.Command.usage should do iirc
A replacement for arguments in the default help text.
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```
oh oops
uhh i got none
uhhh nvm, wrong property then
would anyone be able to help me with discord api. #help-chili using .to_dict()
am high, its ctx.command.signature
that'll return an output like it does for the default help
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
???
eh i just added $ {ctx.command.name} to the begining to finish it up
rather use ctx.prefix so that it remains dynamic and not static
commands.bot is a module, use the class commands.Bot (capital B) instead.
ight i added that. gn yall
gn
good night lol, imma sleep too
gn sweet dreams
@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
```
!paste | Use this to post long code, so you don't flood the channel
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.
shouldnt use requests and format and the error quite says it all and you should use dict.get
When defining commands on cogs, make sure to include self as the first parameter. This applies to every instance method.
good eye cirno


if u can set webhooks avatar by webhook.avatar_url
how do u set a name?
Hey @slate swan!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
the Context class has no such attribute as the error says
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
?
Command raised an exception: AttributeError: 'Command' object has no attribute 'quailified_name
...
Rip
do i need 2 values for embed.add_field
Yes
close it and open again
did that 3 times
@stray carbon can u show the screenshot of last few error lines?
help
lemme restart it rq
icon is none
how can i
disnake
embed.set_author(name=f"{ctx.guild.name}", icon_url=f"{ctx.guild.icon.url or }")
...
- 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
help me pls
embed.set_author(name=f"{ctx.guild.name}", icon_url=f"{ctx.guild.icon.url or }")
ctx.guild.icon.url if ctx.guild.icon.url else 'default url'
Weird
when installing postgres did u change anything you are not supposed to
No? i just added this to path env variable
;C:\Program Files\PostgreSQL\14\bin
` - 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?
Try searching online
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
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?
!d discord.ext.commands.Bot.get_prefix
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.
hey how do u copy a channel id, i looked it up on google and it doesnt show copy id
with discord.ui how do i make buttons never time out
turn on developer mode in discord settings
oh ty
check examples/views/persistent.py in discord.py's repo
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)
BTW u can get the user object by ctx.author
also can u print ctx.author.avatar once?
or Member object if possible
its a union of types it can be both really
i know
yep yep yep
discord.Member has all the attrs discord.User has
Not a direct subclass, but they subclass the common class
smart
shhhhhhh
I have just read the source
why are you making a string a string lol
it returns a string already lol
and Asset.url does as well
source
I have exam
I didn't
I got this as output
d757c454bab7e3bba41c50c508ef004b
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
discord-components 2.1.2
and got another error
Oh god
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
Why not use discord.py 2.0
Or disnake or nextcord
Discord-components is outdated
And very inconvenient to use
I was following tutorial
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...
That guy couldn't find a good video but I know a good guide
Can you show me what guide it is?
Aren't utub tutorials bad?
They are extremely bad
I am creating a tutorial on github and will put it on site later
gud
Like 80% of them are
but easy to understand what is going on(at least for me)
those 20% are who reading the docs
And actually have looked into pep at least once
xD
https://discordpy.readthedocs.io/en/latest/interactions/api.html#view
just if you could understand this without utub tutorial
For buttons
Item = Button / Select Menu / TextInput
rapptz also has examples in discord.py git repo
Yes
I just recommend disnake cause I don't like dpy slash commands and asynchronous cogs/extensions working maybe that's subjective but still
dpy has slash commands? 😳
2.0 does
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
i dont care about anything, im just happy cus now i can write slash commands on dpy without any problems
yey
i tried js and just nothing worked lol
nah
Disnake has easier slash commands implementation
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
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
(also i was spamming in thread called "spam" or smth like this)
almost same as dpy?
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
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")
And what's not working?
ehm alr
And what the error is
wait wtf is value=
A kwarg
Ah yes
Bruh in embeds fields have a value kwarg
There
Ah yes
a
Why do you have empty title
h oh
Just don't provide the kwarg at all
maybe he wants to add the spaces, but it will not work like this
I see nothing wrong besides that with your code, just stop using replit for bots
you'll need an invisible char to set a title or the name of a field to have an empty space in the embed
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
content="edit test"
ty
And avoid f-strings without actual values inside of them
f-string without interpolation is a violation of code style
yeah somethings there
i just removed it for sending here oops
Python police will arrest you otherwise
weee arrest me
I remember how one dude used to cast objects to str
a = 69
str_a = f"{a}"
heheheheh
isnt that the way how you do that? :lemao:

probably :kyber_lemao:
is there any like master code style guide?
@strong ibex where is my nitro give it back plss
a = 69
str_a = str(a)```
is a proper method tho I hope you were kidding
Yes it's PEP (I don't remember the number)
I hope you understood that by :lemao:
8
ty
8!!!!!
!pep 8
A Foolish Consistency is the Hobgoblin of Little Minds
this will be a fun read
bye all
bye
indeed
Guys what is use of bot.listen()
?
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
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
Like @bot.event can only do 1 event on_message
And @bot.listem can do it more than 1 time?
Yup, you got the point
google is not good for this
but im not sure from these examples you can clearly understand ||(BlvckTvrsier is typing)||
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'
you need to provide command_prefix parameter when you create a bot
@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
my bot uses slash cmds
if only them, then / i think
You will need to declare a prefix anyways
^ ↓
is a required argument
oh i should keep / in the parameter?
The prefix can be wathever you want, slash command prefix doesn't change
@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│ )
364│
365│ if not package:
366│ # TODO: find similar
→ 367│ raise ValueError(
368│ "Could not find a matching version of package {}".format(name)
369│ )
370│
371│ return package.pretty_name, selector.find_recommended_require_version(package)
exit status 1
Do:
bot = commands.ApplicationBot
anyone?
show code?
Traceback (most recent call last):
File "main.py", line 5, in <module>
bot = commands.ApplicationBot(intents=discord.Intents.all())
AttributeError: module 'discord.ext.commands' has no attribute 'ApplicationBot'
Can anyone help me how ca we make button interaction?
yeah i didnt find anything 'bout AppBot in docs too
It isn't a thing in fact 
uhm, i dont think this is it, you have error related to some client that is nor finding a matching version
-__-
i mean that's code not related to an error
or that's all code you have in your bot?
nope
Oh wait you using discord?
I thought you are using disnake.
lol
NVM idk about discord disnake is just easier.
There isn't a class named ApplicationBot in disnake too 
There is.
lol
I used it.
You were drunk probably 
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'
That is a parameter of an Interactions which stands for the bot who is handling that interaction 
!d disnake.ApplicationCommandInteraction.bot
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").
In the variable
bot = discord.ext.commands.Bot(commands_prefix='$', intents=discord.Intents.all())
??
Class requires the parameter
ohk
not as the var outside it :D_D:
still same error
!d disnake.ext.commands.InteractionBot this one allows only slash commands 
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.
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'
WTF
not in commands.Bot
bot = discord.ext.commands.Bot(command_prefix='$', intents=discord.Intents.all())
just bruh
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
that's not how you use slash_commands in dpy
this
this is a better practice though ^
Don't give him weird ideas
what?
yeah, Bot > Client
what?
what?
i mean wdym
i was answering to ash
I didn't even ask anything....
oh kay
u can't do that, u need to import commands
why not? of course that looks weird but why can't you import discord and use this?
bot = discord.ext.commands.Bot()
AttributeError: module 'discord' has no attribute 'ext'
Guys can someone help me work on my welcoming system or nah
yes?, but not spoonfeed
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()
save the plot and send it as a file
How can i save? image.save?
Can you tell me do i need to remove plt.show?
plt.savefig('<name of file>.png') ig
Do i need to remove plt.show()
i dont think so
Ok
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
It worked thak u
So ill change it to command at my own
Btw thanks for help!
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
so you typed ?slowmode 10s right?
No just slowmode 10
show full traceback pls
Ok
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".```
no, you typed something wrong, cus it says that it could not convert time to int
well i showed code , idk
ima check
sus
what do this code?
=.=
U showed the error
hi:)
"Time" is an int. So u should do "10s" cuz it will pass as a STR
what do this command?
sssssssssuuuuuuuuuuuussssssssssss
slowmode settings =.=
It enable/disable the slowmode in the specific channel
!ot :D
one of you telling them that the question is OT, was ENOUGH
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
!d discord.on_member_join
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.
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.
!d discord.Guild.member_count
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]`.
alright, thank you : ) and if i want to get the counts of daily communicator, how can i do that?
wdym daily communicator?
If you want to save member count of server every day then you can store it in DB or JSON
a member who talked
dont use json for that purpose, its the best for static or or or or data that is not often edited
just use the on_message event and a database that checks if they are already in the database or not
is there any way to scrape the info from server insight?
!pypi beautifulsoup4
Be vary that it's blocking and u will have to use asyncio.loop.run_in_executor
okay thank you
!d asyncio.loop.run_in_executor
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:
how to make kick command?
!d discord.Guild.kick
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.
!d discord.Member.kick
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").
@carmine hearth
Using this plus snowflake would be the most elegant solution. Less resources.
why this error ?
because bot has no attr slash command
You need to create a scope using the generator
what ?
where
are you trying to make slash command using dpy?
yes
It's literally called url generator.
then this is how it works
It's a panda.
Install dpy 2.0
and also this is what changes between 1.7.3 and 2.0 https://discordpy.readthedocs.io/en/latest/migrating.html
you need to install it from github
but how is that even looking like a monkey....
send my link pls
pip install git+https://github.com/Rapptz/discord.py
python -m pip install git+https://github.com/Rapptz/discord.py
py -3 -m pip install -U git+https://github.com/Rapptz/discord.py
error
sudo apt install git
/downloads *
I got no clue.
I've never needed to explain it before...
that's why people feel clueless
because they dont understand how is panda looking simple to monkey
Might as well drop this convo now
@silk fulcrum
I honestly thought he was still going on about it not being linux 😂
!d discord.Intents
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.
yeah
I just finished^ a python course by CS50, so am I eligible to start making bots now or am I not?
😏
Huh?
I mean if you really want to, why not?
no because the last time I tried making a bot I was mocked
for being a novice
Hi hunter
Well shame on them.
Congrats! I never got to complete the course cz.... motivation. Anyways, yea it's a good starting point!
of course you can, but to make really good bots you have to finish at least one project on python i think
oh okay
Please don't depend on me to ask yr problem please. Just ask the question and any person online, wil help you
^ finished means attended all lectures
I'm on and off nowadays and u won't be able to finish ur bot if u depend on me
im not prof, I can't say 100%, i remember that on this server there is info about what should you know to make a bot: discord.gg/dpy
I don’t depend
thanks
cus im banned from it :lemao:
Anyways , I need help fixing 2 commands , coding 2 commands
dpy servers gonna eat him raw
Agreed
oof
yeah, good people from dpy are also here
bad people from dpy are on dpy
oh wait what?
What... do u mean
yeah so what's the problem?
go make 'em
….. ok
I got a java problem.
this is python server tbh :lemao:
What do I do?
!d how to code welcome message
Pass the Intent class in the Client constructer using the kwarg intent.
add , intents=discord.Intents(some intents)
@cloud dawn@silk fulcrum https://mystb.in/ForthCigarettesBrad.python
大家好
client = commands.Bot(command_prefix= '2')
status = cycle(['MaDe By CHiVaz#4888', 'CN Store'])
discord.Intents.all()```
=>
```py
client = commands.Bot(command_prefix= '2', intents=discord.Intents.all())
status = cycle(['MaDe By CHiVaz#4888', 'CN Store'])
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.
You can't just smash 2 bots together and expect it to work like that.
I need help making a set welcome message command
oof, every1 have probs with welcome
just ask away tho
I legit asked
you mean you did nothing and want us to help?
Non multi guild is easy , 3 lines of code , multi guild requires more work
I'd have to agree with master here, "welcome message command" is pretty vague.
Sort of but not quite
Is it a welcome message event or welcome command?
It’s a command
Okay, and what does this command do?
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
Okay, I understand, how did you want to save the channel?
gud, what's the problem doin' it
Everyone, I'm new here, please take care
I don kno how
taking care
I use aiosqlite if interested lol
thanks
Well you'd need a database, on_member_join event and a command.
same as you saved a channel?
Yes I have that
I’ll show code rq ?
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
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
Yeah sure.
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."
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
you need to enable intents in dev portal (link in your error)
https://paste.pythondiscord.com/uhidetepiz current code
Okay, well you could combine the enable/disable of the channel welcome command by inversing the bool.
can i reload my bot's cog without restarting the bot?
i saw someone talking about that before
Could u help me do that ?
Ye it’s possible idk how tho
I know u can do it for events for sure
Yeah later, what is the current issue? What isn't working?
my bot is now stopping forever :D
bruh wanted to say something about spoonfeeding but lost in thoughts
good job
!d discord.ext.commands.Bot.reload_extension
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.
alright thanks
why ?
You are using dpy 1.7.3
no
its still going on
bruh wanted to send some helpful link for MasterKnots but lost in thoughts after seeing his code
It's app_command.
Hi! Do you know if there is a ready-made bot for the lottery? Ticket issuance, leaderboard and ga based on number of tickets?
go to top.gg
How do I see my version?
I’ll let u know wait
pip show discord.py
or pip3
or python3 -m pip
or py -3 -m pip
or bruh im stupid
Open a terminal and type pip show discord.py or in python console __import__("discord").__version__
thanks
is this normal
guys where to dowload python? which channel
@silk fulcrum@cloud dawn
!python
nothing happened
ty
np
i have image logger and stuff
just google python download tbh =.=
but i need nuker
...
...
okay this version 2.0
what on earth is going on
We don't help with that here.
is this bad to see?
yes, its gud i think
i mean i got a nuker lol
Do you have setuptools and build installed
i just rerun it and boom its like this
because that's not how u use slash commands in dpy
this is how u do ^
Does poetry work without python3 -m for you
Ok
@bot.command()
async def reload(ctx, arg):
bot.reload_extension(arg)
ctx.send('reloaded')
will this work?
No.
ei
unload and load again
what about this
What do we do when sending a message?
No.
Uhm no.
ah
that means its reloaded?
that means you have to await ctx.send
copy the entire code and put it in the bot file?
No it's a coro we, await those.
oo ya i forgot
huh why?
mb
nope, that's not how programming works
@bot.command()
async def reload(ctx, arg):
await bot.reload_extension(arg)
await ctx.send('reloaded')
As for the reload, if you use 1.7.3 this code is fine. If you use 2.0+ use await on the reload as well.
like this?
If you use 2.0+ then yeah. But you do want to use seom try/except, you'll notice why pretty fast.
alright
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.
How.. , I'm currently learning how bots work
How bots work or how programming works
I mean you only need to change the guild id, and token.
lol i understand now
How how works how.
Works how it works 😃
except ExtensionNotLoaded:?
That happends when you try to reload an extension that is unloaded.
Also good to catch ExtensionNotFound in case you type extension name wrongly
ikik i mean do i did it correctly
programming != 100% copy + paste
programming = 50-70% copy + paste and 50-30% think
:/
programming = 10% copy pasta for me
Same
Depending on your skill level obv.
i only copt pasta some very specific or technical thing
I only copypaste from my own projects
yeah
same
Well sometimes I copypaste java code cause it's readable only in IDE 😩
lol
All extensions must have setup function that adds cogs to the bot
is it even possible to define this thing =.=
This sussy thing 😳 https://github.com/Exenifix/AIAS/blob/master/utils/bot.py#L121-L129
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)```
bot.ExtensionNotLoaded or error.ExtensionNotLoaded??
Nah it's discord.ExtensionNotLoaded I think
alright
!d discord.ext.commands.ExtensionNotLoaded
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")
=.=
bruh
Ok this
Cmon namespaces guys
You could've pressed the link in docs tho
what is namespace
from discord.ext.commands import ExtensionNotLoaded
i think
Nah it's
from discord.ext import commands
commands.ExtensionNotLoaded```
@silk fulcrum's method is valid too
alright
ok yes
But you usually do import commands so it's more common
A namespace is a collection of classes and functions that usually have a connection
In some languages it is just a folder with classes
classes and functions have not collection has
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))
python ice cream
@loud junco what theme is that?
Ice cream made of snake????2?2?2 😳
?
what code editor do you use?
replit
oh bruh
im ashamed to say this


