#discord-bots
1 messages · Page 454 of 1
Ghost ping, great
we all gonna get banned
wym
You already pinged Moderators
.....?
admins have their do not disturb on
Still, ghost ping 
what ping
Uh use ctx.command to get the command used?
Well a moderator has already seen this channel (pgp verified), so I am sure he's taking the required action
Yeah
what are u people trying to make a music bot with? if not youtube
!mute 878071532163846184 Investigating
:incoming_envelope: :ok_hand: applied mute to @steel flower until <t:1631003220:f> (59 minutes and 58 seconds).
Let's get back on topic please guys
👍
also, back to the removing the help command thing, do u want to make something like this instead?

help_command=None
in bot constructor
i do this
bot.remove_command("help")
help_command = None is better to use
not really tbh
up to you what you want to do tho
it's just doing bot.remove_command is dynamically doing it
people in this channel told me before to just use bot.remove_command("help") so imma stick with it
ok
well ya but if u dont code it to be added again it just removes it
but like im just gonna say it'll be suggested to do none as help command
yes, same for remove_command right?
ya i think
yes, so same thing implies
i havent worked on a bot in months so im rusty on a lot of the stuff lol
???
Literally right here
right there bruh
h o w
it's member
not user
discord.Member
user and member objects are 2 diff things??
yes of course
so far my bots do all that i need them to do and i dont have an idea for another bot
!d discord.Member
class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Guild "discord.Guild").
This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/stable/api.html#discord.User "discord.User").
`x == y` Checks if two members are equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/stable/api.html#discord.User "discord.User") instances too.
`x != y` Checks if two members are not equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/stable/api.html#discord.User "discord.User") instances too.
`hash(x)` Returns the member’s hash.
`str(x)` Returns the member’s name with the discriminator.
Mb 🤣
good for you
so discord.Member object would be like this?
... help(ctx, member = discord.Member):?
yep
wait no
nope
typehint
Oh wait
member: discord.Member
:
yes
yeah i forgot typehint is a thing
alr thx for da help
oh so would I have to use member intents if im using a on_message events to get discord.Member object? @slate swan
or is there an easier way WITHOUT having the member to give input
yeah
saylesssss
@client.command()
async def join(self,ctx):
if ctx.author.voice is None:
await ctx.send("You're not in a voice channel")
voice_channel = ctx.author.voice.channel
if ctx.voice_client is None:
await voice_channel.connect()
else:
await ctx.voice_client.move_to(voice_channel)``` it just doesnt want to work
does anybody wants to collab with me for making a bot ?
Are you inside a cog
nope
What kind of
wdym ?
what kind of bot mate
there are various types of bot mate
You can't call a verification bot a moderation bot
music/moderation/leveling/economy/anime/gaming
yeah
How do i get a role hexcode?
ctx.author
show the snippet where you load the extension
Try rules instead of Rules
? lol why
sorry got it already
You didn't have to delete everything lmao
it was a long message and took lots of space so
nothing to worry 'bout that
how to get channel count
call len on Guild.channels
guild = ctx.guild
clist = await guild.fetch_channels()
count = len(clist)
Wouldn't want to do an API call for no reason when you can just use guild.channels
Is role: discord.Guild.role a thing?
discord.Guild.role isn't a thing
why fetch?
You probably mean discord.Role
I am trying to get a role information
I think RoleConverter exists
it does
So that'd work
.roles is an attr
of discord.Guild
i also want all roles which exist in server
Guild.roles
ctx.guild.role?
not role
What should be args
roles
yhnx
paste the code instead?
What's the problem anyway
@commands.command()
async def roleinfo(self, ctx, role : discord.Roles):
roleembed = discord.Embed(title =f"{role.name} information", color = discord.Color.random(), timestamp = datetime.datetime.utcnow())
roleembed.add_field(name = "ID", value = role.id)
roleembed.add_field(name = "Name", value = role.name)```discord has no atrr Roles
channel categories??
Guild.categories
and wht abt the owner of the server
use Guild.owner_id and Guild.get_member
could u right it cause i did not get you sorry
write
plsssss
no
ohk
!d discord.Guild.get_member
get_member(user_id)```
Returns a member with the given ID.
!d discord.Guild.owner_id
The guild owner’s ID. Use Guild.owner instead.
role.members gives a list of members , how do i get the names of the members from that list?
Probably learn how to use for loop 🙂
thnx got it
a for loop isn’t needed here
thnx @hasty iron
list comp is also a for loop
for member in role.members
it’s different
something?
Yes
idk what a list comp is
no
[member.name for member in Role.members]
thnx for helping
try it and see
hm it prints just 1 name
do this
help
ye
so
any help
!d discord.Member.bot
bot```
Equivalent to [`User.bot`](https://discordpy.readthedocs.io/en/stable/api.html#discord.User.bot "discord.User.bot")
how can i reverse the postion of roles?
you can use that to get it
code?
async def roleinfo(self, ctx, role : discord.Role):
members = [member.name for member in role.members]
perm_string = ', '.join([str(p[0]).replace("_", " ").title() for p in role.permissions if p[1]])
date_format = "%d %b %Y %I:%M %p"
roleembed = discord.Embed(title =f"{role.name} information", color = discord.Color.random(), timestamp = datetime.datetime.utcnow())
roleembed.add_field(name = "ID", value = role.id)
roleembed.add_field(name = "Name", value = role.name)
roleembed.add_field(name = "Position", value = role.position)```
i want it to count the top most role as pos 1 and so on, insead of counting @lament oar one role as pos 1
Is there any discord.py fork yet, which has support for slash commands in cogs?
no stable fork yet
Tell me the unstable ones
I'm waiting too lmao
xD
huh
roles[-1] returns all roles except everyone
index it to remove the first one that'll always come
like by default @ everyone role has postion 0, then the role just above it get s the postion 1
its ctx.guild.roles[1:] ,
i want to the role postion that is 1 by default gets the last postion
so for the Position field in your embed right
yes
so can't you just do int(role.position) - 1 or something?
oh edit the role?
wait
take a look at this
the role PsyDuck i on the top of the list
and the Role Nurse at the bottom
normally while getting postion
the nurse role get the postion 1
and the Psyduck role gets the last postion
is that what you want? if not what do you want?
i did
didn't work?
rolesList = ctx.guild.roles rolesList.reverse() for role in rolesList:
it give every role postion to 0
s
let me try
roles = ctx.guild.roles[::-1]
!ban
nope didnt work
??
.ban
[::-1] makes the indexing reverse? @slate swan
!d discord.Guild.ban
await ban(user, *, reason=None, delete_message_days=1)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Bans a user from the guild.
The user must meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/stable/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.
You must have the [`ban_members`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.ban_members "discord.Permissions.ban_members") permission to do this.
ok thanku
i used implemented mondodb in my bot and it is giving me this error:
pymongo.errors.OperationFailure: bad auth: Authentication failed., full error: {'ok':0, 'errmsg' : bad auth....
can someone fix this
how do i use cog
not ext
!d discord.ext.commands.Bot.cogs
cogs```
A read-only mapping of cog name to cog.
can someone help me , please.
not working
Regenerate your Token 
description
not decription
sounds like a weird decease
and you're addicted to f-strings
lol
f"Member Count"
yeah, just some python basics lmao
@slate swan
learn how to use the docs
when someone tells you
discord.Member.bot,
the discord.Member has to be replaced with a member object
I need a answer. How do we get rate limited and till how much time
a couple of minutes
for doing too many API calls
when you get ratelimited, you know you've done something illegal
illegal 👀
ToS breaking
illegal


Replit is ready to ruin new developers
They also got a video tutorial tab
hasn't it already

I just saw it
freecodecamp's been advertising it for a long time
Suggesting one of the best almost outdated tutorials
oh, that's the freecodecamp tutorial
fuq bru

3rd line
c = discord.Client()
triggered
Atleast I didn't write it bot = discord.Client 
discord.Bottum

What am I doing illegal
Yes
Like crossing it's max rate limit will get you ban for a few minutes or hours
And you probably crossed it
await ctx.send("wanna get ratelimited")
#illegal```
async def on_ready():
while True:
await client.change_presence(...)
await asyncio.sleep(10)
await client.change_presence(...)
await asyncio.sleep(10)
More illegal
there's sleep
so no
while True:
10 secs sleep is nothing for presence changes
And most people do it every 10 secs
but putting things in on_ready can't be no good anyways
lmao why would you do it in this way
i have error handler but it doesnt work:
code:
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandOnCooldown):
em = discord.Embed(title="Failed to run the command!", description="This command is on cooldown. Please try again after {round(error.retry_after, 1)} seconds.")
elif isinstance(error, commands.MissingPermissions):
em = discord.Embed(title="Failed to run the command!", description="\nYou dont have permission to run this command")
elif isinstance(error, commands.MissingRequiredArgument):
em = discord.Embed(title="Failed to run the command!", description=f"{error.param} argument is requierd")
elif isinstance(error, commands.CommandNotFound):
em = discord.Embed(title="Failed to run the command!", description=f"nCommand not found!")
else:
em = discord.Embed(title="Failed to run the command!", description=f"Oh no! Something went wrong while running the command!")
await ctx.send(embed=em)
you have task loops for this
unwrap your error
error = getattr(error, 'original', error)

