#discord-bots
1 messages ยท Page 762 of 1
use a for loop on bot.guilds and print(guild.me.guild_permissions)
how do i jumble the words in the list and yes i know a is meant to be an x
like if i put in
as ds cs ls
it would randomize
and shoot out something like ds cs ls as
What is the.me. like client ?
!e py import random print(random.shuffle(['a' , 'b' , 'c']))
shuffle is actually what you're looking for
you have a list and execute the shuffle method on it
oh thank you
member object for your bot
Ok that is what I thought
it should be a list
isnt this a list
u changed it rn
and send a , not x
!e py from random import shuffle ; a = [1,2,3] shuffle(a) print(a)
@slate swan :white_check_mark: Your eval job has completed with return code 0.
[3, 1, 2]
seems more like it, maybe a different emoji per usage category
Couldn't find a ram emoji
ahh k
Like a dimm
you can always make custom ones
Thats true
that's where stuff really gets interesting
That didn't work right
Please tell me how to run it in a cog
I think self has to go in front
property me: discord.member.Member```
Similar to [`Client.user`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client.user "discord.Client.user") except an instance of [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member"). This is essentially used to get the member version of yourself.
read it
how do i split the first two
and to team 1, team 2
like how do i split the shuffled a
into 2 parts
first_part = a[0:2]
that's called slicing, you should look into that
use *slicing or numpy
Whats the formatting for emoji's again?
And can I send custom emojis in embed fields names?
add * before reason arg , or use command like +unban <user> 'long reason with full display'
yes , you can now do that in field names and embed titles
<:name:id> , added a before :name: if its an animated one
Its looking like this now but the emoji is too small
Would that be my fault for cropping it badly?
true, make it nice for people who don't know anything about hardware too
50% of people won't understand the RAM stick
So what would I do?
find cool examples
tysm
like this right?
async def unban (ctx, user: discord.User,*, reason=None):
no idea, I'm not a front-end dev lol
When most people think of ram, what do they think of?
Thats the million dollar question
if so, it doesnt work @slate swan
i learnt splicing it works but how do i get rid of these annyoing brackets
yeah
save the code and rerun the bot
it should work
!d join
join
Joins a list with a string, like Pythonโs str.join(list)
For example:
{{ value|join:" // " }}
``` If `value` is the list `['a', 'b', 'c']`, the output will be the string `"a // b // c"`.
Turn it in to a string
yep thanks! just had to re-run it for the second time!
!d discord.TextChannel.edit
await edit(*, reason=None, **options)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the channel.
You must have the [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to use this.
Changed in version 1.3: The `overwrites` keyword-only parameter was added.
Changed in version 1.4: The `type` keyword-only parameter was added.
Changed in version 2.0: Edits are no longer in-place, the newly edited channel is returned instead.
^ overwrites kwarg check the docs for more info
hey does anyone know how to use the ctx.channel.purge() command in a cog?
I get an error saying that the cog has no atribute channel
Let's see the code
you probably didnt added self as the first arg
mhm
you are right
What am I doing wrong?
async with aiosqlite.connect("notes.db") as db:
for n in notes:
note = notes[n]
cur = await db.execute(
"INSERT INTO notes VALUES(?,?)",
(steamid, note),
)
await db.commit()
await db.close()
sqlite3.OperationalError: database is locked D:
And no. The answer isn't 'Unlock it'
you have to close DB Browser before running that shit
Isnt that what I am doing with await db.close()?
close DB Browser, the program
What happened
It was working alright until yesterday?
whats "RuntimeWarning: Enable tracemalloc to get the object allocation traceback"
Put all your imports on 1 line. import discord, asyncio, os, json, random
you didn't await
oh
I dont have a DB browser program lol
if you read the whole traceback, you would've known, the error isn't always on the last line
i'll just try and run my code in a different way I guess.
then whatever program you use to look into your sqlite db
what does 'str' object has no attribute 'channel' mean?
get_channel is a method of guild
code pls, it means you're doing .channel on a string instead of a guild object or whatever it is
so do i put "guild.get_channel"
if you want to get a channel from a guild by ID, yes
kay
it's a method, not an attribute!
its R. Danny's example eval command https://github.com/Rapptz/RoboDanny/blob/rewrite/cogs/admin.py#L216-L261
or if you dont have a guild object , you can even use bot.get_channel
don't try to create eval commands, just use jishaku for that
๐
well , there ctx.message is the thing , maybe u did it wrong
mind showing your code?
they're too complicated AND you're basically copy pasting from what I can tell
exact same as there
and yeah , jishaku is really better than other bot's eval commands
( if you are actually making it by yourself then its better tho)
hmmm
u r in a cog?
no
how do i make the bot send a message and ping the user i mentioned
how to fix then
just remove self
make a member parameter
oh
btw , it uses many in-class functions
so its suggested to use it in the cog
why not use jishaku though?
I just want to test it, will be shifing to jsk anyways
Like you want to mention someone from your code, or just mention someone whom you mentioned while using a command
while using the command
make a member parameter
how do i make that
how do i get the name of all the people in ctx.authors voice channel
!d discord.VoiceChannel.members
property members: List[Member]```
Returns all members that are currently inside this voice channel.
@green bluff^^
\o/ fixed my issue
wdym
can i have an example
I was having a db issue lol
That doesn't exist.
u do this in discord dev portal dont you?
ID of authors channel?
yes
like which channel the author is in
Whoever created the channel?
nope whoever is in the channel and used the command
Well you have a channel object, use the id attribute.
how would i do that
channel.id ;-;
oh k ctx.author.get_channel.id?
No, ctx.author.channel.id
k thanks
Or just ctx.channel.id actually.
what actually is channel
you didn't mention specific channel in code, nor its a param
voice channel
param?
parameter
oh are u in the vc?
.id for the id? or no id needed?
It's to get the channel id and nothing else, so you choose if you need it or not.
yeh i dont think i do
now if there r 4 ppl in the voice chat can i split them into two different voice chats?
well it didn't work I tried to re-start VS code and it works like normal Thanks
oh sorry. i should've mentioned that the imports were just to save space lol. first thing I noticed
I also put imports before the froms.
Same
whats wrong here?
@client.command(pass_context=True)
async def coin(ctx, amount: int, other: discord.Member):
other_id = str(other.id)
if str(other.id) not in amounts:
amounts[other_id] = 0
_save()
else:
amounts[other_id] += amount
_save()
def _save():
with open('data.json', 'w+') as f:
json.dump(amounts, f)```
i keep getting this error:
``line 46
amounts[other_id] = 0
TabError: inconsistent use of tabs and spaces in indentation``
line 46 is ``amounts[other_id] = 0``
also there were many unused imports
Yes remove unused lol.
uhh _save() is not in the else, indent it unless it's meant to not be in the if/else statement.
and idk if not in works? try if not str(other.id) in amounts:?
Also depending on how big your data is, it may be best to use a database instead.
is empty xd
still getting same error 
amounts isnt being passed to the _save()
Unless amounts is meant to be a global variable?
nop just for use one time there
Then you need to pass the variable into the save function
no
@client.command(pass_context=True)
async def coin(ctx, amount: int, other: discord.Member):
other_id = str(other.id)
if str(other.id) not in amounts: #Maybe try if not str(other.id) in amounts:
amounts[other_id] = 0
_save()
else:
amounts[other_id] += amount
_save() #is this meant to be here? or is it meant to be tabbed 1 more time to be in the else part?
#Maybe add amounts to save()?
def _save():
with open('data.json', 'w+') as f:
json.dump(amounts, f) #where is it getting the variable amounts from? Perhaps consider adding a parameter called amounts to def _save()?
Some notes
Should also know pass_context has long been deprecated
idk what pass_context even is xD
ohhhh
lmao i see xd
ty
async def clist(ctx):
channel = ctx.author.voice.channel
members = channel.members
memberlist = []
for member in members:
memberlist.append(member.mention)
random.shuffle(memberlist)
team1 = memberlist[0:2]
team2 = memberlist[2:4]
embed = disnake.Embed(title='**The teams have been chosen**', colour=disnake.Colour.blue())
embed.add_field(name="**Team 1 is**", value=f'{team1}')
embed.add_field(name='**Team 2 is**', value=f'{team2}')
await ctx.send(embed=embed)``` how do i move team 1 into a different vc and team 2 in another one
did it work?
Imagine if dpy didn't had *args, **kwargs in the bot deco but instead different attr listed manually... Most of the people would have been like: WHY am I getting this error lmao
They add *args and **kwargs for custom command classes
At least iirc
andy can u help
Ah yea, cz it can also return a custom class, right?
@client.command()
async def clist(ctx):
channel = ctx.author.voice.channel
members = channel.members
memberlist = []
for member in members:
memberlist.append(member.mention)
random.shuffle(memberlist)
team1 = memberlist[0:2]
team2 = memberlist[2:4]
embed = disnake.Embed(title='**The teams have been chosen**', colour=disnake.Colour.blue())
embed.add_field(name="**Team 1 is**", value=f'{team1}')
embed.add_field(name='**Team 2 is**', value=f'{team2}')
await ctx.send(embed=embed)```
please help
how do i move team 1 to a seperate vc from team 2
Yep you can pass cls
Ah, gotcha
Then *args and **kwargs goes to this class
Yea
ye, where i can leave my 5 stars
for member in team1: await member.move_to(channel1)
for member in team2: await member.move_to(channel2)
this will ONLY work if team1 and team2 are a list of member objects, NOT member mentions
also, I hope you noticed the memberlist isn't ever shuffled, I think
always TEST first
it returns a shuffled list, it doesn't just shuffle the given list and that's it
it did return into a shuffled list
ah, that's good Ig, then you can ignore that note
wdym member obhjects not member mentions
well, you can only call move_to on member objects
your memberlist is a list of member mentions
ever went through the docs?
so do i just search it up
a member object is an instance of the discord.Member class
als, you can ONLY move the members if they're in a voicechannel already, you can't magically make someone join a voicechannel
yes ik
also, the command will throw an error when you invoke it when you're not in a voicechannel, handle that
put the last line outside of the if block
then everything will work again
correct
don't remove it from the event ofc, just get it out of the if block
if True:
#shit
#put it here```
gl hf
how to make discord bot
i need music
learn the basics first, then try to implement the things you want
ok
guys whats the error idk pls help me
import keep_alive
import os
import discord
from discord.ext import commands
from discord.ext import tasks
import asyncio
import random
bot = commands.Bot(command_prefix='?')
@bot.event
async def on_ready():
print('bot is ready')
@bot.command()
async def impo(ctx):
embed = discord.Embed(title = 'Find The Impostor My Boi', description = ':redamongus: Red'
':1yellow: Yellow'
':1black: Black'
':Blue: Blue', color = discord.Color.red())
msg = await ctx.send(embed = embed)
await msg.add_reaction(':redamongus:')
await msg.add_reaction(':1yellow:')
await msg.add_reaction(':1black:')
await msg.add_reaction(':Blue:')
keep_alive.keep_alive()
bot.run(os.getenv('TOKEN'), bot=True)
Send the error lol
have you ever heard of \n

\n ?

!e print("Hello\nWorld")
@slate swan :white_check_mark: Your eval job has completed with return code 0.
001 | Hello
002 | World
yes
makes a new line

why arent you using it?
Use it in the description lol
seems like you didnt know it
can we use in dc bots?
yes
Ofc LoL
my bad sed


LOL
it shows error in last line bot.run one @keen talon@slate swan
...... Ss when
me?
show
Send a ss
Of error
or maybe ctrl c ctrl v with a code block
!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.
!spoiler
Send the error 
||spoiler alert||
who will create bot for
no one

we dont make bots here we help with them
For?
dank
What's the error it gives?
dank
!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.
!code
๐ ๐
bruh
means?
means someone is doing to many requests so youre getting limited
aaaaaaaah so what to do now?
f in the chat

wait about an hour
or should i make new replit?
try that ive seen it worked before
ok
@karmic lintel change it to bot.run(os.environ['TOKEN'])
Wym no?
eh no
No need lol
its related to the discord api rate limiting the ip
it is working now i got rate limited
yah no need
Ohhhhhhhhhhh

Not what I thought was happening
the tb says it all
I see it now at the bottom lol
replit shares ips
so someone is making to many requests
hmm
so it will rate limit the whole ip
Damn
making so no user on that ip can interact with the api
@slate swan @keen talon tysm guyz โค๏ธ
anytime
I didn't help 
hahaha at least you tried..... workers never fails
โค๏ธ
pros
Ok I will dm or ping you whenever I need help 
sounds good


can we use if and elif in dc bot? ..... isn't it against rules?
โค๏ธ ty pros
there built ins lol
no ofc its not against the "rules"
the boi
ty too โค๏ธ
@slate swan :white_check_mark: Your eval job has completed with return code 0.
true
you guys and sarthak are good....and others just trolls me here lol

i try my best
thats enough as 100% โค๏ธ
Report to mods if someone trolls 
โค๏ธ
ok boi
guess your gonna get banned๐
bromance ๐ซ
๐ซ
Bruh why 
im joking
gtg bye guysss
You made me cry ๐ฅฒ
im sorry๐
I was jk too 
maybe help me with the docs of my api wrapper <33

jk im stuck with a error in docs with sphinx
๐
I am kinda busy nowadays lol , I am studying for a entrance ๐
niceeeee
what is the event for interaction of a button?
gl for studies
elaborate
๐
Youtubedl is the thing for music correct?
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)
WHAT

