#discord-bots
1 messages · Page 529 of 1
It's just causing a timeout regardless of whether the condition is met or not
Can I see your code?
can I dm you it?
!paste
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.
what do you want to do with the current view? remove it?
What're we trying to do?
https://paste.pythondiscord.com/ginonihedo.sql
I am new to the API and Python, so I honestly an completely lost on this.
Also, this is only the listener for the delete reaction, not the entire cog.
changing the view to dropdown?
Been browsing the docs and whatnot for ages
still lost 
class History(discord.ui.Select):
def __init__(self):
options = [
discord.SelectOption(emoji='1️⃣', label='Warns'),
discord.SelectOption(emoji='2️⃣', label='Mutes'),
discord.SelectOption(emoji='3️⃣', label='Bans'),
discord.SelectOption(emoji='4️⃣', label='Kicks')
]
super().__init__(placeholder='How may I help?', min_values=1, max_values=1, options=options, custom_id="pp1")
async def callback(self, interaction: discord.Interaction):
if self.values[0] == 'Warns':
db = await aiosqlite.connect('database.db')
cursor = await db.execute('SELECT * FROM warns WHERE user_ids=?', (member.id,))
rows = await cursor.fetchall()
await db.close()
embed = discord.Embed(
title=f"Warns",
color=discord.Color.red())
for row in rows:
embed.add_field(name=f"Case {row[2]}", value=row[1])
await interaction.response.send_message(embed=embed)
return
if self.values[0] == 'Mutes':
await interaction.response.send_message(f'Currently Not Available!', ephemeral=True)
if self.values[0] == 'Bans':
await interaction.response.send_message(f'Currently Not Available!', ephemeral=True)
if self.values[0] == 'Kicks':
await interaction.response.send_message(f'Currently Not Available!', ephemeral=True)
class HistoryView(discord.ui.View):
def __init__(self):
super().__init__(timeout=None)
self.add_item(History())
client = PersistentViewBot()
client.remove_command('help')
@client.command()
@commands.has_permissions(administrator=True)
async def history(ctx: commands.Context, member: discord.Member = None):
if member == None:
a = await ctx.reply("You can't see the history of nobody!")
await asyncio.sleep(5)
await ctx.message.delete()
await a.delete()
return
else:
view = HistoryView()
embed = discord.Embed(
title=f"History of {member}",
description=
f"Choose the type of history you would like to view!",
color=discord.Color.purple())
await ctx.channel.send(embed=embed, view=view)
await ctx.message.delete()
await view.wait()``` It sends the right view. I just need to get the member from the command into the callback/some other way to fix the `member.id` to get their history.
Why are you waiting for a reaction to be added in an on_reaction_add event?
@commands.Cog.listener()
async def on_reaction_add(self, reaction, user):
if user == self.bot.user:
return
delete = '🗑️'
if str(reaction.emoji) == delete:
if reaction.message.author.bot:
await reaction.message.delete()
thanks, lol
my brain is quite fried too, so I honestly just have no idea what the hell I am doing for the most part
I recommend you learn Python before jumping into discord.py.
I've just been learning both at once at this point

i got an idea, pass member to HistoryView's __init__
then later you can access it from callback
Not a very good idea.
Will take you much longer to learn than if you learnt at least the basics first.
Could I by chance get an example to add it to the init? I've been trying to research it in the documents, but I can't find anything, I'm so sorry, I just would really like to go this done
class History(discord.ui.Select):
def __init__(self, member: discord.Member = None):
self.member = member
options = [
discord.SelectOption(emoji='1️⃣', label='Warns'),
discord.SelectOption(emoji='2️⃣', label='Mutes'),
discord.SelectOption(emoji='3️⃣', label='Bans'),
discord.SelectOption(emoji='4️⃣', label='Kicks')
]
super().__init__(placeholder='How may I help?', min_values=1, max_values=1, options=options, custom_id="pp1")
async def callback(self, interaction: discord.Interaction):
if self.values[0] == 'Warns':
db = await aiosqlite.connect('database.db')
cursor = await db.execute('SELECT * FROM warns WHERE user_ids=?', (self.member.id,))
rows = await cursor.fetchall()
await db.close()
embed = discord.Embed(
title=f"Warns",
color=discord.Color.red())
for row in rows:
embed.add_field(name=f"Case {row[2]}", value=row[1])
await interaction.response.send_message(embed=embed)
return
if self.values[0] == 'Mutes':
await interaction.response.send_message(f'Currently Not Available!', ephemeral=True)
if self.values[0] == 'Bans':
await interaction.response.send_message(f'Currently Not Available!', ephemeral=True)
if self.values[0] == 'Kicks':
await interaction.response.send_message(f'Currently Not Available!', ephemeral=True)
class HistoryView(discord.ui.View):
def __init__(self, member: discord.Member = None):
super().__init__(timeout=None)
self.add_item(History(member))
``` this is for the `View`
view = HistoryView(member) and in the command
Throws me this error: py AttributeError: 'NoneType' object has no attribute 'id'
Oh wait
It works! Thank you so much!
i did this not a good idea ( i didnt plan on coding before just the idea of a discord bot was cool and i didnt really care about the python basics such as strings capitalization etc )