Your errors got packed in CommandInvokeError
oh
ok
Also where it is defined?
what? Error?
The func
do you have @bot.event?
I don't remember we need any decorator syntax or not for error handlers 

yea
I have a question guys
?
any output tho?
nope
try error = getattr(error, 'original', error) on top
ok
still no output. The error doesnt show in the console too
Is there like a way to inplement a status like uptimerobot or npm2 to ur discord bot, it’s hosted on windows vps tag if u have an answer or dm me
i have that
My error handler is very simple.
@client.event
async def on_command_error(ctx, error):
await ctx.send(error)

but i want an embed per error
That works fine.
Do you have @bot.event just at the top of the on_command_error function?
Imagine using bot to define the commands 
can i use .mp4 in embed.set_image ?
@compact field u cant
how can i use .mp4 in embed ?
i dont know
Other than png and images ofc
yyea
pretty sure you can put a GIF in set_image
U can but not .mp4's
My bot not responding to members only for the owners guild
Why?
@client.command()
@commands.guild_only()
async def avatar(ctx, user: discord.User = None):
if user == None:
user = ctx.author
e = discord.Embed(title=f"{user.display_name} Avatar")
e.set_image(url=user.avatar_url)
e.set_footer(text=f"Requested By {ctx.author}",
icon_url=ctx.author.avatar_url)
await ctx.reply(embed=e)
even that doesnt work
.
@boreal ravine
the full one
It is the full onw
Include the decorator
wait
@bot.event
async def on_command_error(ctx, error):
error = getattr(error, 'original', error)
if isinstance(error, commands.CommandOnCooldown):
em = discord.Embed(title="Failed to run the command!", description="This command is on cooldown. Please try again after {round(error.retry_after, 1)} seconds.")
elif isinstance(error, commands.MissingPermissions):
em = discord.Embed(title="Failed to run the command!", description="\nYou dont have permission to run this command")
elif isinstance(error, commands.MissingRequiredArgument):
em = discord.Embed(title="Failed to run the command!", description=f"{error.param} argument is requierd")
elif isinstance(error, commands.CommandNotFound):
em = discord.Embed(title="Failed to run the command!", description=f"nCommand not found!")
else:
em = discord.Embed(title="Failed to run the command!", description=f"Oh no! Something went wrong while running the command!")
await ctx.send(embed=em)
do any errors pop up? like pyflakes
nope
u need to send the embed in every if/elif statement u add
um
-.-
still no response
show the code again
@be
async def on_command_error(ctx, error):
error = getattr(error, 'original', error)
if isinstance(error, commands.CommandOnCooldown):
em = discord.Embed(title="Failed to run the command!", description="```py\nThis command is on cooldown. Please try again after {round(error.retry_after, 1)} seconds.```")
await ctx.send(embed=em)
elif isinstance(error, commands.MissingPermissions):
em = discord.Embed(title="Failed to run the command!", description="```py\nYou dont have permission to run this command```")
await ctx.send(embed=em)
elif isinstance(error, commands.MissingRequiredArgument):
em = discord.Embed(title="Failed to run the command!", description=f"```py\n{error.param} argument is requierd```")
await ctx.send(embed=em)
elif isinstance(error, commands.CommandNotFound):
em = discord.Embed(title="Failed to run the command!", description=f"```py\nCommand not found!```")
await ctx.send(embed=em)
else:
em = discord.Embed(title="Failed to run the command!", description=f"```py\nOh no! Something went wrong while running the command!```")
await ctx.send(embed=em)
await ctx.send(embed=em)
@be ?
add await ctx.send(embed=em) to the if/elif statements
i edited
can someone explain how should i use on_member_unban to send a msg in a channel when the user gets unbanned?
WHATVDIDNU DO 😭
why the codebloks in the errors smh
wait
@slate swan can u like remove the ```py so i can edit it?```
yea
send me the code in DMs
why emoji.user is coming None
!d discord.Emoji.user
The user that created the emoji. This can only be retrieved using Guild.fetch_emoji() and having the manage_emojis permission.
@stiff nexus ^
Anyone?
it'll be none unless you fetch it
oh
Restart your ide
guys how can i send gif emoji from guild with bot ?
Bruh
i copy the gif emoji but doesnt work
@stiff nexus man asked this somewhere else
???
uh
U wanna send a emoji from a guild using a bot?
yes
how can i do that ?
An animated emoji?
yes yes
<a:emoji_name:emoji_id>
who the hell are you to tell me
thankss
calm down lol
how to make purge command delete bot' messages only?
emoji.user is only filled when you use Guild.fetch_emoji
Check if message.author == bot.user
Anyone???
ok got that
then use an else statement?
no
Not neeed
Then tell me what is it?
py -3 -m pip install -U discord.py
it's meant to work like Rythm, deleting itself messages only
if message.author == client.user:
await ctx.channel.purge(limit=amount)
``` i think?
let me try
No...
I finished my ModMail and i works but it is really bad code
why this code is not printing anything...
class Help(commands.Cog, name='Help Command'):
def __init__(self, bot: commands.Bot):
self.bot = bot
help_command = HelpCommand()
help_command.cog = self
bot.help_command = help_command
async def send_bot_help(self, mapping):
print('help command')
It accepts a check
Is it open source?
Had that issue so i delted all my python versions and installed the latest, even the windows app. I then switched to pycharm
Not yet

I mean it is really bad written
I'd like to see, since when I tried to make one it really got complicated lol
btw what is this called?
Says that the cmdlet doesn't recognize py????
Emoji ID
Actually, let me just reiinstall it
Emoji markdown
I'll probably make one soon as well
python, python3
Try to restart your ide
thx for the info. @boreal ravine ^^
ok
I used a config.yml and a config file like you did in 0x42 lol
@client.command()
async def purge(ctx, amount=5):
if ctx.author == client.user:
await ctx.channel.purge(limit=amount)```
ok 👍
There's no good lib rn, I won't make anything unless some good lib gets released 
I mean a config class and that
uhhh I'm semi decent with python but try it
finally it worked
well doesn't work 😂
+1
No
Just apply a check= in the purge method which returns true for the conditions you need to purge
I really only used it as an easier way to interface other then that it's pretty much extra
I mean wy is their from_file classmethod seems exactly like jst doing Config(file='path')
This'll not be true, since it wants that bot itself invoked the command
My bot reached 48 servers 
That was just cause it looks better and I was planning on some other things
so how to fix
Is there any async spotify api wrapper?
@wispy sequoia
hey how do u create bots in discord im new to this server