event for pressing on a button man
!d disnake.ui.Button.callback
what lib
await callback(interaction)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
The callback associated with this UI item.
This can be overriden by subclasses.
why use an event
yah ytdl is against tos

sigh
cuz I wanna know when someone presses a button?
I mean, why not
you have to wait for the button๐
discord
no such event
on 2.0?
Welp that's no longer gonna get made
Use disnake
!d discord.ui.View
class discord.ui.View(*, timeout=180.0)```
Represents a UI view.
This object must be inherited to create a UI within Discord.
New in version 2.0.
bruh no
Das sucky
there is such an event but not recommended...
oof
fr?
yes
Pycord
!d discord.on_interaction
discord.on_interaction(interaction)```
Called when an interaction happened.
This currently happens due to slash command invocations or components being used.
Warning
This is a low level function that is not generally meant to be used. If you are working with components, consider using the callbacks associated with the [`View`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.View "discord.ui.View") instead as it provides a nicer user experience.
New in version 2.0.
thats the only event afaik
Nah disnake is better
no.
so that's what I need no?
discord.py best now stop arguing
Facts
what are you trying to do i feel like this is a xy
Yea I agree with that
ofc its best
It is not there anymore 
recommend you subclass a view, use a func and do stuff in there
nah just quit discord
Stilllll
It was the best
It is the best
It will be the best
dude it's not a xy I just ask if that's what I need for knowing when someone presses on a button
and still is the best
It will be remembered
sec
are you on dpy 2.0 btw
you make no sense
what's happening
how
@slate swan what if I get it through Spotify instead?
@disnake.ui.button(label="Traceback", style=disnake.ButtonStyle.red)
async def callback(self, button: disnake.ui.Button, intr: disnake.MessageInteraction):
await intr.send("msg", ephemeral=True)
self.value = True
self.children[0].disabled = True
self.stop()
wheres the event๐
in js there is an event "interactionCreate" so I just ask the event for this
if your on dpy 2.0
if its not copyright your good
it's different here, you subclass ui.View