Wait is there a way to make a bot do TTS in a vc?
vanity_code kwarg in Guild.edit
https://discordpy.readthedocs.io/en/latest/api.html#:~:text=vanity_code
😄
yes it is possible.
class History(discord.ui.Select):
def __init__(self, member: discord.Member = None):
self.member = member
options = [
discord.SelectOption(emoji='1️⃣', label='Warns'),
discord.SelectOption(emoji='2️⃣', label='Mutes'),
discord.SelectOption(emoji='3️⃣', label='Bans'),
discord.SelectOption(emoji='4️⃣', label='Kicks')
]
super().__init__(placeholder='How may I help?', min_values=1, max_values=1, options=options, custom_id="pp1")
async def callback(self, interaction: discord.Interaction):
channel = interaction.guild.get_channel(interaction.channel)
if self.values[0] == 'Warns':
db = await aiosqlite.connect('database.db')
cursor = await db.execute('SELECT * FROM warns WHERE user_ids=?', (self.member.id,))
rows = await cursor.fetchall()
await db.close()
embed = discord.Embed(
title=f"Warns",
color=discord.Color.red())
for row in rows:
embed.add_field(name=f"Case {row[2]}", value=row[1])
await interaction.channel.send(embed=embed)
return
if self.values[0] == 'Mutes':
await interaction.channel.send(f'Currently Not Available!')
if self.values[0] == 'Bans':
await interaction.channel.send(f'Currently Not Available!', ephemeral=True)
if self.values[0] == 'Kicks':
await interaction.channel.send(f'Currently Not Available!', ephemeral=True)
class HistoryView(discord.ui.View):
def __init__(self, member: discord.Member = None):
super().__init__(timeout=45)
self.add_item(History(member))
client = PersistentViewBot()
client.remove_command('help')
@client.command()
@commands.has_permissions(administrator=True)
async def history(ctx: commands.Context, member: discord.Member = None):
if member == None:
a = await ctx.reply("You can't see the history of nobody!")
await asyncio.sleep(5)
await ctx.message.delete()
await a.delete()
return
else:
view = HistoryView(member)
embed = discord.Embed(
title=f"History of {member}",
description=
f"Choose the type of history you would like to view!",
color=discord.Color.purple())
await ctx.channel.send(embed=embed, view=view)
await ctx.message.delete()
await view.wait()``` Why does it send this error: ```py
raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction``` when I use any of those?
It works, but it just gives me that error 
await interaction.response.defer() (i think its a coro)
Hey, I had a question about a discord bot in #help-pretzel, if someone that is knowledgeable with discord.py
I need a help
await interaction.edit_original_message.defer(embed=embed)``` I don't think I'm understanding :P
also try using your view's on_error to see if it catches a different error @hollow agate
i was having the same error and it was actually this:
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In components.0.components.5: The specified component exceeds the maximum width
I need to make a select menu when clicked on a option it should show an embed when clicked on other it should show other can anyone help?
I removed all my error handlers, nothing different.
@client.event
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandNotFound):
return
elif isinstance(error, commands.MissingPermissions):
return
elif isinstance(error, commands.MemberNotFound):
return
elif isinstance(error, commands.CommandInvokeError):
return
elif isinstance(error, commands.CommandOnCooldown):
await ctx.channel.send(
f"Hey {ctx.author.mention}! You can't use that command yet! \n \nTry again in {error.retry_after:.2f}s.",
delete_after=10)
await ctx.message.delete()
else:
print('Ignoring exception in command {}:'.format(ctx.command),
file=sys.stderr)
traceback.print_exception(type(error),
error,
error.__traceback__,
file=sys.stderr)``` Is the only thing I had and I removed it.
R u trying to make buttons?
Or
.
not on the error handler, on your discord.ui.View's on_error
For example: https://github.com/LeoCx1000/discord-bots/blob/master/DuckBot/helpers/paginator.py#L256-L258
DuckBot/helpers/paginator.py lines 256 to 258
async def on_error(self, error: Exception, item: discord.ui.Item, interaction: discord.Interaction) -> None:
if interaction.user.id in self.ctx.bot.owner_ids:
await self.ctx.reply('```py' + ''.join(traceback.format_exception(etype=None, value=error, tb=error.__traceback__) + '\n```'))```
thanks python bot :D
I don't have an on_error
make one, see if it catches an unexpected error that isnt handled
Where would I put it? sorry
inside your View class/subclass
Can anyone help
like making drop-down menus?
Yh
class HistoryView(discord.ui.View):
def __init__(self, member: discord.Member = None):
super().__init__(timeout=45)
self.add_item(History(member))
async def on_error(self, error: Exception, item: discord.ui.Item, interaction: discord.Interaction) -> None:
if interaction.user.id in self.ctx.bot.owner_ids:
await self.ctx.reply('```py' + ''.join(traceback.format_exception(etype=None, value=error, tb=error.__traceback__) + '\n```'))``` Should I indent the `async def on_error`?
I using without cogs
Those aren't cogs
Well, kinda... but it works differently
#help-pretzel pls
that is right. but you would need to pass a ctx in your init.
(or just remove the if statement and make it send the error not only to you - probably easier)
O
Btw I need to make an embed when reacted to an option I have this kind of sample@pale zenith
No one here?
i get the error local variable 'role' referenced before assignment when i run this
the emoji.name would be this in the image:
use str(payload.emoji) which is the full !Giveaway
async def on_error(self, error: Exception, item: discord.ui.Item, interaction: discord.Interaction) -> None:
await self.ctx.reply('```py' + ''.join(traceback.format_exception(etype=None, value=error, tb=error.__traceback__) + '\n```'))``` What do I replace ctx with? I'm so bad using self :P
.
uhm... interaction.response.send_message
Ah, thank you xd
i didnt respond bc idk lol 
wdym
await interaction.response.send_message('```py' + ''.join(traceback.format_exception(etype=None, value=error, tb=error._
_traceback__) + '\n```'))
TypeError: can only concatenate list (not "str") to list```
..
class HistoryView(discord.ui.View):
def __init__(self, member: discord.Member = None):
super().__init__(timeout=45)
self.add_item(History(member))
async def on_error(self, error: Exception, item: discord.ui.Item, interaction: discord.Interaction) -> None:
await interaction.response.send_message('```py' + ''.join(traceback.format_exception(etype=None, value=error, tb=error.__traceback__) + '\n```'))``` :P
i have an emoji: 
str(emoji) is !Kek
emoji.name is Kek
.
@pale zenith
@slate swan
are you sure that format_exception returns a list?
!d traceback.format_exception
traceback.format_exception(exc, /, [value, tb, ]limit=None, chain=True)```
Format a stack trace and the exception information. The arguments have the same meaning as the corresponding arguments to [`print_exception()`](https://docs.python.org/3/library/traceback.html#traceback.print_exception "traceback.print_exception"). The return value is a list of strings, each ending in a newline and some containing internal newlines. When these lines are concatenated and printed, exactly the same text is printed as does [`print_exception()`](https://docs.python.org/3/library/traceback.html#traceback.print_exception "traceback.print_exception").
Changed in version 3.5: The *etype* argument is ignored and inferred from the type of *value*.
Changed in version 3.10: This function’s behavior and signature were modified to match [`print_exception()`](https://docs.python.org/3/library/traceback.html#traceback.print_exception "traceback.print_exception").
ah i see
:P?
but :P
Hm
class HistoryView(discord.ui.View):
def __init__(self, member: discord.Member = None):
super().__init__(timeout=45)
self.add_item(History(member))
async def on_error(self, error: Exception, item: discord.ui.Item, interaction: discord.Interaction) -> None:
await self.ctx.reply('```py' + ''.join(traceback.format_exception(etype=None, value=error, tb=error.__traceback__) + '\n```'))``` @pale zenith how would I pass ctx? I wanna see if that'll work
i dont think u can use ctx lol
class MyCustomView(discord.ui.View):
def __init__(self, ctx: commands.Context, member: discord.Member):
super().__init__(timeout=45)
self.ctx = ctx
# then inside your command:
await ctx.send('hi', view=MyCustomView(ctx=ctx, member=member))
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'HistoryView' object is not callable ```
The command and dropdown works, but it gives me an error which is weird
The new one or the older one?
how can i make it so when the bot restarted, the reaction role button will still works?
You can't
oh uh
You can...
xD how
Are you using reactions or buttons?
Wait, u mean using events?
buttons
Ah, nvm. Buttons
Send me your code
okie
U can use persistent views
Even with reactions it works :P
Yea, I understand now haha. Sorry
bouta implement commands to my wrapper before I even finish all the models
😔 got the parser running
@pale zenith
like, which line does that error that popped up at last is raised
the one where says ... is not callable
await ctx.channel.send(embed=embed, view=view(ctx=ctx, member=member))
TypeError: 'HistoryView' object is not callable```
nvm, i figured out
when youre creating the class you need to
here pass your ctx
not in view=view
@hollow agate ^
AttributeError: 'Context' object has no attribute 'id'```
Seems like you have already done view = HistoryView()
And after doing this, u r calling view again, which raises that error
Breh, my net
ctx is your first parmeter right? you pass it first (ctx, member)
or you can make it a kwarg, like ctx=ctx
here^
No like, what is the end goal?
Everything works, but an error happens in the process
raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction``` this error
class History(discord.ui.Select):
def __init__(self, member: discord.Member = None):
self.member = member
options = [
discord.SelectOption(emoji='1️⃣', label='Warns'),
discord.SelectOption(emoji='2️⃣', label='Mutes'),
discord.SelectOption(emoji='3️⃣', label='Bans'),
discord.SelectOption(emoji='4️⃣', label='Kicks')
]
super().__init__(placeholder='How may I help?', min_values=1, max_values=1, options=options, custom_id="pp1")
async def callback(self, interaction: discord.Interaction):
channel = interaction.guild.get_channel(interaction.channel)
if self.values[0] == 'Warns':
db = await aiosqlite.connect('database.db')
cursor = await db.execute('SELECT * FROM warns WHERE user_ids=?', (self.member.id,))
rows = await cursor.fetchall()
await db.close()
embed = discord.Embed(
title=f"Warns",
color=discord.Color.red())
for row in rows:
embed.add_field(name=f"Case {row[2]}", value=row[1])
await interaction.channel.send(embed=embed)
return
if self.values[0] == 'Mutes':
await interaction.channel.send(f'Currently Not Available!')
if self.values[0] == 'Bans':
await interaction.channel.send(f'Currently Not Available!', ephemeral=True)
if self.values[0] == 'Kicks':
await interaction.channel.send(f'Currently Not Available!', ephemeral=True)
class HistoryView(discord.ui.View):
def __init__(self, member: discord.Member = None):
super().__init__(timeout=45)
self.add_item(History(member))
client = PersistentViewBot()
client.remove_command('help')
@client.command()
@commands.has_permissions(administrator=True)
async def history(ctx: commands.Context, member: discord.Member = None):
if member == None:
a = await ctx.reply("You can't see the history of nobody!")
await asyncio.sleep(5)
await ctx.message.delete()
await a.delete()
return
else:
view = HistoryView(member)
embed = discord.Embed(
title=f"History of {member}",
description=
f"Choose the type of history you would like to view!",
color=discord.Color.purple())
await ctx.channel.send(embed=embed, view=view)
await ctx.message.delete()```
Removing the member stuff, breaks everything.
right we got very off topic. but the end goal was for you to have an on_error inside your HistoryView so you could see what was causing Unknown Interaction
Yes. So do I do what you just asked me to do... or?
It'll throw me way too many errors for it to be even helpful because I need member for it to work the database.
Oh my wait
the end goal was to have something like this so you could see if there were any unexpected errors:
class HistoryView(discord.ui.View):
def __init__(self, member: discord.Member = None):
super().__init__(timeout=45)
self.add_item(History(member))
def on_error(self, error, interaction):
await interaction.channel.send('```py\n' + ''.join(traceback.format_exception(etype=None, value=error, tb=error.__traceback__)) + '\n```')
# then in your command
view = HistoryView(member)
I had two bot instances running, that's probably it
oh? 👀 
class History(discord.ui.Select):
def __init__(self, member: discord.Member = None):
self.member = member
options = [
discord.SelectOption(emoji='1️⃣', label='Warns'),
discord.SelectOption(emoji='2️⃣', label='Mutes'),
discord.SelectOption(emoji='3️⃣', label='Bans'),
discord.SelectOption(emoji='4️⃣', label='Kicks')
]
super().__init__(placeholder='How may I help?', min_values=1, max_values=1, options=options, custom_id="pp1")
async def callback(self, interaction: discord.Interaction):
channel = interaction.guild.get_channel(interaction.channel)
if self.values[0] == 'Warns':
db = await aiosqlite.connect('database.db')
cursor = await db.execute('SELECT * FROM warns WHERE user_ids=?', (self.member.id,))
rows = await cursor.fetchall()
await db.close()
embed = discord.Embed(
title=f"Warns",
color=discord.Color.red())
for row in rows:
embed.add_field(name=f"Case {row[2]}", value=row[1])
await interaction.channel.send(embed=embed)
return
if self.values[0] == 'Mutes':
await interaction.channel.send(f'Currently Not Available!')
if self.values[0] == 'Bans':
await interaction.channel.send(f'Currently Not Available!', ephemeral=True)
if self.values[0] == 'Kicks':
await interaction.channel.send(f'Currently Not Available!', ephemeral=True)
class HistoryView(discord.ui.View):
def __init__(self, member: discord.Member = None):
super().__init__(timeout=45)
self.add_item(History(member))
client = PersistentViewBot()
client.remove_command('help')
@client.command()
@commands.has_permissions(administrator=True)
async def history(ctx: commands.Context, member: discord.Member = None):
if member == None:
a = await ctx.reply("You can't see the history of nobody!")
await asyncio.sleep(5)
await ctx.message.delete()
await a.delete()
return
else:
view = HistoryView(member)
embed = discord.Embed(
title=f"History of {member}",
description=
f"Choose the type of history you would like to view!",
color=discord.Color.purple())
await ctx.channel.send(embed=embed, view=view)
await ctx.message.delete()``` Doesn't throw me an error anymore
then leave it as is. and if it happens again at some point try this ^
async def callback(self, interaction: discord.Interaction):
channel = interaction.guild.get_channel(interaction.channel)
if self.values[0] == 'Warns':
db = await aiosqlite.connect('database.db')
cursor = await db.execute('SELECT * FROM warns WHERE user_ids=?', (self.member.id,))
rows = await cursor.fetchall()
await db.close()
embed = discord.Embed(
title=f"Warns",
color=discord.Color.red())
for row in rows:
embed.add_field(name=f"Case {row[2]}", value=row[1])
await interaction.edit_original_message(embed=embed)``` When I add edit_original_messgage it says ```py
raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10015): Unknown Webhook```/doesn't work
Using interaction.channel.send works.
there's interaction.response.edit_message
thats a mood 
They'll do different things later, just needed to figure out the first thing for now
oh
uhm..how would I make a cooldown error handle display the time you have left in minutes or hours or even days ??
!pypi humanize
you can use that lib to convert the time needed left to run the command
Hey, I was wondering if there's a way to clear out this notification every time there's an argument error when a command is being invoked.
error.retry_after
!d discord.on_command_error
No documentation found for the requested symbol.
my code looks like this
Uhhh, what
What's embed?
I removed the insertion of the embed message.
yes it gives output as seconds
That's what it should (:
yes but I need it to be minutes or hours ¯_(ツ)_/¯
What's supposed to do is that if you do !howsus without any arguments, it would just send an embed of how sus the author of the command sender is.
U can divide bro
I tried it dosent give output
Wym
import humanize
from datetime import timedelta
humanize.precisedelta(timedelta(seconds=x))
hey guys, does anyone know how i would be able to use a check inside a command instead of using it as a decorator?
if statements
you could make member an optional field, then make it so if theres no member, the member is the author
@bot.command
async def howsus(ctx, member: discord.Member = None):
member = member or ctx.author
# check how sus
``` No need to handle that in a local error handler
whys there an if statement for that
for what
idk how to make a check without an @ tho
I wanted to make two different dialogues, one for {member.name} and one for you're*. Although that's good.
ah ok, that isnt possible
I just wanted to clear those error messages on my console, although idk how to prevent it
i think so
so this whole time
ive wasted my time making a function
to convert seconds to those units
you could like make it check for that
ur = "you're"
f"{member.name + ' is' if member != ctx.author else ur} {number} percent sus"
We can do that inside a {}?
ooooh that makes more sense and way easier
you cant have \
yeah
humanize saves time :)
yeah maybe ill use my own
use f"""{member.name + ' is' if member != ctx.author else "you're"} {number} percent sus"""
still if i knew that at the start id use it
ooh
humanize can convert bytes to mb, gb etc. and more stuff
"you\'re"
ah nice
yes but you can't have backslashes inside a {} f-string
you'd need like:
ur = "you're"
f"{member.name + ' is' if member != ctx.author else ur} {number} percent sus"
oooh okok
var = member.name + ' is' if member != ctx.author else "you're"
f"{var} {number} percent sus"
```this is better
When I found humanize I deleted my code for conversion with zero hesitation
tru that. less long line @crystal wind ^
yeah but if i have to use naturaltime id use humanize
i think he gets it
Is it used to convert time?
i already said this
Sent a ss anyway
yes
What's wrong if I said it again, I was replying
._. I have always used a convert with bunch of if statement
that still works
MyBot/cogs/moderation/admins.py lines 101 to 114
if time is None:
time = apply_time + timedelta(hours=1)
else:
if 'm' in new_time:
convert = int(new_time[:-1])
time = apply_time + timedelta(minutes=convert)
elif 'h' in new_time:
convert = int(time[:-1])
time = apply_time + timedelta(hours=convert)
elif 'd' in new_time:
convert = int(time[:-1])
time = apply_time + timedelta(days=convert)
else:
time = apply_time + timedelta(hours=1)```
What? Why did it send it?
I guess
A feature of the bot
it's like that, on_message detects if the link is a github page and then gets the data from it
Not really
I see, I thought it is only for the bots source
What is a better way?
A discord bot focused on clean code and utility. Using the discord.py library - 0x42/converters.py at a69d77e3acb901e317f1ec4f476c7992be7e0347 · an-dyy/0x42
Heres how I do mine
You don't need a bunch of if statements you can just make a time mapping
I wrote this for converting something like 2h 3m 40s to just seconds
def cts(self, string):
def divide_list(l, n):
return [l[a:b] for a, b in [(a, b) for a, b in zip(range(0, len(l), n), range(n, len(l) + n, n))]]
string = string.lower()
numbers = [n for n in re.findall(r"\d", string) if n]
words = [w.strip().lower()[0] for w in re.findall(r"\D", string) if w]
if [w for w in words if not w in ["s", "m", "h", "d"]]: return False
if not len(numbers) == len(words): return False
formatted_list = []
for t in zip(numbers, words):
formatted_list.append(t[0])
formatted_list.append(t[1])
formatted_list = divide_list(formatted_list, 2)
cv = {"s": 1, "m": 60, "h": 3600, "d": 86400}
return sum([int(x[0]) * int(cv[x[1]]) for x in formatted_list])
I don't know much regex
Smart to use regex
pretty pog, got commands working on my wrapper
What?
If you look at lefi/ws/wsclient.py there is a method read_messages of WebSocketClient. Which is really just an overhead to handle the internal websocket which is under the attribute ws. The read_messages method actually receives the events then dispatches it to parsers in state.py. You're gonna want to use aiohttp.ClientSession.ws_connect(url), here url being the url you receive after calling the /gateway/bot endpoint in the API. Keep in mind after connecting to the websocket you will need to keep it alive, first send an identify, then start the heartbeat loop. All of this can be seen in the code
What u mean?
u tried editing a select menu? idk if u can
Yh
@slate swan try removing await
From where?
wait wheres ur code
@client.command()
async def option(ctx):
await ctx.send(
"This message has a select menu!",
components=[
SelectMenu(
custom_id="test",
placeholder="Choose up to 2 options",max_values=1,
options=[
SelectOption(
label = "Option 1",
value = "value 1"),
SelectOption(
label = "Option 2",
value = "value 2"),
SelectOption(
label = "Option 3",
value = "value 3")
]
)
]
)
e1 = Embed(title="embed1", description="a really exciting embed")
e2 = Embed(title="embed2", description="a really exciting embed")
e3 = Embed(title="embed3", description="a really exciting embed")
while True:
try:
event=await self.client.wait_for("select_option" , check=None)
label = event.component[0].label
if label == "Option 1":
await event.edit(
ephemeral = False,
embed=e1
)
elif label == "Option 2":
await event.edit(
ephemeral = False,
embed=e2
)
elif label == "Option 2":
await event.edit(
ephemeral = False,
embed=e3
)
except discord.NotFound:
print("error")
Here
why self tho
Oh sry
My mistake
Didn't remove it
i cant install psutil.. (i had it installed) but since i reinstalled python it gives an error while installing it
ERROR: Command errored out with exit status 1: 'C:\Users\Krzx\AppData\Local\Programs\Python\Python310\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Krzx\\AppData\\Local\\Temp\\pip-req-build-xnj3dbkw\\setup.py'"'"'; __file__='"'"'C:\\Users\\Krzx\\AppData\\Local\\Temp\\pip-req-build-xnj3dbkw\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\Krzx\AppData\Local\Temp\pip-record-b4jci4hd\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\Krzx\AppData\Local\Programs\Python\Python310\Include\psutil' Check the logs for full command output```
(error is too big to send full thing)
import discord from discord.ext import commands from env import load_env from os import getenv load_env()i want to store token how to do that it throws error
just use it in your command without the decorator lol
from dotenv import load_dotenv
load_dotenv()
also make sure you did pip install python-dotenv
but that file name should be .env then right?
@slate swan
yes
but repl.it doesnt allow to rename that
that's bc replit stores then somewhere else
why even use replit
then what do i do
🥲
.
either get an actual VPS or if your bot's really really small then use heroku
is there no way i can do it in repl?....
you can
how
it should work the same way
only that u don't have to do the load_dotenv
@slate swan
Error says it all
or use replit's new key syste
read the error
¯_(ツ)_/¯
how do i fix it :/
Just read
i am dumb help me when 🥲
If you know the very very very very basics of Python you know how to fix
ik that
If you never learned Python consider learning it before making a bot
Then you can fix by yourself by reading the error
... the error is just...
Is it possible to get the Invite a user used to join a guild?
🙂 very difficult one
They even give a fix 
we need AI to solve that error
😳 so tough
With the audit logs, yes
by learning python
oh, thanks
ig the guy is following python 2
💀

:>
my print has parenthesis after it
😳 show the code also pls
`import discord
from discord.ext import commands
from env import load_env
from os import getenv
load_env()client = commands.Bot(command_prefix=".")
@client.event
async def on_ready():
print("Bot is Ready")@client.command()
async def hello(ctx):
await ctx.reply("Hello")@client.command()
async def add(ctx, numb1:int, numb2:int):
await ctx.reply(numb1+numb2)@client.command()
async def multiply(ctx, numb1:int, numb2:int):
await ctx.reply(numb1*numb2)@client.command()
async def divide(ctx, numb1:int, numb2:int):
await ctx.reply(numb1/numb2)client.run(getenv('TOKEN'))`
... i don't seem to find print anywhere
also. next time use
lmao what tf is the error then
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
dude it literally says that its your 51st line
bruh
@slate swan
it is in your env.py file
😂
how to make an event that if anyone messages in a certain channel then the bot will reply Hi to it
use on_message
how to check the channel id
it has just TOKEN="...." its not py file
k
on_message event; check if the message channel is in that specific channel.. with then just go ahead
thx
wow
dude 😂
my answer is still same
your file is .py
env files have .env extension
💀
No pretty sure that's the library
💀 i bet; he himself doesn't know what he is doing
Yeah this indeed is true
😂 🥲 😩
🥲 feel free to ask for help, but don't go for dpy without knowing basic py
...
But it says ctx is undefined
u dont' do ctx.reply
then wut do i do
do message.reply
tias, (me not really sure, lol)
ARGH THE TIMER
if message.channel.id !== "896472063496298496":
return
It says invalid syntax
.
🙂 nice
@client.event
async def on_message(message):
if message.channel.id != "896472063496298496":
return
else:
embed = discord.Embed(title="Hi", description=
"This a test", color=0x1dddee)
await message.reply(embed=embed)
nothing happens
how will i get all roles of the ctx user
when I send a message in the specified channel
dm me if somebody can make me a website
roles = [role.mention for role in ctx.roles]
which "specific channel" i don't see any specific channel
does this code work??
ctx.author.roles
if message.channel.id != "896472063496298496":
and why it is not working 🤔
ok
its just not ok
bro that means; you're excluding it
channel ids are integers
and you've used != i.e. it won't do anytihng if u message there
yeah but i kept else: after it
...
^^
+1
and* still 💀
check if message author is the bot itself*
and return it
kkkk
would anyone here know how to make a command that when it's run, shows the current server member count? kinda like the server stats bot but in chat command form?
ok
u just do py ctx.guild.member_count ig?
@lament mesa this is the error
roles = [role.mention for role in ctx.author.roles.mention]
this code i added
ctx.author.roles is a list which doesnt have an attribute mention
how would I make that into a chat command?
i want all role of that user shows
a "chat command" is just like a "normal command" or a "commnd" 🙂
and that roles want to mention also
list.mention isnt a thing
that is i added mention
oh ok
Hi! I am trying to host my bot in heroku but import cv2 causing error .This I got to know by logs
I am able to start the resource
but the bot is inactive due to crash by cv2 import
gg; you got to know by logs; then send logs here
ok
so that we know what is causing the error
okay
doesnt work
It still keeps looping for 5 time
maybe you don't know how to check?
or u did some mistake while doing it?
if message.author == client:
return
ohk
yes
send requirements.txt for a second
opencv-python
yeah but how would I do it?
@bot.command(name='roll',help='rickrolles someone')
async def roll(ctx):
print('someone just got rolled')
content = ('you just got rolled! https://www.youtube.com/watch?v=dQw4w9WgXcQ')
print('roll was used, so I replied with',content)
await ctx.send(content)
this is what I currently use as a command handler, would I just need to change content out for the member count thing you said earlier?
Nice
damn it didn't format
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
this
🙂
then how can i do
Hey @opaque seal!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:

i found this in their pypi long description give it a look
iterate through it
i don't have much idea on opencv
remove that part
.txt files are not uploading
i want tht part
Loop trough the list and get the .mention of each element
bro that depends on u.. and for member u need to make ANOTHER command
?
💀 then use hastebin
yha i do that
list.mention isnt a thing. why do you want it?
ok nvm
Maybe read what is being told by the bot?
!paste
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.
i do like this ```py
roles = [role.mention for role in ctx.author.roles.mention]
remove .mention in the last part
You need to loop trough the roles object
discord.py
python-dotenv
opencv-python
numpy
cmake
Pillow
distlib==0.3.2
dlib==19.22.1
ig?
I know that, but would I only need to change out the variable "content"?
idk i don't have much idea on openv
you mean like this ```py
roles = [for role in ctx.author.roles.mention]
No
no
then
in the last part
i bet; guy doesn't know what he is doing in that
l a s t
and we're just putting it on him
remove it
bro content part doesn't matter if there is no other parameter in send
you remove last .mention
content is by default a parameter in send
And consider learning python
roles = [role.mention for role in ctx.author.roles]
okay thanks
ok
yes lmao
imma do some testing
i know but
wait; for real? u pay for winRAR?
😳

it's just a combination of concept of lists & for loop...
it's not hard to learn
it's called "list comprehension"
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
:p
subclass list and add a mention property
you still need to do MyList(something).mention anyway
XD
no
__builtins__.list = MyList```
it will make [] to MyList?
i dont think it says anything about modifying built-in datatypes 
Look at the last pinned message in #esoteric-python lol
^_^
wow
how do i get my bot to list all the servers its in...if possible the names too rather than only ids
for i in bot.guilds:
""" now here u do your stuff"""
peace
help??```py
@commands.command()
async def nuke(self, ctx, channel: discord.TextChannel = None):
"""Clones a channel and deletes the older one"""
channel = channel or ctx.channel
new_channel = await channel.clone(reason=f"Action performed by {ctx.author} ({ctx.author.id})")
await channel.delete()
await new_channel.send(f"{utily.done} Successfully Nuked this channel by {ctx.author}")
good to know that it works
but ig, it's not possible to arrange
💀
Is there any way to make a command that completely deletes every message in a channel when used?
2 ways; just nuke the channel
or make purge command
I need a purge command
then code it ;'/
How
Actually imma yoink this assuming it works
it works; but it's not purge
command
- nuke command has its own pros & cons
Ik, it's a nuker right?
yes
Good enough
i hope u will try to understand it rather than copy pasting
gg
I mean I understand what it does and kinda how it does it
Just not well enough to write it myself
...
alr
Plus im also just lazy
what
The code
bruh u can
oo i see
what about it
🤔 i've no idea then.. good luck with it
🤔 i think
we can get the position* of the channel
then we create new channel & move it to the position*
🤔
async def game(ctx, *, message):
if ctx.author.id in [738609666505834517,840411506646319124,827123687055949824]:
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.playing, name=message)
else:
titld = "You don't have permissions?"
main = "The command you tried to use can be used only be used by the developer and people whom he gave access to. You are not allowed to use it"
embedVar = disnake.Embed(title=titld, description=main, color=bot_embed_color)
await ctx.send(embed=embedVar)```
Can someone tell me what's wrong in this?
can you tell us?
tell what?
That what is wrong in the code
IDK myself and it give a really idiot error
else:
^
SyntaxError: invalid syntax
```
I can't understand how it's wrong
There is a weird character?
missing ) in the line before
Oh
?
what?
miss close brackets
if ctx.author.id in [738609666505834517,840411506646319124,827123687055949824]:
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.playing, name=message))
Oooooooooo
wow nice spoonfeed
xd

LOLLLLLL I don't need that I understood a missing bracket
and you didn’t understand a "missing )"
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: InvalidArgument: activity must derive from BaseActivity.
Hhhhelpppppppppppp
can you show what you have atm?
WDYM?
the code, can you show it?
async def game(ctx, *, message):
if ctx.author.id in [738609666505834517,840411506646319124,827123687055949824]:
await Yui.change_presence(activity=discord.Activity(type=discord.ActivityType.playing, name=message))
else:
titld = "You don't have permissions?"
main = "The command you tried to use can be used only be used by the developer and people whom he gave access to. You are not allowed to use it"
embedVar = disnake.Embed(title=titld, description=main, color=bot_embed_color)
await ctx.send(embed=embedVar)```
are you sure there is a activity called playing?
yes
I used it earlier
did it work?
Why is it even disnake.Embed but discord.Activity
.....
probably using disnake
Issue found
Why is it different though
LOLLLLLLLLLLL
lol?
Why not just one
it supports slash commands and few other things
Either everything disnake. or discord.
and dpy is no longer supported
I imported both so even if I used discord.embed it works
It's just confusing
😅
it's a different package so it makes sense
Well if u install the discord shim with pip install disnake[discord], no need to change the imports lol
Yeah makes more sense
.bm 897029578378330162 useful import to remember
loll
don't mind me
It's fine haha
good
Facts. I was also lazy to change my imports but I am rewriting my bot nowadays, so I am okay with changing all the imports to disnake since it doesn't conflict with discord.py package :D
rewriting sound painful to do
I like how everyone are changing to disnake 
edpy
I'm still staying with dpy
evil choice
Nope
Not bad choice
Can't be arsed to wait for updates and use forks
Hehe well I am also learnig JS to make my website. And gotta say canvas sucks
XD
which language