I don't think so atm, I was working on one like a week ago
Authentication is a pain
I started working on one just today 
Read the discord.py docs
Everybody here already made api wrappers for things I wanna do
i basically just copied everything from spotipy but made it async
That's why I'm keeping it to Client Credentials grant only, the id and secret one

make your own api
and make the wrapper yourself
I have for my bot before

bro where is that?
!d discord
In order to work with the library and the Discord API in general, we must first create a Discord Bot account.
Creating a Bot account is a pretty straightforward process.
but don't jump right to making bot if you don't know the basic syntax of py
hmm thanks
Well Oop just makes it more simple and clear but u dont typically need it
Discord.py was very tough at the beginning for me, had to search for bugs online for hours but after you’ll get in a lot of python
You actually need it. Imagine doing discord.Member.send instead of context/message.send which a lot of people do
And if you get more advanced, subclassing
Yes
subclassing is not advanced
But if u want a simple bot u can just have sone client commands
I have to admit, I know nothing about OOP, at least not good at it
oh yeah
I mean atleast for discord.py, since you don't require it most of the time except cogs
But cogs are really easy
All you do is change decorators names and self.bot instead of bot
oh kk
Thanks to dpy who kept it easy 
oof
Indeed, but they stoped development 😔
Danny the legend
@client.command()
async def join(ctx):
channel = ctx.author.voice.channel
await channel.connect()```
```Command raised an exception: RuntimeError: PyNaCl library needed in order to use voice```
why
How do people make libraries for discord?
the error
pip install discord.py[voice]
install voice version
ah

no need
Restart your ide
Just get pynacl extra id assume
and it says requirements already satisfied
then do the command
HELP ME PLEZZZZZ
join a VC then try the command
ANYONE HELP ME?
Maybe install it manually pip install PyNaCl @wispy sequoia
For me?
chill dude
You set it to only in a guild so it wont work in dms if thats what you mean?
I can help you stop spammin?
ok it was missing
No i write command in guild
Do you have an on_message
Ily

what library are you using
discord_components
no
!pypi discord-components
no it's buttons
oh ok thanks
`Discord components are cool, but discord.py will support it on version 2.0. It
is hard to wait, so we made a third-party library for using components such as
buttons or selects!`
version 2.0 😔
hmm wym
I just pasted their welcome texts
hmm but how do i fix my error
this
repost the image,so that those who can help you can see
@commands.command()
@commands.cooldown(rate=1, per=4.5, type=commands.BucketType.user)
@commands.guild_only()
async def hoist(self, ctx):
#remove hoisted names starting with !
for member in ctx.guild.members:
if member.display_name.startswith("!"):
first = 0
try:
await member.edit(nick=f"{member.display_name.replace('!', '')}")
first += 1
except:
pass
await ctx.send(f"{first} users nicknames have been changed.")
#remove hoisted names starting with a number
x = member.display_name[0].isdigit()
second = 0
if x:
try:
await member.edit(nick=re.sub("\d", "", f"{member.display_name}"))
second += 1
except:
pass
await ctx.send(f"{second} users nicknames have been changed.")
#remove hoisted names starting with a .
if member.display_name.startswith("."):
third = 0
try:
await member.edit(nick=f"{member.display_name.replace('!', '')}")
third += 1
except:
pass
await ctx.send(f"{third} users nicknames have been changed.")
#remove hoisted names starting with a [
if member.display_name.startswith("["):
last = 0
try:
await member.edit(nick=f"{member.display_name.replace('[', '')}")
last += 1
except:
pass
await ctx.send(f"{last} users nicknames have been changed.")```
this is super basic but would this work as is? I still need to add some stuff but do i need multiple for loops for each if statement?
You're taking more than 3 seconds to respond
Maybe your internet, or your code is taking time
any suggestions / concerns?
hmm how
How..? Your code is taking more than 3 secs after receiving interaction, or maybe slow internet
buttons = [
[
Button(style=ButtonStyle.grey, label='1'),
Button(style=ButtonStyle.grey, label='2'),
Button(style=ButtonStyle.grey, label='3'),
Button(style=ButtonStyle.blue, label='×'),
Button(style=ButtonStyle.red, label='Exit')
],
[
Button(style=ButtonStyle.grey, label='4'),
Button(style=ButtonStyle.grey, label='5'),
Button(style=ButtonStyle.grey, label='6'),
Button(style=ButtonStyle.blue, label='÷'),
Button(style=ButtonStyle.red, label='←')
],
[
Button(style=ButtonStyle.grey, label='7'),
Button(style=ButtonStyle.grey, label='8'),
Button(style=ButtonStyle.grey, label='9'),
Button(style=ButtonStyle.blue, label='+'),
Button(style=ButtonStyle.red, label='Clear')
],
[
Button(style=ButtonStyle.grey, label='00'),
Button(style=ButtonStyle.grey, label='0'),
Button(style=ButtonStyle.grey, label='.'),
Button(style=ButtonStyle.blue, label='-'),
Button(style=ButtonStyle.green, label='=')
],
]
#calculates answer
def calculate(exp):
o = exp.replace('×', '*')
o = o.replace('÷', '/')
result = ''
try:
result = str(eval(o))
except:
result = 'An error occurred.'
return result
@bot.command()
async def calc(ctx):
m = await ctx.send(content='Loading Calculators...')
expression = 'None'
delta = datetime.datetime.utcnow() + datetime.timedelta(minutes=5)
e = discord.Embed(title=f'{ctx.author.name}\'s calculator | {ctx.author.id}', description=expression,
timestamp=delta)
await m.edit(components=buttons, embed=e)
while m.created_at < delta:
res = await bot.wait_for('button_click')
if res.author.id == int(res.message.embeds[0].title.split('|')[1]) and res.message.embeds[
0].timestamp < delta:
expression = res.message.embeds[0].description
if expression == 'None' or expression == 'An error occurred.':
expression = ''
if res.component.label == 'Exit':
await res.respond(content='Calculator Closed', type=7)
break
elif res.component.label == '←':
expression = expression[:-1]
elif res.component.label == 'Clear':
expression = 'None'
elif res.component.label == '=':
expression = calculate(expression)
else:
expression += res.component.label
f = discord.Embed(title=f'{res.author.name}\'s calculator|{res.author.id}', description=expression,
timestamp=delta)
await res.respond(content='', embed=f, components=buttons, type=7)```
i responded fast
Not you, the bot
just change the timer
uh
You can take how much time you want, doesn't matter, but bot needs to respond back in 3 secs
oh
!charinfo ✅
\u2705 : WHITE HEAVY CHECK MARK - ✅
what lib are you using?
can it be because i m using replit
prolly
!charinfo ⛔
I guess it's some error
#bot-commands
sry
np
!pypi discord-components
i made one using disnake
oh
yes
They have
he prolly wont
lol
no errors
we can only hope for that
Did you not read his gist?
No idea then, never used this lib 
highly unlikely he'll come back
oof ok
he might contribute some stuff
but he probably wont ever fully maintain anything anymore
Soo
!d discord.Guild.change_voice_state
await change_voice_state(*, channel, self_mute=False, self_deaf=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Changes client’s voice state in the guild.
New in version 1.4.
await change_voice_state(*, channel, self_mute=False, self_deaf=False)
^
SyntaxError: invalid syntax
and dont pass in *
@client.command(aliases=["connect", "come"])
async def join(ctx):
try:
channel = ctx.author.voice.channel
embed = discord.Embed(color=0x000000)
embed.add_field(
name="\u2705 Success!", value=f"Succesfully connected to `{channel}`.", inline=False)
await channel.connect()
await ctx.send(embed=embed)
except:
embed = discord.Embed(color=0x000000)
embed.add_field(
name="\u26d4 Error!", value="An error occoured.", inline=False)
await ctx.send(embed=embed)```
how to fix
error?
what?
it doesn't error rn
I need it to defean itself when it joins a vc
yes
hmm
okay
.-.
@wispy sequoia I already told you ^ 
Call this method after joining the channel
did
oh bruh
syntax error
syntax error
Because it's a method of guild
???
^
They copy pasted exactly await change_voice_state(*, channel, self_mute=False, self_deaf=False) from docs
you aren't even doing it right
oh come on
don't copy paste
try to understand
😔
change_voice_state is a method. use the kwargs to deafen
self_deaf=True
And it's a method attached to guild, not defined globally
Yeah
and (*, ...) is for docs, you don't pass kwargs like this
you don't need to even copy all and pass all kwargs it just shows examples of what you can do with it
so await change_voice_state(channel, self_deaf=True)
do you know what a method is
almost correct, but it's a method of guild
omg 😔
Parameters after * need to be supplied as key word arguments, you cant pass it positionally