How would it be copyright?
Oh so like regular songs then?
no such thing as a regular song
๐

Many people don't understand this logic 
welp thats how the world works 
sadly๐

is there any syntax like
if blah blah user clickes reaction:
await ctx.send('blahhh')
and whoever uses command and clickes reaction bot rplies to them only not others
Yes there is
check the user who reacted and compare it to the ctx.author
hmm indeed
but if your doing something like reaction roles or something use buttons
!d discord.on_reaction_add
discord.on_reaction_add(reaction, user)```
Called when a message has a reaction added to it. Similar to [`on_message_edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_message_edit "discord.on_message_edit"), if the message is not found in the internal message cache, then this event will not be called. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") instead.
Note
To get the [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") being reacted, access it via [`Reaction.message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Reaction.message "discord.Reaction.message").
This requires [`Intents.reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.reactions "discord.Intents.reactions") to be enabled.
Note
This doesnโt require [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") within a guild context, but due to Discord not providing updated user information in a direct message itโs required for direct messages to receive this event. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") if you need this and do not otherwise want to enable the members intent.
thats for buttons
!d disnake.ui.View.interaction_check
await interaction_check(interaction)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
A callback that is called when an interaction happens within the view that checks whether the view should process item callbacks for the interaction.
This is useful to override if, for example, you want to ensure that the interaction author is a given user.
The default implementation of this returns `True`.
Note
If an exception occurs within the body then the check is considered a failure and [`on_error()`](https://docs.disnake.dev/en/latest/api.html#disnake.ui.View.on_error "disnake.ui.View.on_error") is called.
interaction_check()
nah i am making among us bot lol
Nvm I read it wrong
๐ณ
Ok

@keen talon you use that emoji a lot lol
cause thats him
I was scrolling up to find my mention and that's all i saw



Why wouldn't I , it's so cute
fax
i just need to know checks now lol bcuz i dont know advance python a lot but basic ik so i am coming yt....ty guys once again โค๏ธ
Replies to them in like dms?
the same channel
yw and its easy its just methods
yeah python really easy bcuz java goes brrrrrrrrrrrrrr
Oh then yea do what that guy said and set up reaction role and when someone clicked it the bot sends a message @ing the user. Or use pycord and make buttons and do the same thing
any fork has the View class
v2 dpy does?
...
class discord.ui.View(*, timeout=180.0)```
Represents a UI view.
This object must be inherited to create a UI within Discord.
New in version 2.0.
Disnake, pycord, etc
I thought that was your question and my answer lol
oh lol
Wuts ur questions?
print("hello")
#bot-commands
Okay
I don't have one
Lol they are saying hello to us ig 
Then I am so confused on your message
and you start it with the prefix ! and since its eval use e
Nice name 
hi ig lol
nah, I thought okimii-san had a question, so I answered
yeah checks are easy tho just simple methods lol
its fine SniperGlitcherz-chan
yeah
What would be better, using the new timeout feature or sticking with regular muting roles?
so did discord.py finally got an update?
timeouts are easy but custom mutes can have more things to them
No
wont
Like?
a history and more time
i never saw this before
What can they have more to?
^
timeouts max i think were 28 days
Plus perm mutes
!d disnake.Member.timeout
await timeout(*, duration=..., until=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Times out the member from the guild; until then, the member will not be able to interact with the guild.
Exactly one of `duration` or `until` must be provided. To remove a timeout, set one of the parameters to `None`.
You must have the [`Permissions.moderate_members`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.moderate_members "disnake.Permissions.moderate_members") permission to do this.
New in version 2.3.
Ah more time understandable, and wym by history? I mean, u can also log number of time timeouts lol
Crap
a history of crimes

Btw I don't think someone will wanna mute someone for more than 28 days... Kick them instead lol
Crimes of Grindelwald
** Supports up to 28 days in the future.**


In a database you can log the mutes they've had and then create a command to read that and see the users mute history
Yea ik
history*
That's what am saying
I mean, ik discord does things without thinking but still...
Being perm muted is way worse than kick or ban
yeah
But is the mute this is low in the hierarchy it won't work
But Ig you could add move_role to it tho
wdym
timeout doesnt give you a role
yes it would be the lowest
That's why you'd have to as move role correct
- set a max limit for mute: like 1day
- save the mute in a db: you don't want a poor guy being muted forever because you restarted your bot
why
If mute longer than 1 day don't put it in the db
Ok say you have a member role and the mute role is below the member role. The mute role won't work because the permissions from the member role will override kt
cough cough how you know that๐งโโ๏ธ
Morning y'all :3
3am๐
Night bro...
Up early I see
mute role should always be the lowest
Um no
no i just havent slept๐
It won't work then
wut
Just use the timeout function from discord...
temout๐ง
Yeah dutch autocorrect
Anytime above the mute role will NOT be affect by it
then make it the lowest
just put the mute standard in the db I'd say, time doesn't matter
๐คฆโโ๏ธ
Which Library is mostly used nowadays for discord bots?
1. admin
2. staff
3. other
4. mute
Disnake
!pypi disnake
Disnake , pycord ,
Not pycord..

Pycords internals are pretty bad and no docs
personal preference
FastAPI = L E G E N D
Ok now I'm confused af cuz when I was testing it, it had to be above the other roles to work

BUT now I just muted myself and got muted even tho the role is below me
yes you can add roles that are below you
cuz you are arceus
hehe smart boi
nope
hand over to pros then
see pro knows it all

Seeing as we are a python server we don't really help with external build errors
bruh
look at the top
it says it all
But you can send over the code for us to check.
INFO:
But yeah I recommend using only one version of aiofiles
@shy elm you okay??
Read the first Line of your ss
^
No I'm not
I need the remove thing
How I get the help remove
wdym
help_command=None inside the bot vars
Where you set the prefix aswell
constructor*
They don't know what that is
!d discord.ext.commands.Bot
class discord.ext.commands.Bot(command_prefix, help_command=<default-help-command>, description=None, **options)```
Represents a discord bot.
This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") you can do with this bot.
This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.

just set it to None or subclass the help command
If we are going to talk technical we couldn't help half the people here
you have a point there

I found what I needed we good
Next time don't swear towards other people.
It was to the bot
you starting swearing to the bot?!?!?๐ญ
Yea don't want close now bro
What's happening
Nothing much
I read help commands ๐ญ

Can i see bot's log on discord with command or smthng?
bots log?
heyyy <33
let's ignore okimii
๐

stop stalking me

<33
๐คจ

Error messages etc.
lol
!d logging
Source code: Lib/logging/__init__.py...
!d discord.ext.commands.Bot.on_command_error
await on_command_error(context, exception)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
The default command error handler provided by the bot.
By default this prints to [`sys.stderr`](https://docs.python.org/3/library/sys.html#sys.stderr "(in Python v3.9)") however it could be overridden to have a different implementation.
This only fires if you do not specify any listeners for command error.
i mean all errors. Syntax error, module errors etc.
if thats what you mean im not sure
!d logging ๐
Source code: Lib/logging/__init__.py...
yes ^
!d isinstance
isinstance(object, classinfo)```
Return `True` if the *object* argument is an instance of the *classinfo* argument, or of a (direct, indirect, or [virtual](https://docs.python.org/3/glossary.html#term-abstract-base-class)) subclass thereof. If *object* is not an object of the given type, the function always returns `False`. If *classinfo* is a tuple of type objects (or recursively, other such tuples) or a [Union Type](https://docs.python.org/3/library/stdtypes.html#types-union) of multiple types, return `True` if *object* is an instance of any of the types. If *classinfo* is not a type or tuple of types and such tuples, a [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "TypeError") exception is raised.
Changed in version 3.10: *classinfo* can be a [Union Type](https://docs.python.org/3/library/stdtypes.html#types-union).
Thx
My error handler hella fancy
Ok
my on command error
async def on_command_error(self, ctx, error):
embed = disnake.Embed(
title="Command Error",
description=f"``{error}``",
color=0xffffff,
timestamp=datetime.datetime.utcnow())
await ctx.send(embed=embed)
```
๐
mines simple
async def on_command_error(self, ctx, error):
await ctx.send(error)
``` why bother at that point
backslashes dont work
bad discord

This typehint is mine though
Related to low level component interface
does DPY support ui buttons,if yes can someone link me the docs
!d disnake.logging
disnake logs errors and debug information via the logging python module. It is strongly recommended that the logging module is configured, as no errors or warnings will be output if it is not set up. Configuration of the logging module can be as simple as:
import logging
logging.basicConfig(level=logging.INFO)
``` Placed at the start of the application. This will output the logs from disnake as well as other libraries that use the `logging` module directly to the console.
The optional `level` argument specifies what level of events to log out and can be any of `CRITICAL`, `ERROR`, `WARNING`, `INFO`, and `DEBUG` and if not specified defaults to `WARNING`.
# Miniboss Channel Unlock/Lock
@commands.Cog.listener()
async def on_message(self, message):
Unlock = discord.PermissionOverwrite(send_messages=True)
Lock = discord.PermissionOverwrite(send_messages=False)
Role = message.guild.default_role
if message.channel.id == 814207750342705164 and message.content.lower().startswith("rpg miniboss"):
await message.channel.set_permissions(Role, overwrite=Unlock)
await message.channel.send(f":white_check_mark: Unlocked {message.channel.name}")
await asyncio.sleep(1.0)
if message.channel.permissions(Role, overwrite=Unlock):
await message.channel.set_permissions(Role, overwrite=Lock)
await message.channel.send(f":white_check_mark: Locked Down {message.channel.name}")
I'm trying to check if channel is locked, and if it isn't, to lock it. But Idk how to do the if command
In the development version yes, you can see examples here
https://github.com/Rapptz/discord.py/blob/master/examples/views/confirm.py
Random commands should be used in #bot-commands :)
Oh okay
Ik lol
I was checking this
Big smh that we still gotta maker functions like this ```py
async def member_get_or_fetch(guild: Guild, id: int) -> Member:
return guild.get_member(id) or await guild.fetch_member(id)
await get_or_fetch_member(member_id, *, strict=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Tries to get a member from the cache by ID. If fails, it fetches the user from the API and caches it.
Has an disnake.Guild.getch_member alias
!d disnake.Guild.getch_member
await getch_member(member_id, *, strict=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Tries to get a member from the cache by ID. If fails, it fetches the user from the API and caches it.
What's that? Show your requirements.txt file @slate swan
Hey @slate swan!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
@maiden fable
Wait, just edit the file to include only those modules, which u have imported
oki
!d discord.Guild.owner
property owner: Optional[discord.member.Member]```
The member that owns the guild.
tysm
help same old cog error for me'
is there a file called ./cogs
no
your folder is named cog not cogs
happens
# Miniboss Channel Unlock/Lock
@commands.Cog.listener()
async def on_message(self, message):
Unlock = discord.PermissionOverwrite(send_messages=True)
Lock = discord.PermissionOverwrite(send_messages=False)
Role = message.guild.default_role
if message.channel.id == 814207750342705164 and message.content.lower().startswith("rpg miniboss"):
await message.channel.set_permissions(Role, overwrite=Unlock)
await message.channel.send(f":white_check_mark: Unlocked {message.channel.name}")
await asyncio.sleep(40.0)
if message.channel.permissions == Unlock:
await message.channel.set_permissions(Role, overwrite=Lock)
await message.channel.send(f":white_check_mark: Locked Down {message.channel.name}")
``` Someone help me with the IF part. I need to check if channel is unlocked
i dont get what your trying to do
Having a problem with selects
I think they want to see if there are overwrite permissions send_message, if not lockdown or smth
please come in #help-apple to Help me
dont x-post
Means
Can u help?
!d discord.Channel.overwrites_for to get channel overwrites
No documentation found for the requested symbol.
BRB
Please help
In #help-apple
I need help, me asked this question many time but didn't get the answer I want
!d discord.TextChannel.permissions_for to see if send_messages is True or not, e.g ```py
if ctx.channel.permissions_for(ctx.guild.default_role).send_messages:
print("Is unlocked")
else:
print("Is locked")
permissions_for(obj, /)```
Handles permission resolution for the [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") or [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role").
This function takes into consideration the following cases...
I'm creating a mute command, but I'm having problems even though the console has no errors. Send the message but do not change the user, here my code:
@commands.has_permissions (kick_members = True)
async def mute (ctx, member: discord.Member):
role = discord.utils.get (ctx.guild.roles, name = "Mutato")
guild = ctx.guild
if role not in guild.roles:
perms = discord.Permissions (send_messages = False)
await guild.create_role (name = "Mutato", permissions = perms)
await member.add_roles (role)
await ctx.send ("** Mutato ** role created and assigned to user.")
else:
await member.add_roles (role)
embed = discord.Embed (description = f "I mutato {member.mention}", color = discord.Colour.green ())
await ctx.send (embed = embed)```
Uhhh, role will either be None or an instance of discord.Role, if the role is there in guild.roles
also when u create role, u never fetch it again to be used member.add_roles()
so it will try to give a role that still is None, even if it is created
and how can i fix?
!d disnake.Member.timeout also consider changing to disnake and use this right there
await timeout(*, duration=..., until=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Times out the member from the guild; until then, the member will not be able to interact with the guild.
Exactly one of `duration` or `until` must be provided. To remove a timeout, set one of the parameters to `None`.
You must have the [`Permissions.moderate_members`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.moderate_members "disnake.Permissions.moderate_members") permission to do this.
New in version 2.3.
Yea
if u misstaken can u send timeout with duration 0, and it overwrites and unmutes?
oh set duration to None, removes it
Hm ok, thanks
seems like discord about to clean up verified bots, https://support-dev.discord.com/hc/en-us/articles/4404772028055
commands.when_mentioned_or() ?
nope , commands.when_mentioned , it's used to make the bot mention your prefix
you would be able to acess the message content if the bot was pinged in the message
Lol this is getting a meme
@slate swanso they basicly wants to remove all prefixes ๐
They basically want us to use the ugly slash commands for our bots
don't think anyone would like to use mentions as prefix lol
Especially for Mobile users
Did you get it fixed?
Ignoring exception in on_application_command_autocomplete
Traceback (most recent call last):
File "C:\Users\eboss\AppData\Local\Programs\Python\Python39\lib\site-packages\disnake\client.py", line 515, in _run_event
await coro(*args, **kwargs)
File "C:\Users\eboss\AppData\Local\Programs\Python\Python39\lib\site-packages\disnake\ext\commands\interaction_bot_base.py", line 1357, in on_application_command_autocomplete
await self.process_app_command_autocompletion(interaction)
File "C:\Users\eboss\AppData\Local\Programs\Python\Python39\lib\site-packages\disnake\ext\commands\interaction_bot_base.py", line 1274, in process_app_command_autocompletion
await slash_command._call_relevant_autocompleter(inter)
File "C:\Users\eboss\AppData\Local\Programs\Python\Python39\lib\site-packages\disnake\ext\commands\slash_core.py", line 537, in _call_relevant_autocompleter
await inter.response.autocomplete(choices=choices)
File "C:\Users\eboss\AppData\Local\Programs\Python\Python39\lib\site-packages\disnake\interactions\base.py", line 978, in autocomplete
await adapter.create_interaction_response(
File "C:\Users\eboss\AppData\Local\Programs\Python\Python39\lib\site-packages\disnake\webhook\async_.py", line 216, in request
raise NotFound(response, data)
disnake.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
``` any way to suppress this?
when this happens?
@slate swanhey! you here! thank god
i wanna know that as randint returns random integer...is there anything that makes randreactions
This happends if a big list gets passed inside autocomplete it cries.
no , nothing like that exists
You can have a list of reactions and use random.choice though
^
i am not getting it.. can you pls explain more further?
random.choice(guild.emojis)
thats only guilds emojis tho
!d random.choice
random.choice(seq)```
Return a random element from the non-empty sequence *seq*. If *seq* is empty, raises [`IndexError`](https://docs.python.org/3/library/exceptions.html#IndexError "IndexError").
I have python but why this happen?
nah... i want like see my bots is sending an embed message ok.....then bot itself reacts to that embed and i want it choses 1 reaction as random out of those reactions
reactionlist = ["๐", .. etc]
reaction = random.choice(reactionlist)
and then i click on any random reaction if its true it says hurray correct and if false it says oh no
thats what i wanted ty
Try py
@karmic lintelhttps://github.com/python-discord/bot/blob/main/bot/exts/fun/duck_pond.py i found this the other day, maybe u can take a look at it too
its basicly same, but u gonna find a duck
ok ty โค๏ธ
@honest vesselif you wont mind may i dm you?.... not for this purpose
not working
Did you install python with the installer provided on the website?
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "main.py", line 163, in help
label = event.component[0].label
TypeError: 'Select' object is not subscriptable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1353, in invoke
await super().invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'Select' object is not subscriptable```
await ctx.send("Testing selects for help command!",embed=embed_hm,
components=
[Select(placeholder="Command Category which you want to see!",
options=[
SelectOption(
label="Option 1",
value="option1",
description="See option 1",
emoji="๐"
),
SelectOption(
label="Option 2",
value="option2",
description="See option 2",
emoji="๐"
),
SelectOption(
label="Option 3",
value="option3",
description="See option 3",
emoji="๐"
),
])]
)
e1 = discord.Embed(title="embed1", description="a really exciting embed")
e2 = discord.Embed(title="embed2", description="a really exciting embed")
e3 = discord.Embed(title="embed3", description="a really exciting embed")
while True:
try:
event = await client.wait_for("select_option", check=None)
label = event.component[0].label
if label == "Option 1":
await event.respond(type=InteractionType.ChannelMessageWithSource,ephemeral=True,
embed=e1
)
elif label == "Option 2":
await event.respond(type=InteractionType.ChannelMessageWithSource,ephemeral=True,embed=e2)
elif label == "Option 3":
await event.respond(type=InteractionType.ChannelMessageWithSource,ephemeral=False,embed=e3)
This is my full code
Please help anyone
@trail flower helped me a lot but apparently it couldn't make it though also
Please help anyone
@zealous dagger :x: Your eval job has completed with return code 1.
001 | File "<string>", line 25
002 | e1 = discord.Embed(title="embed1", description="a really exciting embed")
003 | IndentationError: unexpected indent
(it, not he)
@zealous dagger :x: Your eval job has completed with return code 1.
001 | File "<string>", line 1
002 | Not fine
003 | ^^^^
004 | SyntaxError: invalid syntax
Now fine
yes i did, before this happen i follow this tutorial, https://youtu.be/CO4BGZOuUkM
then this error appear!
Run csharp and .NET program in visual studio code on windows
Hey, guys in this video I'm going to show you how you can configure visual studio code (#vscode) to run C# program on #Windows10 OS (operating system) visual studio code C# and I'm also gonna show you how you can run two sample user input program on #vscode_csharp dotnet core in vscod...
Looks like you just forgot to check the "add python to path" option
you need to either run setup again, marking that option
or do it manually
@soft depot can you help bud
u can try run the full path to python.exe
like "C:......\python39\python.exe" "c;...\fullpath\yourscript.py"
@slate swanheiye
I was trying make the following commands with but it is not working.
class Moderation(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command(aliases = ['purge'])
@commands.has_permissions(manage_messages = True)
async def clear(self, ctx, amount = 1):
await ctx.channel.purge(limit = amount+1)
await ctx.send(f'{amount} number of messages have been deleted from the channel', delete_after= 5)
@commands.command(aliases = ['boot'])
@commands.has_permissions(kick_members = True)
async def kick(self, ctx, member: discord.Member, *, reason= None):
await member.kick(reason=reason)
await ctx.send(f'{member.mention} have been kicked!', delete_after=15)
@commands.command(aliases = ['hammer'])
@commands.has_permissions(ban_members = True)
async def ban(self, ctx, member: discord.Member, *, reason= None):
await member.ban(reason=reason)
await ctx.send(f'{member.mention} have been banned!', delete_after=15)
@commands.command(aliases = ['forgive'])
@commands.has_permissions(ban_members = True)
async def unban(self, ctx, member):
ban_list = await ctx.guild.bans()
member_name, member_discriminator = member.split('#')
for ban_entry in ban_list:
user = ban_entry.user
if user.name and user.discriminator == member_name and member_discriminator:
await ctx.guild.unban(user)
await ctx.send(f'{user.name} have been unbanned', delete_after=15)
break
def setup(bot):
bot.add_cog(Moderation)
error:
Extension 'cog.Moderation' raised an error: TypeError: cogs must derive from Cog
because you didnt pass in bot while adding cog
Making a cog without passing bot in __init__ is fun
๐
Please help anyone
@slate swan you help
event.component[0]
You helped before lso
Is the issue
You usre
Pretty sure it's not a list
Then why are you subscripting it
What library do u use
import discord
import os
import discord
import random
from discord.ext import commands, tasks
from PIL import Image
import youtube_dl
from pypresence import Presence
from discord_components import Button, Select, SelectOption, ComponentsBot,DiscordComponents
from discord_interactions import InteractionType
import asyncio
from typing import Optional, Set
import time
Dpy 2.0 then?
and the imports in the cog?
probably not , since components is not a thing there
It's view
Oh no discord components
lmao
So what
Why just why ๐ฅฒ
The good developer is the one that is able to leave the comfort zone and search for a better solution
Sidenote , lucas' unban command is bad
Class is much more convenient to use once you get used to it
U don't need to learn class for using views
I know but then I have to make every command in class
I have used it before
Not really ๐
The class
You can put the view classes to the separated python module and then just import them
viewโย โ=โย โViewโ()
โย ย ย ย ย ย ย ย โbuttonsโย โ=โย [
โย ย ย ย ย ย ย ย ย ย ย ย โButtonโ(
โย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย โstyleโ=โButtonStyleโ.โurlโ,
โย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย โlabelโ=โ"Inviteย Bot"โ,
โย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย โurlโ=โctxโ.โbotโ.โinvite_urlโ,
โย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย โemojiโ=โ"๐"โ,
โย ย ย ย ย ย ย ย ย ย ย ย ),
โย ย ย ย ย ย ย ย ย ย ย ย โButtonโ(
โย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย โstyleโ=โButtonStyleโ.โurlโ,
โย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย โlabelโ=โ"Vote"โ,
โย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย โurlโ=โf"https://top.gg/bot/โ{โctxโ.โbotโ.โuserโ.โidโ}โ/vote"โ,
โย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย โemojiโ=โ"๐"โ,
โย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย โdisabledโ=โTrueโ,
โย ย ย ย ย ย ย ย ย ย ย ย ),
โย ย ย ย ย ย ย ย ย ย ย ย โButtonโ(
โย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย โstyleโ=โButtonStyleโ.โurlโ,
โย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย โlabelโ=โ"Support"โ,
โย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย โurlโ=โf"https://discord.gg/โ{โctxโ.โbotโ.โserver_inviteโ}โ"โ,
โย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย โemojiโ=โ"๐"โ,
โย ย ย ย ย ย ย ย ย ย ย ย ),
โย ย ย ย ย ย ย ย ]
โย ย ย ย ย ย ย ย โforโย โbuttonโย โinโย โbuttonsโ:
โย ย ย ย ย ย ย ย ย ย ย ย โviewโ.โadd_itemโ(โbuttonโ)
โย ย ย ย ย ย ย ย โawaitโย โctxโ.โreplyโ(โembedโ=โembedโ,ย โviewโ=โviewโ)```
My buttons are workin well
Example
What's the issue then
I never tried the library u r using
Ok which one did you try
What's the actual error
I can work with
This is the error
Ok
yes , without any external libraries
!pypi nextcord
A Python wrapper for the Discord API forked from discord.py
How do I make a page system for displaying info through embed?
Pagination
Hey @brittle flume!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
class disnake.ui.View(*, timeout=180.0)```
Represents a UI view.
This object must be inherited to create a UI within Discord.
New in version 2.0.
!d disnake.ui.Select
class disnake.ui.Select(*, custom_id=..., placeholder=None, min_values=1, max_values=1, options=..., disabled=False, row=None)```
Represents a UI select menu.
This is usually represented as a drop down menu.
In order to get the selected items that the user has chosen, use [`Select.values`](https://docs.disnake.dev/en/latest/api.html#disnake.ui.Select.values "disnake.ui.Select.values").
New in version 2.0.
subclass View, add select in
in a cog I can have two commands.Cog.listeners() both for async def on_message(self, message) exactly the same
It is a rule command with cog
@commands.command(aliases = ['rules'])
async def rule(self, ctx, number=None):
await with open("rules.txt", 'r') as f:
rules = f.read()
rule = f.readlines()
if number == None:
await ctx.send(rules)
else:
ruleEmbed = discord.Embed(title = f'Rule {number}', discription = f'{rule[int(number)+1]}', color =0x552E12)
await ctx.send(embed = ruleEmbed)
Input:
.rule 4
Error:
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: IndexError: list index out of range
how do I load jishaku in disnake
Vscode?
Ok
heyy. I have this code but it gives this error. (its a server ip not mine)```python
@commands.command()
async def test(self, ctx):
r1 = requests.get(f'http://51.89.34.216:30802/players.json')
events1 = r1.json()
name = str(config['servername'])
em = nextcord.Embed(title=':green_circle: Server Is Online!', description=f"ฮฮนฮฑ ฮฝฮฑ ฯฯ
ฮฝฮดฮตฮธฮตฮฏฯฮต ฯฯฮฟฮฝ {name}ฮฮฝฮฟฮฏฮณฮตฯฮฑฮน FiveM, ฯฮฑฯฮฌฯฮต F8 ฮบฮฑฮน ฮณฯฮฌฯฮตฯฮฑฮน ", color=orange, timestamp=datetime.now())
em.set_author(name=name)
em.add_field(name = 'lolo:', value= int(events1['id'])+"\n", inline = True)
await ctx.send(embed=em)
```-Command raised an exception: TypeError: list indices must be integers or slices, not str```
Help me(
Command isn't working
@bot.command(aliases=["nukechannel", "channelnuke", "n"])
@commands.is_owner()
async def nuke(ctx):
channel = ctx.channel
author = ctx.author
await ctx.message.delete()
def check(m):
return m.author == author and m.channel == channel
await ctx.send(f"are you sure you want to delete all messages in {channel} (**y**/**n**")
msg = await bot.wait_for("message", check=check)
if msg == "yes" or msg == "y":
try:
await channel.clone(reason=f"{author} requested channel nuke")
await channel.delete(reason=f"{author} requested channel nuke")
await author.send(f"I nuked <#{channel.id}> for you :thumbsup:")
except:
channel.send("I'm missing `MANAGE_CHANNEL` perms")
elif msg == "no" or msg == "no":
await channel.purge(limit=2)
await ctx.send("nuke cancelled :thumbsup:", delete_after=5)
else:
pass
anyone?
not me
okay thanks for the information
can anyone help?
what error?
don't think someone would help u with a nuke command
read the command
"are you sure you want to delete all messages in {channel}"
its nicknamed nuke cuz other verified bots call it that too
Mhm makes sense
it works by cloning the channel and deleting the last one to "purge" all messages
Your issue?
stops at the wait for
i type "y" and it doesn;t do anything
no error printed either
Msg is a discord.Message object so you'd be using py if msg.content=="yes"...
Like this
!d discord.Message.content
The actual contents of the message.
ahhh
Pycord is not supported in the bot , most of people here use Disnake and nextcord forks so they exist
okay thanks for the information
also how would I send a message do the newly cloned channel?
would I store it in a var?
yeah , store the cloned channel in a variable , and use variable.send
appreciate it
#help-cake help for regxp -> find banned words (advanced?)
what's the check?
@commands.has_permissions(ban_members = True)
async def ban(ctx, member : discord.Member, *,reason=None):
if member == None or member == ctx.message.author:
await ctx.channel.send("You cannot ban yourself")
return
if reason == None:
reason = "Being bad!"
message = f"You have been banned from {ctx.guild.name} for {reason}"
await member.send(message)
await member.ban(reason=reason)
await ctx.send(f"{member} is banned!")
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 50007): Cannot send messages to this user ```
help
Error says all.
it was working before idk what happened
The user has private messages disabled or does not share a server with the bot.