English 
😂
very funny joke
Indeed
help
you did not install smth I guess @storm sluice
That's a nice guess x)
can u await a list tho
@potent jetty https://stackoverflow.com/questions/31087111/typeerror-list-object-is-not-callable-in-python
premium_subscribers is an attribute, not a method and you therefore don't need to await it and don't need to have ()
Also consider not naming your variable list as this is kind of a reserved keyword of Python
And you don't need user = boosters.user
As the elements in the list is already of type Member
So you can directly use the attributes of it
Such as boosters.name, etc.
what should i install
¯\_(ツ)_/¯
The parent module
Read ur code it says where the error is and what you need to install
sure
We don't teach you, there are enough tutorials around
We help you with your errors
A learning guide for the discord.py bot framework written by members of our community.
we dont teach people how to make a working bot, people teach us
then make it work
Make the bot first > Code it > If theres errors ask people
sad
why u cant
ok, so how are we supposed to help when you sent nothing for us to work with
Totally new? No experience with python?
Please learn Python first, you will do a favor for yourself
@client.command()
@commands.has_permissions(manage_messages = True)
async def log(ctx, content):
guild = ctx.guild
c_id = str(content[2:-1])
channelbruh = client.get_channel(c_id)
channelid = channelbruh
with open('logs.json', 'r') as f:
logs = json.load(f)
logs[str(guild.id)] = channelid
with open('logs.json', 'w') as f:
json.dump(logs, f, indent=4)
await ctx.send("added")
it just does null https://shit-dev.me/
Is it possible to check when specified members got offline and got online with a discord bot?
because you use client.get_channel (it gets only from the bot's cache) and not guild.get_channel
guild.get_channel gets channel from cache too
But from the guild itself
still prints out none
Which has more chances to be cached than all the bot's channels
use get_channel then if it's null use fetch_channel
No, client.
fetch_channel is an async function, so it needs to be awaited too
a simple one-line solution would be channel = client.get_channel(id) or await channel.fetch_channel(id)
What is wrong here?
em is not indented
the line where you wrote em = isnt indented far enough
use @bot.listen() rather than @bot.event
frick
i want the channel id not the name it just prints out ze name
@vocal plover How would I fix that or got any idea?
My cogs are not not doing anything al all.
This sounds obvious, but have you loaded them?
ive forgot a bunch of times and it makes me feel so dumb lol
@client.command()
async def load(ctx, extension):
client.load_extension(f'cogs.{extension}')
@client.command()
async def unload(ctx, extension):
client.unload_extension(f'cogs.{extension}')
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
client.load_extension(f'cogs.{filename[:-3]}')
``` @vocal plover Isn't this right?
hm should be
hello
got any idea?
no clue sorry
for what
Well, my cogs are just not doing anything at all.
what kind of bot are you making?
I already have a bot I was just trying to get cogs to work
Because that would be way easier
Any clue @glad thicket
hmm wait one sec
Okay
no clue... sorry
Weird
How to make an or in an on_message client.listen?
ok i didnt explain nicely
but like
async def on_message(message):
if message.author == client.user:
return
else:
if message.channel.id == int(896472063496298496):
await message.reply("Thanks for advertising in Nebula advertising!")
else:
return```
how to make two channels
Ok i really cant explain what im trying to say
@client.command()
async def on_message(self, message):
if message.author == self.client.user:
return
else:
guild = self.client.get_guild(867086205182017536)
channels = await guild.fetch_channels()
channel = discord.utils.get(channels, name = str(message.author.id))
if channel is None:
category = discord.utils.get(guild.categories, name = "Tickets")
channel = await guild.create_text_channel((message.author.name),category = category)
await message.author.send("Modmail has been created succesfully")
em = discord.Embed(
title = f"{message.author.name}#{message.author.discriminator} created a modmail",
description = {message.content},
timestamp = datetime.utcnow(),
color = discord.Color.dark_blue()
)
await channel.send(embed = em)
else:
em = discord.Embed(
title = f"{message.author.name}#{message.author.discriminator}",
description = {message.content},
timestamp = datetime.utcnow(),
color = discord.Color.dark_blue()
)
await channel.send(embed = em)
``` What is wrong with this
would this be event?
yeh
indent
Yeah but which one
on the first line
I guess you need to indent everything after that line
ah ye
are you on cogs, or why is there so big indent?
ooh that's why
yeah
cogs are really useful to be used
I know
But it just doesn't work
Like my code runs but my cogs don't respond at all
there may be a logic error somewhere , or a missing 1-2 lines if you have a on_message event
Should I try to use cogs though
I can show you
I got that code now in cogs
I got 2 cogs atm
wait actually
But they just don't respond at all
Your bot has many commands that you want to spread into different category?
nowadays python's been having some werird errors
Yeah true
But like cogs don't work for me
all the commands I use in cogs just don't work, I don't even get a error
do you know how to use them?
will len(bot.cogs) return the amount of cogs the bot has?
did you load cogs?
Should be
@client.command()
async def load(ctx, extension):
client.load_extension(f'cogs.{extension}')
@client.command()
async def unload(ctx, extension):
client.unload_extension(f'cogs.{extension}')
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
client.load_extension(f'cogs.{filename[:-3]}')
show me one cog of urs
maybe somethings wrong in ur file
import discord
from discord.ext import commands
from datetime import datetime
class Member(commands.Cog):
def __init__(self, client):
self.client = client
@commands.Cog.listener()
async def on_message(self, message):
if message.author == self.client.user:
return
else:
guild = self.client.get_guild(867086205182017536)
channels = await guild.fetch_channels()
channel = discord.utils.get(channels, name = str(message.author.id))
if channel is None:
category = discord.utils.get(guild.categories, name = "Tickets")
channel = await guild.create_text_channel((message.author.name),category = category)
await message.author.send("Modmail has been created succesfully")
em = discord.Embed(
title = f"{message.author.name}#{message.author.discriminator} created a modmail",
description = {message.content},
timestamp = datetime.utcnow(),
color = discord.Color.dark_blue()
)
await channel.send(embed = em)
else:
em = discord.Embed(
title = f"{message.author.name}#{message.author.discriminator}",
description = {message.content},
timestamp = datetime.utcnow(),
color = discord.Color.dark_blue()
)
await channel.send(embed = em)
def setup(client):
client.add_cog(Member(client))
and I got 1 more cog
mm u need to unindent that
wait should I use the .load command though?
nope, you already loaded the cog automatically
Yea
quick side note, after your if message.author == self.client.user: you dont need an else: since you already return
So you have some sort of fire tree like this? (just example)
you need a some sort of main file
That is botdaxles.py
Wrong Way: ```py
class Member(commands.Cog):
def init(self, client):
self.client = client
@commands.command()
async def ping(self, ctx):
#code
def setup(client):
client.add_cog(Member(client))
Right Way:
```py
class Member(commands.Cog):
def __init__(self, client):
self.client = client
@commands.command()
async def ping(self, ctx):
#code
def setup(client):
client.add_cog(Member(client))
``` u did the `wrong way` btw
Where do I have that
in ur cog
yes
I don't see a difference
Yea?
it needs to match the def __init__ indent
maybe
import discord
from discord.ext import commands
from datetime import datetime
class Mod(commands.Cog):
def __init__(self, client):
self.client = client
@commands.Cog.listener()
async def on_message(self, message):
try:
if ".close" in message.content:
pass
else:
if str(message.channel.type) == "private":
return
else:
if message.author == self.client.user:
return
else:
user = await message.guild.fetch_member(int(message.channel.name))
emb = discord.Embed(
title = "Message from the staff team",
description = {message.content},
timestamp = datetime.utcnow(),
color = discord.Color.green()
)
await user.send(embed = emb)
except Exception as e:
print(e)
pass
@client.command()
async def close(self, ctx):
user = await ctx.guild.fetch_member(int(ctx.channel.name))
await user.send("The modmail has been closed by the staff team")
await ctx.channel.delete
def setup(client):
client.add_cog(Mod(client))
``` This is my other cog
ur making a command like a function, so it needs to be on the def __init__() indent line and not the self.bot indent line
!e
class my_cog():
def __init__(self, name):
self.name = name
def age(self, age:int):
print("{self.name} is {age}")
cog = my_cog("kayle")
cog.age(5)
@boreal ravine :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 9, in <module>
003 | AttributeError: 'my_cog' object has no attribute 'age'
by unindenting the file
uh I don't really get you in what way
!e
class my_cog():
def __init__(self, name):
self.name = name
def age(self, age:int):
print(f"{self.name} is {age}")
cog = my_cog("kayle")
cog.age(5)
``` this is what I did to fix ur cog
@boreal ravine :white_check_mark: Your eval job has completed with return code 0.
kayle is 5
Bruh this is wrong
unindent the command/event
import discord
from discord.ext import commands
from datetime import datetime
class Mod(commands.Cog):
def __init__(self, client):
self.client = client
@commands.Cog.listener()
async def on_message(self, message):
try:
if ".close" in message.content:
pass
else:
if str(message.channel.type) == "private":
return
else:
if message.author == self.client.user:
return
else:
user = await message.guild.fetch_member(int(message.channel.name))
emb = discord.Embed(
title = "Message from the staff team",
description = {message.content},
timestamp = datetime.utcnow(),
color = discord.Color.green()
)
await user.send(embed = emb)
except Exception as e:
print(e)
pass
@commands.command()
async def close(self, ctx):
user = await ctx.guild.fetch_member(int(ctx.channel.name))
await user.send("The modmail has been closed by the staff team")
await ctx.channel.delete
def setup(client):
client.add_cog(Mod(client))
This is how it should be
client.command can't be used in cogs
Thanks
oh yeah
import discord
from discord.ext import commands
from datetime import datetime
class Member(commands.Cog):
def __init__(self, client):
self.client = client
@commands.Cog.listener()
async def on_message(self, message):
if message.author == self.client.user:
return
else:
guild = self.client.get_guild(867086205182017536)
channels = await guild.fetch_channels()
channel = discord.utils.get(channels, name = str(message.author.id))
if channel is None:
category = discord.utils.get(guild.categories, name = "Tickets")
channel = await guild.create_text_channel((message.author.name),category = category)
await message.author.send("Modmail has been created succesfully")
em = discord.Embed(
title = f"{message.author.name}#{message.author.discriminator} created a modmail",
description = {message.content},
timestamp = datetime.utcnow(),
color = discord.Color.dark_blue()
)
await channel.send(embed = em)
else:
em = discord.Embed(
title = f"{message.author.name}#{message.author.discriminator}",
description = {message.content},
timestamp = datetime.utcnow(),
color = discord.Color.dark_blue()
)
await channel.send(embed = em)
def setup(client):
client.add_cog(Member(client))
``` @slate swan And this one?
same thing like earlier
indent error
I just don't get how to change it sorry
Let me do it wait
import discord
from discord.ext import commands
from datetime import datetime
class Member(commands.Cog):
def __init__(self, client):
self.client = client
@commands.Cog.listener()
async def on_message(self, message):
if message.author == self.client.user:
return
else:
guild = self.client.get_guild(867086205182017536)
channels = await guild.fetch_channels()
channel = discord.utils.get(channels, name = str(message.author.id))
if channel is None:
category = discord.utils.get(guild.categories, name = "Tickets")
channel = await guild.create_text_channel((message.author.name),category = category)
await message.author.send("Modmail has been created succesfully")
em = discord.Embed(
title = f"{message.author.name}#{message.author.discriminator} created a modmail",
description = {message.content},
timestamp = datetime.utcnow(),
color = discord.Color.dark_blue()
)
await channel.send(embed = em)
else:
em = discord.Embed(
title = f"{message.author.name}#{message.author.discriminator}",
description = {message.content},
timestamp = datetime.utcnow(),
color = discord.Color.dark_blue()
)
await channel.send(embed = em)
def setup(client):
client.add_cog(Member(client))
do not spoonfeed the fix ;-;
All the things should be under
def __init__(self, client):
self.client = client
Yeah but he is not gonna understand
why not
Yeah something like this...
I didn't...
@junior verge look at that
fyi what this does under the hood is this:
class Member(commands.Cog):
def __init__(self, client):
self.client = client
commands.Command()
```if that helps show why it doesnt work
vco, how long have you been making discord bots?
couple years
I guess you have made a public bots as well
sometimes
cool
I prefer not to generally
public bots means i go from being a developer to being tech support
private bots mean i get to power moderation in places like the gta online server
which is much more fun
I did not think it that way
so you make bots to servers you are in, instead of making public ones
mostly yeah
I do have a public bot but its main use to me is testing things like sharding when I'm doing library development 
oo, cool
making a public moderation bot is real pain
In my eyes you can have a public mod bot or a good mod bot, pick one
The issue with public mods bots is that you can't trust people, which means you can't give them powerful tooling
things like regex can be exploited to catastrophically backtrack and crash your program
yeah , also you need to be super careful while doing anything with the bot
sometimes public bots are good, but depends on use case (and type of bot)
public bots can definitely be good, its just that a small subset of them (mod bots) struggle to be good and public because of the aforementioned issues
MEE6's team
the ideal thing for a mod bot is kinda semi public, bots like zeppelin for example, because you have motovation and help to build them from your users, but you only let select people use it to ensure its safe
so not everyone may be able to invite it?
exactly, if you invite zep without being whitelisted it will just sit in your server and do nothing until it restarts, at which point it will leave all un-whitelisted servers
nice system, that seems a good choice
it has the advantage also of meaning only a few people have access to support for the bot, in zeppelin's case large server admins, who are likely to understand it better in the first place, not ask annoying questions, and generally put less load on the devs for support
That system sounds like working well
I am back
But I gotta go for a class 👋
Bye

why it is showing ffmpeg is not found
clientexception
@bot.command()
async def play(ctx, *, musicpath):
voice_client: discord.VoiceClient = discord.utils.get(bot.voice_clients, guild=ctx.guild)
audio_source = discord.FFmpegPCMAudio(musicpath)
if not voice_client.is_playing():
voice_client.play(audio_source, after=None)
full traceback pls
download it
ok
download to your pc, not your venv
ok
then wht here?
click whatever your os is
ctx.voice_client exists
pls beg
error is ffmpeg not found
what?
its is scrolling
it is showing ffmpeg not found
Hi! is there a timeout decorator for commands?
ok, but use ctx.voice_client
ok
Timeout?
make your own deco
in pc it was not installed
you can use asyncio.wait_for
where i will get that ?
for the timeout
where i will find ffmpeg?
we told you not to install it with pip
but the web is confusing
that's the library to be able to use it in a python script
hi
i need help i have rank card and i dont know how to use Pil or any moudle to add my rank card to my level system is anyone know how
learn how to use PIL
@steep estuary
Go to https://github.com/BtbN/FFmpeg-Builds/releases - Example: ffmpeg-n4.4-178-g4b583e5425-win64-gpl-4.4.zip
Download the file for Windows
Extract the content of the archive
Copy paste the folder somewhere you will always keep, example: C:\ffmpeg
Go to environment variables settings
Select the path variable in the rectangle at the top and click edit
Then click new in the window you will see
Add the path to the ffmpeg binaries folder you just previously created, example: C:\ffmpeg\bin
The website also literally states this.
It's hard to search things by yourself, people expect things to come to themselves instantly
Run ffmpeg in the cmd
ok
to see if you really did everything correctly
Now open just the cmd
Execute ffmpeg -version
shown
So you get the version
Yeah it's installed
:)
how i can get music
by its name ?
how i can search for music?
should i use youtube_Dl ?
!ytdl
Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.
For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:
The following restrictions apply to your use of the Service. You are not allowed to:
1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service; (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;
3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;
9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
Have you even read it?
reading