sad

answer blankets question though, what's method?
Revise your python concepts and try again
do you know?
a function avaiable for an object
There you go you got your answer
okay..
is that from the internet 
it seems you know
no
so what's the problem
change_voice_state is a method of the Guild object
change_voice_state is a method of Guild, and you just said what a method is
so....
use it now
Now think how you can get the guild
bruh
just look at your code lmao

await ctx.guild.change_voice_state(channel=channel, self_mute=False, self_deaf=True)
omg I did it
why is it looking like it's playing smth
Why is there a random colon in the return statement?
how do i check if a user has a nickname
Check if their nickname is different from name prob
hmm
can anyone help with this4
!d discord.Member.nick
The guild specific nickname of the user.
I think you should learn some basic python, don't just watch a video and copy everything down
That's obviously invalid syntax
Hello
Well, the colon shouldn't be there which is the error you're being pointed to by your editor
does anyone know a way to show dm recipient, couldn't find anything in documentation ```py
on_message
@bot.event
async def on_message(message):
if message.guild is None:
await bot.get_channel(751758793691365437).send(
f"[{message.guild}]<@{message.author.id}>: {message.content}")
await bot.process_commands(message)
oh
message.channel.id shows the recipient's ID
I don't think it does, it displays 751756429286834206 while my id is 418793373365829633
however just using message.channel shows Direct Message with Shiba#7473
which is pretty good
I think I found something though
recipient
lemme try
ok message.channel.recipient.id works
thanks for the help though @visual island
why me is getting error when
i invite bot its not inviting the bot whaii
someone tell me how to come up with a name for a discord bot
best discord bot names
bruh
`@client.command(help = "Check your level using this")
async def stats(ctx, member: discord.Member):
print("Brudda")
if member is None: member = ctx.author
# get user exp
async with client.db.execute("SELECT exp FROM guildData WHERE guild_id = ? AND user_id = ?", (ctx.guild.id, member.id)) as cursor:
data = await cursor.fetchone()
exp = data[0]
# calculate rank
async with client.db.execute("SELECT exp FROM guildData WHERE guild_id = ?", (ctx.guild.id,)) as cursor:
rank = 1
async for value in cursor:
if exp < value[0]:
rank += 1
lvl = int(math.sqrt(exp)//client.multiplier)
current_lvl_exp = (client.multiplier*(lvl))*2
next_lvl_exp = (client.multiplier((lvl+1)))**2
lvl_percentage = ((exp-current_lvl_exp) / (next_lvl_exp-current_lvl_exp)) * 100
embed = discord.Embed(title=f"Stats for {member.name}", colour=discord.Colour.gold())
embed.add_field(name="Level", value=str(lvl))
embed.add_field(name="Exp", value=f"{exp}/{next_lvl_exp}")
embed.add_field(name="Rank", value=f"{rank}/{ctx.guild.member_count}")
embed.add_field(name="Level Progress", value=f"{round(lvl_percentage, 2)}%")
await ctx.send(embed=embed)`
I made this command , but it is not running when said to , what am i doing wrong ?
Just made a music bot in like 30 minutes pog
search on googlr
how do i send a message every 2 hrs by bot lol
pls tell
task loop
what ?
does anyone know what I'm doing wrong? ```py
await bot.change_presence(status=discord.Status.online,
activity=discord.CustomActivity(
name="Waiting for .help",
emoji=None))
it works 🦆
changed the code a bit ```py
presence
@bot.event
async def on_ready():
await bot.change_presence(status=discord.Status.online,
activity=discord.CustomActivity(
name="Listening to .help (msg me for modmail)",
emoji=None))
print("Bot online!")
Put those in bot construction
It has those kwargd
?
Kwargs *
bot = commands.Bot(comamnd_prefix ="a prefix", activity=...., status =...)```
oh ok
still doesnt work @spring flax
activity=discord.CustomActivity(
name="Listening to .help (msg me for modmail)",
emoji=None),
status=discord.Status.online)
in commands.Bot
send the entire code of the bot constructor please
bot = commands.Bot(
command_prefix=[
"Shiba ",
"shiba ",
"Doggo ",
"doggo ",
"."],
help_command=None,
activity=discord.CustomActivity(
name="Listening to .help (msg me for modmail)",
emoji=None),
status=discord.Status.online)
i don't think it's custom activity
just try activity
just changed it btw ```py
bot = commands.Bot(
command_prefix=[
"Shiba ",
"shiba ",
"Doggo ",
"doggo ",
"."],
help_command=None,
activity=discord.CustomActivity(
name="Listening to .help (msg me for modmail)",
emoji="🐕"),
status=discord.Status.online)
ok
File "/Users/shiba/Documents/projects/shiba-bot/bot.py", line 15, in <module>
activity=discord.Activity(
File "/opt/homebrew/lib/python3.9/site-packages/discord/activity.py", line 193, in __init__
self.emoji = PartialEmoji.from_dict(emoji)
File "/opt/homebrew/lib/python3.9/site-packages/discord/partial_emoji.py", line 83, in from_dict
animated=data.get('animated', False),
AttributeError: 'str' object has no attribute 'get'
shiba@MacBook-Pro shiba-bot %```
@slate swan
I don't think bots have access to custom activity currently
this error hasn't got to do with the code
oh wait
I changed the emoji to None
Now I have no errors but the acitivity doesnt work eitehr
i gtg rn tag me if you reply pls
how could i check if a users name contains a string
if member.display_name.contains("!") and member.display_name.contains("."):```
this doesnt work since strings are a no no apparently
error:
```py
Traceback (most recent call last):
File "/home/container/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/home/container/Cogs/mod.py", line 555, in hoist
if member.display_name.contains("!") and member.display_name.contains("."):
AttributeError: 'str' object has no attribute 'contains'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/container/.local/lib/python3.8/site-packages/jishaku/features/invocation.py", line 146, in jsk_debug
await alt_ctx.command.invoke(alt_ctx)
File "/home/container/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/home/container/.local/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: AttributeError: 'str' object has no attribute 'contains'```
if "!" in str(member.display_name)
There is no python function named contains believe
make the options a list, loop through that list, and check if list[i] is what you want
yes, there is.
startswith and endswith
smart
Indeed
thank you for the help
or just loop through i of the str(member.display_name) and check if i == "what you want" that'll also work
may be better
this is what i was doing before
its very not optimized
I was more or less testing if i could do what i wanted
there isnt, thats a dunder method
?
!d object.contains
object.__contains__(self, item)```
Called to implement membership test operators. Should return true if *item* is in *self*, false otherwise. For mapping objects, this should consider the keys of the mapping rather than the values or the key-item pairs.
For objects that don’t define [`__contains__()`](https://docs.python.org/3.10/reference/datamodel.html#object.__contains__ "object.__contains__"), the membership test first tries iteration via [`__iter__()`](https://docs.python.org/3.10/reference/datamodel.html#object.__iter__ "object.__iter__"), then the old sequence iteration protocol via [`__getitem__()`](https://docs.python.org/3.10/reference/datamodel.html#object.__getitem__ "object.__getitem__"), see [this section in the language reference](https://docs.python.org/3.10/reference/expressions.html#membership-test-details).
yeah, try looping through each letter of the display_name
not working
firstly, don't do it on on_ready
do not disturb or idle
dnd works
whai
it's not good to do it then
ah
how could i check if the users name contains something then?
i guess startswith works fine
since hoisting
!d discord.ext.commands.Bot.activity <- this one
activity```
The activity being used upon logging in.
i'm not sure exactly what it is
but in your bot constructor use activity and status kwarg
oh it's a loop
is list the name of the list or is [i] the name of the list
so py names = chars if names[i]
ii said bot constructor for status?
can someone explain me how should i use on_member_unban to send a msg in a channel when the user gets unbanned?
wrong
!d discord.ext.commands.Bot read the kwargs
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/stable/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Client "discord.Client") you can do with this bot.
This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.
okay let me make an example cause i dont quite understand
for i in (member.display_name):
if i == "something":
#do something
elif i == "something else":
#do something else
I need a help of custom embed just I need like this syntax !embed <hex code of the colour> <description> please help me
ahhhh
just make a new embed
Means how ?
what is i?
with the description as description, color=color, based on command arguments
i need it like this
try and except it, or make error handlers
Ok
i already told you what to do.
it doesn't have to be i
Thank you very much my friend
it can be anything
ah i see
your welcome
can someone explain me how should i use on_member_unban to send a msg in a channel when the user gets unbanned?
read what i said
!e
str = "test"
for letter in str:
print(letter)
@slate swan :white_check_mark: Your eval job has completed with return code 0.
001 | t
002 | e
003 | s
004 | t
i cannot understand
Is that even exist?
oh thats pretty cool
see that's like basically looping through each character of the string
How can a member be unbanned
Yep
!d discord.on_member_unban
discord.on_member_unban(guild, user)```
Called when a [`User`](https://discordpy.readthedocs.io/en/stable/api.html#discord.User "discord.User") gets unbanned from a [`Guild`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Guild "discord.Guild").
This requires [`Intents.bans`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Intents.bans "discord.Intents.bans") to be enabled.
firstly users get unbanned not members.
The event does
Ik, in the docs it says user and guild attributes , i too dont know why it is on_member_unban
Ye
Ik how to get the id and to send the msg in that chan, but what about the middle part? Getting the user which was unbanned and stuff @slate swan
so im finally integrating my bot with a database, and i wanted to store the db password and the bot token in a json file. is it ok if i store these 2 in a json file, and how would i do that? is it better to make a .py file and make a list and put it in there?
@bot.group(invoke_without_command=True)
async def help(ctx):
embed = discord.Embed(title="Welcome!", description="Here's the list of available commands", color=discord.Color.purple())
embed.add_field(name="Information:", value="`serverinfo`,`check`", inline=False)
embed.add_field(name='Other Commands', value="`youtube`", inline=False)
embed.add_field(name="Moderation:", value="`kick`", inline=False)
embed.add_field(name="Utilities:", value="`about`, `ping`", inline=False)
@help.command
async def kick(ctx):
embed = discord.Embed(title='Kick', description='Kicks a Member from the guild. This command requires **Kick Members** permission to work.')
embed.add_field(name='Usage', value="`!kick <user>`")
embed.add_field(name='Aliases', value='Coming soon....')
embed.add_field(name='Examples', value='!kick @user')
await ctx.send(embed=embed)
```While trying `!help kick` I am getting that main help menu, why don't I get the below one?
?
I think invoke_without_command=False just try it
guys! i need help if someone can help me!
i am making a bot that plays music radios in a voice channel
i want it to send an error message if you're not in a voice channel but i can't make my code to work 😢
@ouvir.command()
async def antena1(ctx):
channel = ctx.message.author.voice.channel
if channel:
player = await channel.connect()
player.play(FFmpegPCMAudio('http://radiocast.rtp.pt/antena180a.mp3'))
await ctx.send("You are listening to **Antena 1**.")
else:
await ctx.send("You need to be in a voice channel!")
didn't work
Wait
can we move to #help-corn
It’s if ctx.author.voice do something, else do something
not an expert on music bots, but i think you have to make a check in the else statement to see if the ser is in a voice channel. i think its going to be something with ctx.author
hmm this should work. you might have to change the code a little, but this is what i meant @fleet prairie
ctx.author.voice is only to detect if their in a voice channel. Only the channel object has the connect method
Can I have the bot active 24/7?
How do I do it?
Tbh, u just need a device on which u can run the python script 24/7
i put my code in replit, create a keep_alive file + uptime robot pings
never shuts down
and free
Just google VPS. I’ve seen ppl use
Amazon AWS
Digital Ocean VPS
Google Cloud Platform
Or purchase a Raspberry pi
These are just a few
does anyone know a way to see all the attributes of message
dir(message)
what's that doo?
!e print(dir(print))
@maiden fable :white_check_mark: Your eval job has completed with return code 0.
['__call__', '__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__name__', '__ne__', '__new__', '__qualname__', '__reduce__', '__reduce_ex__', '__repr__', '__self__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__text_signature__']
It returns the list of methods and attributes
THAT'S SOOOO COOOLL
(:
yh ik that
why im even getting it
i do
it gib error
what's that
@honest shoal
|| shit.py ||
can someone teach me python for my school practicals
only basic python ,, like list function ,, range function
discord-bots
hey i have a small question, is there any way to get the id of a user
if i have the username
!d discord.Guild.get_member
get_member(user_id)```
Returns a member with the given ID.
ah, it doesn't accept a name
yea
lemme check in the docs
i need the vice versa
!d discord.Guild.get_member_named
get_member_named(name)```
Returns the first member found that matches the name provided.
The name can have an optional discriminator argument, e.g. “Jake#0001” or “Jake” will both do the lookup. However the former will give a more precise result. Note that the discriminator must have all 4 digits for this to work.
If a nickname is passed, then it is looked up via the nickname. Note however, that a nickname + discriminator combo will not lookup the nickname but rather the username + discriminator combo due to nickname + discriminator not being unique.
If no member is found, `None` is returned.
id```
Equivalent to [`User.id`](https://discordpy.readthedocs.io/en/stable/api.html#discord.User.id "discord.User.id")
im not the one coding it, my friend is(i like js more) but i will tell him
how to do the error handling part for group commands?
!d discord.on_command_error @reef shell
discord.on_command_error(ctx, error)```
An error handler that is called when an error is raised inside a command either through user input error, check failure, or an error in your own code.
A default one is provided ([`Bot.on_command_error()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot.on_command_error "discord.ext.commands.Bot.on_command_error")).
for group commands, not for all commands


