#discord-bots
1 messages · Page 659 of 1
Yeah thats the issue 
https://discord.gg/djs wrong one lol
Although the discord.js isn't very kind to beginners keep that in mind.
yes i noticed i still sended the wrong one
wait you are not understanding lol
I've coded a discord python bot, but ive installed discord js things
Why..?
I was brainlessly following a tutorial
I dont wanna talk about it 
Until I remembered I wrote the 2000 lines of code in python
npm uninstall <package name>
its alright ima just reinstall the whole server
It's okay just don't install it again :)
will try my best


@cloud dawn please help ( i dmed you )
how to connect a bot to voice? using Message
I won't help in DM these channels are meant for this.
Using message?
how can I pip install a certain discord version
connect to author voice channel by command in chat
I don’t feel comfortable sending that much code here
py -m pip install discord.py==1.6.0
do I need py -m?
!paste that's why we got this.
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
!d discord.VoiceChannel.connect
await connect(*, timeout=60.0, reconnect=True, cls=<class 'discord.voice_client.VoiceClient'>)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Connects to voice and creates a [`VoiceClient`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceClient "discord.VoiceClient") to establish your connection to the voice server.
This requires [`Intents.voice_states`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.voice_states "discord.Intents.voice_states").
can I just do pip3 install discord==1.7.3?
Yep, but the default is 1.7.3 so you won't need to do the ==1.7.3 anyways.
I mean like I don’t feel comfortable sending the code here
Well i don't know you and we didn't have any non-code related conversation and you sended it to me without even asking.
I don't want to make you feel uncomfortable but i prefer it here.
You can also send the part that isn't working instead of the whole code and tell us what isn't working.
You have better changes of getting help in this channel than in DMs afaik
why my bot saying that i'm not in voice?
You were not in voice channel?
i'm was in voice channel
Show the code + trackback?
@client.command()
async def server(self, ctx):
activeserver = client.guilds
for guild in activeserver:
await ctx.send(f"{guild.name} has {len(guild.members)} members")
#print(guild.name)
#await ctx.send(len(ctx.guild.members))
Problem:
Nothing happens when used
sorry i just needed to install PyNaCl
this will spam the API what are you trying to achieve?
anyone know how to access rich presence
!d discord.Member.activities
The activities that the user is currently doing.
Note
Due to a Discord API limitation, a user’s Spotify activity may not appear if they are listening to a song with a title longer than 128 characters. See GH-1738 for more information.
find servers with under 5 members to free up some space because i haven't gotten verified
Then just leave it without spamming the chat
so what am i supposed to do exactly?
print in console instead?
if so please tell me how
just check the member_count , see if its below 5 , if True , leave it
i lost my discord bot's file and code but it is in heroku, how i can download it ?
!d discord.Guild.leave
await leave()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Leaves the guild.
Note
You cannot leave the guild that you own, you must delete it instead via [`delete()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.delete "discord.Guild.delete").
@client.command()
async def server(self, ctx):
for guild in client.guilds:
if len([m for m in guild.members if not m.bot]) < 5:
await guild.leave()
I think this suffices
😉
yeah it does
so if i change 5 to 10 it would also work right?

it will
is there any way to download my app's files and folders from heroku ?
ok
or if you have jishaku or something in your bot just make it send all the files
idk about jishaku
could u make it so that it prints Left Guild
in console for every time it leaves, i would love to see how many servers it leaves
print(guild.name)
basic question, how do you basically like send a user a message with ctx/context
heroku git:clone -a APP-NAME
heroku slugs:download -a APP_NAME
these 2 commands are enough to download the source code and files ?
you should filter the guilds as soon as the bot joins a guild tbh
can someone tell me
where are you trying to implement it?
a DM message to user ?
no like basically you can dm a user with the bot like user.send and define the user to be a discord.User object
how could you do the same like this in ctx 🤔
ctx.author.send
if you want to defined the user manually , you can use bot.get_user(id)
or you mean bot.get_user(ctx.author.id) i guess
yes
Ignoring exception in command server:
Traceback (most recent call last):
File "C:\Users\ADMIN\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\ADMIN\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\commands\core.py", line 855, in invoke
await self.prepare(ctx)
File "C:\Users\ADMIN\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\commands\core.py", line 789, in prepare
await self._parse_arguments(ctx)
File "C:\Users\ADMIN\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\commands\core.py", line 697, in _parse_arguments
transformed = await self.transform(ctx, param)
File "C:\Users\ADMIN\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\commands\core.py", line 542, in transform
raise MissingRequiredArgument(param)
discord.ext.commands.errors.MissingRequiredArgument: ctx is a required argument that is missing.
bruh define ctx
also you cant dm a user only members
.
commands.Context
yea thats fine i use discord.Member
remove self
plz help
not what i meant but uhhh
so rich presence anyone
still geniunely correct
for disnake
!d discord.User.send
await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.
To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.
To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
Delete self you are not working in a class
you can
!d disnake.Member.activities
The activities that the user is currently doing.
Note
Due to a Discord API limitation, a user’s Spotify activity may not appear if they are listening to a song with a title longer than 128 characters. See GH-1738 for more information.
you cant it will return an error cuz you can only dm a person that has a mutual guild with the bot
a user can share a guild with the bot too
if I want for a bot is it disnake.bot.Activities
How come i have never seen you lol
for your bot?
yes
!d disnake.ext.commands.Bot.change_presence
await change_presence(*, activity=None, status=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Changes the client’s presence.
Example
```py
game = disnake.Game("with the API")
await client.change_presence(status=disnake.Status.idle, activity=game)
``` Changed in version 2.0: Removed the `afk` keyword-only parameter.
ty
im invisible 😏
so something similar to the code below is what i should do
var = bot.get_id(ctx.author.id)
await var.send("bru")
🤔 alright
oh yeah and would some handling inside a command like this still work becuase i didnt get the dm
@bot.command()
@commands.has_any_role(914534709986467890, 912631582681092117)
async def warm(ctx: commands.Context, member: discord.Member):
if member not in ctx.guild.members:
await ctx.message.delete()
await ctx.author.send("That is not a valid member to bean!")
else:
Warmed = discord.Embed(title=f"{member} has been warmed", description=f"{member} has been warmed", color=discord.Colour.gold())
await ctx.send(embed=Warmed, view=KCIHM)
and yes kcihm class exists
was trying to figure out how to get buttons working in a discord bot host
member is in the ctx.guild.members simple
what about elif ok
is this for rich presence ?
do you get some error ? if no
do you have an error handler ? if yes
add else : raise error in it
its just online, offline, idle, or dnd right?
status and playing/watching/listening/competeting status
Pretty sure the converter can't convert it into a member if it is not in a guild so the first check is kinda odd.
bots cannot have rich presence for now
cant js bots have rich presence
none of the bots can have it
They indeed cannot, at most the about me page.
Pretty sure they can't since people will only abuse it.
@bot.command()
@commands.has_any_role(914534709986467890, 912631582681092117)
async def warm(ctx: commands.Context, member: discord.Member):
if member in ctx.guild.members:
Warmed = discord.Embed(title=f"{member} has been beaned",description=f"{member} has been beaned.", color=discord.Colour.gold())
else:
raise Error
``` 🤔
no output stil
wait lemme try is in
i said the same lol?
@shadow wraith
Where?
Anyone who’s experienced with bots I need help with making embedded leaderboard bot that you can give points with command
do you store the points data in some database or something?
Yeah i saw that but i just wanted to tell you that that is prob the reason 
I haven’t made it yet I need help
i have no idea if and else statements which check your commands and are known as "checks" can also be considered error handlers ¯_(ツ)_/¯
I’m semi New to coding I’ve coded for 8 months but I’m still skidd as I don’t Know any good python tutorials for discord bots
wait i just realized what you meant by error handlers
like @<cmd>.error
wait im literally stupid i couldve just done
!d discord.ext.commands.BadArgument
exception discord.ext.commands.BadArgument(message=None, *args)```
Exception raised when a parsing or conversion failure is encountered on an argument to pass into a command.
This inherits from [`UserInputError`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.UserInputError "discord.ext.commands.UserInputError")
im stupid
yo @slate swan @prisma spoke ur guiding plz?
huh?
for?
so?
now how to run it??\
Bruh
we are getting presents! 🥳
u pinged for this?
the code breh
run and debug bruh
afer itz??
test ur bot then if it shows no errors
bruh u r noob in tech
alright so whos familiar with pillow here?
breh... will ya shut up?? my mistake i pinged u
Good day mates
Ok then dont just fuck off
Is that really real?
dunno
So in disnake it says to await bot.change_presence(self, *, activity, status)
..
But how do u actually implement that
you
Well its a coro you implement it wete you would like to can be a command or not
i need help with it bruh.. thats why m asking
its a complicated question
needs a complicated math
Like changes status as the bot starts
Thats lit
Not it changes the presense depends where you add the coro
nais ig discord gona leak nitro codes
Yeah ofc but
@slate swan u are Indian? (ofc im indian and christian)
Idk like where to add it
No lol i wish
but who tf cares bout religion
I love my indians bros
i am not christian
Like is there a bot event for it or do I add it when loading a cog
pakistani?
ohk nvm
Nah american
woa/
Lol
okimi what new file? to open?
Ahh i like the brotherhood between some ppl if they of pakistan if they except us as their bros
anyways back to the topic.. does nyone know pillow?
it asked to mention the name
dude so do it
learn computers before using it please
cool background pic
Wdym?
TF ITS PERIODIC TABLE
askin to mention
ik
Oh no just in file press new and then it will ask language and type in python
ohk thanks
who tf likes it
no comments
its useful, especially for cheating in exams 
lmfao
okimmi
topper here lol
Bro?😳
Give me a sec
kay
await self.bot.change_presence(activity=disnake.Game("**with /bazaar**"))
that is essentially what I want to do
but idk a good place to implement that
oo
You can make it a event or a command or a task
Yes thats correct now you can start!
thanks!
Yw
yo AttributeError: 'RawReactionActionEvent' object has no attribute 'role'
async def on_raw_reaction_add(payload: discord.RawReactionActionEvent):
if payload.member.bot:
return
channel = bot.get_channel(payload.channel_id) or await bot.fetch_channel(payload.channel_id)
if str(payload.emoji) == "👍":
if payload.role.id != 915363576867344435:``` anyone know the thing I use?
if we dont download the python we cant code? @slate swan
reaction roles
https://paste.pythondiscord.com/rekipeluji.py
i need the verify command to work and no other ones, only for this specific channel, whilst deleting any other messages sent in the verify channel using the verify command
is using it on_ready a bad idea
whats the error
Yes you cant code in python without the language
no error but the problems in the video
Yes it is
oh god the worst
ohk downloadin
dk how to describe it
send the code
i have no handlers for it or even globals or anything like that
for a command that doesn't work
i did, its in the pastebin
send the one that works
its a basic help command, below the event
@slate swan
@commands.check(checkk)
its not some over the top code its just a command + embed
remove that line and try
?
ya, im making the cmd only work in 1 server
remove that line for now
downloaded python now what??
alright ill let you know if anything changes
Now you install it as you downloaded the installer
exe.??
send the output once you do if there is one
Yes the installer
ohk
.bm
okimmi click on install now?
Can someone help me at #help-burrito?
No add python to path
Install now
click on it?
Yes
downloadin
Alright
How is installing python related to discord bots?
i removed it, and nothing happens
i went and removed the event for a second as well, same thing. nothing happens
and i dont get errors either 
the code is in python lol
theres no global or local handlers so irdk
I would recommend going to a help channel instead
fuck
Cuz installation of a program is not related to discord bots at all
As a matter of fact that's not even related to coding
It is as your downloading python which you use to code
What
You are installing it not using it
Now that's just false
You install it for what?
Installation of a program is not related to coding
The program is a language in this case
He can prolly ask for help after the completion of installation
Installation of python is
You downloaded spotify for what?
@bot.command()
async def verify(ctx):
embed = discord.Embed(title=f'Verification', description=f'You have `1` attempt to verify. If you fail, you may be re-evaluated by executing the command again', color=clr)
failbed = discord.Embed(title=f'Verification', description=f'You have failed the verification process! Please try again', color=clr)
passbed = discord.Embed(title=f'Verification', description=f'You have passed the verification process! Enjoy your stay', color=clr)
captcha = random.randint(1, 4)
if captcha == '1':
embed.set_image(url=f'https://cdn.discordapp.com/attachments/910579746205745283/917283179843452970/wickCaptcha.png')
await ctx.send(embed=embed)
def check(m):
return m.author.id == ctx.author.id
msg = await bot.wait_for('message', check=check)
if msg.content == 'KZEXEH':
await ctx.send(embed=passbed)
await user.add_roles(917654915311099944)
else:
await ctx.send(embed=failbed)
elif captcha == '2':
embed.set_image(url=f'https://cdn.discordapp.com/attachments/910579746205745283/917283141130006578/wickCaptcha.png')
await ctx.send(embed=embed)
def check(m):
return m.author.id == ctx.author.id
msg = await bot.wait_for('message', check=check)
if msg.content == 'SXOXMM':
await ctx.send(embed=passbed)
await user.add_roles(917654915311099944)
else:
await ctx.send(embed=failbed)
elif captcha == '3':
embed.set_image(url=f'https://cdn.discordapp.com/attachments/910579746205745283/917283129163669524/wickCaptcha.png')
await ctx.send(embed=embed)
def check(m):
return m.author.id == ctx.author.id
msg = await bot.wait_for('message', check=check)
if msg.content == 'KHBLHC':
await ctx.send(embed=passbed)
await user.add_roles(917654915311099944)
else:
await ctx.send(embed=failbed)
elif captcha == '4':
embed.set_image(url=f'https://cdn.discordapp.com/attachments/910579746205745283/917282861734842418/wickCaptcha.png')
await ctx.send(embed=embed)
def check(m):
return m.author.id == ctx.author.id
msg = await bot.wait_for('message', check=check)
if msg.content == 'GVPWVK':
await ctx.send(embed=passbed)
await user.add_roles(917654915311099944)
else:
await ctx.send(embed=failbed)``` no errors, dont know what to do
yikes i didnt realise how big that was sorry
I am listening to Spotify after installation bruh
Not before installing
Then it makes it related
It's not but I won't argue
Installation of any program is not related to coding
Is downloading Spotify related to listening to music?
Well ig you listen on spotify
Spotify Installer > spotify > listen to music
ye
How is that not related
And you code with python. It's the same concept
Exactly
How to add reaction to user's message???
ye
anyone???
So you mean installation of spotify is listening to music even when you are not listening during installation?
Ok then
No but it's related to listening to music
msg= await ctx.send("message")
msg.add_reaction("emoji")
my my lol
The same way installation of python is related to python but not coding in python
@slate swan now?/
what else will you use python for ? except for if you use linux
So the question doesn't fit here
code an app! code a bot!
For controlling my PC with discord
NOT bot's message
Go to vsc
That doesn't make any sense
Oh my bad
@tasks.loop(hours=1.0)
async def status(self):
member_count = sum([count.member_count for count in self.bot.guilds])
await self.bot.change_presence(activity=disnake.Game(f"with {member_count} Users!"))
but I get this traceback
Unhandled exception in internal background task 'status'.
Traceback (most recent call last):
File "C:\Users\Vader\PycharmProjects\pythonProject1\venv\lib\site-packages\disnake\ext\tasks\__init__.py", line 166, in _loop
await self.coro(*args, **kwargs)
File "C:\Users\Vader\PycharmProjects\pythonProject1\taskscog.py", line 114, in status
await self.bot.change_presence(activity=disnake.Game(f"with {member_count} Users!"))
File "C:\Users\Vader\PycharmProjects\pythonProject1\venv\lib\site-packages\disnake\client.py", line 1417, in change_presence
await self.ws.change_presence(activity=activity, status=status_str)
AttributeError: 'NoneType' object has no attribute 'change_presence'
Get the message and add a reaction
wont you be coding it to do that?
and code??
Yeah
Well ofc
the bot isn't ready yet
oops
!d discord.ext.commands.Bot.wait_until_ready
await wait_until_ready()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits until the client’s internal cache is all ready.
send me once the guide pls? okimi
@tasks.loop(hours=1.0)
async def status(self):
await self.bot.wait_until_ready()
member_count = sum([count.member_count for count in self.bot.guilds])
await self.bot.change_presence(activity=disnake.Game(f"with {member_count} Users!"))
ty, that worked, the code looks good
plz plz

well, idk if im supposed to use the wait until ready there every time
A tutorial on how to use discord.py to create your own Discord bot in Python, written to fix the flaws of many other popular tutorials.
Why does everybody say my name with one i 😭
How to get a user's hypesquad badge?
tnaks
!d discord.User.public_flags
property public_flags: discord.flags.PublicUserFlags```
The publicly available flags the user has.
@tiny ibex
Ty
sorry okimii
It returns all the badges ig?
No its alr lol
class discord.PublicUserFlags```
Wraps up the Discord User Public flags.
x == y Checks if two PublicUserFlags are equal.
x != y Checks if two PublicUserFlags are not equal.
hash(x) Return the flag’s hash.
iter(x) Returns an iterator of `(name, value)` pairs. This allows it to be, for example, constructed as a dict or a list of pairs. Note that aliases are not shown.
New in version 1.4.
How to find the hypesquad one?
!d discord.PublicUserFlags.hypesquad
Returns True if the user is a HypeSquad Events member.
Ah thanks
!d discord.PublicUserFlags.hypesquad_bravery
Returns True if the user is a HypeSquad Bravery member.
Understood
yo why does not search through the file and pass? py if newRole in Json_Items[i][x]['roles']: print("passed as they have this role") pass else: print(newRole) Json_Items[i][x]['roles'].append(str(newRole)) json.dump(Json_Items, open("./all_user_rep.json", "w"), indent=1) print(Json_Items[i][x]['roles']) just ignores the if x in x
if it goes to else: then id assume there is no x in x
na fixed it, newRole had to be assigned to a string
anyone?
Is it possible to create a graph showing member count in the last week or maybe month or anything
u could use emojis and add an emoji to display x amount of ppl joining
!pypi matplotlib
how to add time on embed footer
timestamp=datetime.utcnow()
discord.Embed(timestamp=value)
In the embed constructor
thanks
SolverProblemError
Because no versions of discord match >1.7.3,<2.0.0
and discord (1.7.3) depends on discord.py (>=1.7.3), discord (>=1.7.3,<2.0.0) requires discord.py (>=1.7.3).
Because discord.py (1.7.3) depends on aiohttp (>=3.6.0,<3.8.0)
and no versions of discord.py match >1.7.3, discord.py (>=1.7.3) requires aiohttp (>=3.6.0,<3.8.0).
Thus, discord (>=1.7.3,<2.0.0) requires aiohttp (>=3.6.0,<3.8.0).
So, because repl-python3-rabdi depends on both aiohttp (^3.8.1) and discord (^1.7.3), version solving failed.
at /opt/virtualenvs/python3/lib/python3.8/site-packages/poetry/puzzle/solver.py:241 in _solve
237│ packages = result.packages
238│ except OverrideNeeded as e:
239│ return self.solve_in_compatibility_mode(e.overrides, use_latest=use_latest)
240│ except SolveFailure as e:
→ 241│ raise SolverProblemError(e)
242│
243│ results = dict(
244│ depth_first_search(
245│ PackageNode(self._package, packages), aggregate_package_nodes
exit status 1
what is error
What u tryna install?
nothing
😐
Hmmmm
and this error show
Idrk, seems like a poetry problem
@slate swan i ran the code and debugged it but no its still offline
Show
Regenerate your token btw
Can someone give me the code of the voting bot, it doesn't need to be complete
Your bot will never start because the bot.run() call is in the function, not the outer scope (i.e. no indentation)
can u tell me how to?
remove the spaces before bot.run
vco announced 😎
and nextcord
just do shift tab untill bot.run reaches the end
oh
basic python, the bot will only run once the command gets invoked, which is like impossilbe since the bot is never gonna be alive
also u dont seem to have the discord.py library
ohk
or he has that weird "module not resolved" bug which you can fix by changing your interpreter iirc
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix="!",help_command=None)
@bot.event
async def on_ready():
print("Your bot is ready")
@bot.command()
async def hello(ctx):
await ctx.send("whatsup")
@bot.command()
async def send(ctx,arg):
await ctx.send(arg)
bot.run("TOKEN")
basic bot
ah yes
the run functions in one file
ohk thanks
why not lol
does anyone know why bot's pinged went up FOUR TIMES?!
yeah ik
four times? what
i just never use it lol
I HAVE TO REFRESH DISCORD TO LOAD UP MESSAGES DELETED AFTER PURGING
it really depends on the websocket latency (and yours)
so any reason why, because before it used to hover a bit above 30 ms
eh, I've seen people do weird shit py @bot.command( aliases = ('ping', 'PING', 'pong', 'pING', 'pinG',) ) and they don't even know that a case_insensitive kwarg exists
haha nubs
😭
i def knew that it existed...
what
yes
i know it exist i just dont really care lol
what do you mean? give more context
if you mean messages dont get deleted after you delete them, that looks like a you issue
but it's NEVER happened before
it's only happening now
it isn't a discord bot problem though, which is this channels topic
its normal if its below 300 ms
I know, but the prob is it went up four times within an hour
not the latency itself
and, whenever i enter a limit for my command on my server, >>>purge 10I have to refresh discord, but the default limit=10 in the code, and it DOESN'T require refreshing then
okimii see
great, refresh your token before i exploit it lol
dpy? wat is it?
py -m pip install discord worked for me :|
link me
i mean pip installl discord does install discord.py so just do that
@earnest ferry press alt + r then type cmd and just type pip install discord
or u can just use the terminal
i just remember ur username is a pokemon
works to
ye?
go to terminal and type in py -m pip install discord
did this
i kinda advise u to learn more py then getting into discord.py
did it work?
wait with space or without sapce?
with
bruh
just copy pip install discord into ur cmd
just copy it
cntrl +r/ type cmd then do pip install
win*
just open your commandline, and type in pip install discord
fuck i accidentally did pip install discor
how to open command line? (im sorry i dont know)
press windows+r, then type cmd, then enter
are u using windows
no u type cmd in it
now
send scrnshot
nice
this opened
yeah now do pip install
type there?
now type in pip install discord
yes
like this?\
yea
now hit enter
ok
remove the ok first tho
ok
getting this error while making a leveling bot
ive installed pip install discord, pip install pymongo and pip install dnspython
send ur code
yeah
ur getting an attribute error
ye
possibly
its find_one, not find.one
ok just reintall python
wha-
alright lemme see
mongo right?
no, now do py -m pip install discord
ye
ah it should work
don't uninstall python, because version 3.4+ come w/ pip
yes
enter?
yes
assuming that levelling is a motor Collection, it's fine_one, rather than find.one
reinstall python
yeah u dont have pip installed
py -m ensurepip
what is pip??
try this before you reinstall
tool used to install packages
k
ensurepip.bootstrap() does what again?
ensures that pip is installed, and if not installs pip
wish i knew that 3 months ago :|
@earnest ferry i still advise you to learn more py then coming to discord.py because u will face obstacles
Yeah I was annoyed when i found this out
ok thnx synthethic
ages of not knowing it existed, and it turned out to be one command
you can install the pip installer, without pip?
yes
clicked enter
result?
it might need to download data first
c:\Users\Public\Documents\Wondershare\CreatorTemp\tmptq_urln_
Processing c:\users\public\documents\wondershare\creatortemp\tmptq_urln_\setuptools-58.1.0-py3-none-any.whl
Processing c:\users\public\documents\wondershare\creatortemp\tmptq_urln_\pip-21.2.4-py3-none-any.whl
Installing collected packages: setuptools, pip
yeah ur good
yup it's working
what it mean?
ensurepip, from what i understand, is just a very specific utility made to install pip itself, as such it doesnt need much of the complexity of pip
its downloading
ohk
it means it's working
how muuch time to download
like 2 sec
bro i REALLY suggest you go ahead an learn about objects and classes before discord.py otherwise it will be HELL
Corey schafer has a great video on OOP in python: https://www.youtube.com/watch?v=ZDa-Z5JzLYM
im 13 and in 7th
@slate swan in 13 saleshone
i watched the exact same thing
like u kinda need to know what ur writing
oh..
In gr7 they gave us CODE.ORG, and didn't even teach us CONDITIONALS
does ur school teach u?
i don't trust the school system when it comes to optional stuff because they will just sleep on it
Hey at least you didnt have to learn in java 🥲
well yes but actually no
tell pls
if school teaches u , i advise u to learn it urself
i know
the school teachers are shit at programming
like i rmemeber they were teaching us c++ in school
lucky
and we wrote them on a piece of paper
^
wtf
they taught us code.org, and it didn't even run most of the time, cuz the compiler was shit
don't
regenerated it again
how tf is this legal
what?
it was trash
send tokens?
bruh can anyone help
send code
ok
I think that most people started coding as kids in html, js or css, is that true?
Hey @mystic grotto!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
ig yep
Can someone hep me fix this?
ur indentation
whoa
they sent it in their message
my spelling lol
where to place the cursor?
ah, i remember the days when i used to code user-unfriendly websites in html on windows notepad
lol
read the error, don't use tabs and spaces, just stick to one
preferably tab (4 spaces)
wat
wut
C:\Users\Holy>py -m ensurepip
Looking in links: c:\Users\Public\Documents\Wondershare\CreatorTemp\tmpb5xgvd02
Requirement already satisfied: setuptools in c:\users\holy\appdata\local\programs\python\python310\lib\site-packages (58.1.0)
Requirement already satisfied: pip in c:\users\holy\appdata\local\programs\python\python310\lib\site-packages (21.2.4)
indent
where to indent
pip is already installed
ye ik
someone...?
so wats the problem
run again?
btw was pip install discord successful?
how can i knwo?
u do it again and if it says its already satisfied then its ok
thats old token i regenrated
or do pip list
do it first
Excuse me for asking, is there a replacement for the avatar_url_as method in the discord.Member class in the py-cord framework?
in vsc?
u can always use requests library to get the avatar url
but discord.py wise i have to check
Yes, it's now member.avatar.with_format()
@slate swan tell in vsc? the upper tabs??
ye
does it even open
okay, thanks @royal lichen @slate swan
new terminal
click on it?
and reset your token you've leaked it now
ah, ok
tell
yeah does it open
type it?
uhm sure
press etner
just went to other line thats it
so like nothing happened
i would advise you to just reinstall python
and make sure to install pip in the process
like make sure pip is checked in the process
and add to path
ok thanks .....
i am quiting (im a nub) ill learn all first then ill come again back
good luck ❤️
see ya!!
btw delete your messages you exposed your token ;-;
i regenerated
To tab it 3 more times?
Hi peeps Have a doubt
sure ig, try playing around with the indents where the error gets caused and it should get fixed
?
Hm?
my flipacoin feature is not working
@client.command(name = "flipacoin")
async def coin(x):
headsortails=random.randint(0, 1) #Gives a 50% chance for each
if headsortails == 0:
flip="Heads" #Sets the name based on the number gotten
else:
flip="Tails"
await x.message.channel.send("I flipped my coin and got..."+ flip+"!")
this is the code
no error it just doesnt work
no like a flip a coin feature
if the user puts $flipacoin it should take a random choice between heads or tails and send it
huh?
Yea
ok
like this?
@client.command(name = "flipacoin")
async def coin(x):
headsortails=random.choice([1, 0]) #Gives a 50% chance for each
if headsortails == 0:
flip="Heads" #Sets the name based on the number gotten
else:
flip="Tails"
await x.message.channel.send("I flipped my coin and got..."+ flip+"!")
Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.
>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."
Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.
let me try
Also instead of x.message.channel.send, u can also use x.send
Yea
but it doesnt work
@maiden fable shouldn't your name be "retnuH"[::-1] 👀
Did u reload the bot?
yes
Okay...
Add a print statement on the top of the function
And print anything, to see if it's even getting printed
Use random.choice(["heads", "tails"])
Isn't that what I said lol
ok
And it's his wish if he wanna do heads and tails or 0 and 1 :D
Using 0 and 1 is pointless and slows it down but if you like it then use it
You could just always return heads or tails statically, if they cant see your code they dont know if it's truly random :)
Well yea
?
could you explain what you are saying
joke about random numbers
in theory a random number gen could always return True
how would you prove it isnt random without the code 😉
U won't need any if statements. Just do
async def flip(ctx):
choice = random.choice(["heads", "tails"])
await ctx.send(choice)
!e
...
@boreal ravine :warning: Your eval job has completed with return code 0.
[No output]
eval works again 🗿
And how r u running the command?
wdym
Like what r u sending in the chat
$
$
$flipacoin
yes thats what i put
that should work lol
let me try with my bot rq
@night seal do you have a event in your code?
Ah yea do u have an on_message?
If yes, then instead of using client.event, use client.listen()
Anyone code bots for free?
There we go
yes
???
Client in this case
Why....?
Just change client.event to client.listen() thTs it
await client.process_commands(message)
Changing the deco is easy (:
at the end of ur on_message function
but am using client.command
What? Can I see the event?
changing the decorator will cause problems later on, and isnt as useful as this
@bot.event
async def on_message(message):
if message.author == bot.user:
return
await bot.process_commands(message)
What problems...?
could be number of them, ur using a listen decorator on a what should be a command
What r u even saying bro
How can an on_message be a command...?
I can make on_message work like a command, even if it doesnt use a command decorator
exe format error - errno 8 in line 41
@bot.command()
async def cf(ctx):
choices = random.choice(["heads", "tails"])
await ctx.send(f"I flipped and got {choices}!")
this works @night seal
bot is "client" for u
Still you can use the bot.listen() deco, bet me a nitro
but why use it when its not the intended purpose lol
Smh leave it. U won't understand
from disnake.ext import commands
bot = CustomBot(command_prefix="$")
@bot.event
async def on_ready():
print('We have logged in as {0.user}'.format(bot))
@bot.event
async def on_message(message):
if message.author == bot.user:
return
await bot.process_commands(message)
@client.command()
async def cf(ctx):
choices = random.choice(["heads", "tails"])
await ctx.send(f"I flipped and got {choices}!")
bot.run("TOKEN")
should be all it takes tho ^
where do i put the client.command
the command decorator goes before a command, like above ur coinflip function
can u show me your code
the order of ur functions doesnt matter that much in general
a command decorator is separate from an event decorator
Yes that should work, assuming u don’t have an on_message(message) without await client.process_commands(message)
It doent work
Show me all of u code, if u can
How to do it?
@bot.command()
async def verify(ctx):
embed = discord.Embed(title=f'Verification', description=f'You have `1` attempt to verify. If you fail, you may be re-evaluated by executing the command again', color=clr)
failbed = discord.Embed(title=f'Verification', description=f'You have failed the verification process! Please try again', color=clr)
passbed = discord.Embed(title=f'Verification', description=f'You have passed the verification process! Enjoy your stay', color=clr)
captcha = random.randint(1, 4)
if captcha == '1':
embed.set_image(url=f'https://cdn.discordapp.com/attachments/910579746205745283/917283179843452970/wickCaptcha.png')
await ctx.send(embed=embed)
def check(m):
return m.author.id == ctx.author.id
msg = await bot.wait_for('message', check=check)
if msg.content == 'KZEXEH':
await ctx.send(embed=passbed)
await user.add_roles(917654915311099944)
else:
await ctx.send(embed=failbed)
elif captcha == '2':
embed.set_image(url=f'https://cdn.discordapp.com/attachments/910579746205745283/917283141130006578/wickCaptcha.png')
await ctx.send(embed=embed)
def check(m):
return m.author.id == ctx.author.id
msg = await bot.wait_for('message', check=check)
if msg.content == 'SXOXMM':
await ctx.send(embed=passbed)
await user.add_roles(917654915311099944)
else:
await ctx.send(embed=failbed)``` no errors, dont know what to do
What exactly do you want to do? Verification by button?
verification by captcha
this is what captcha 1 is
so if they type ^verify it randomly selects a captcha and wait_for()'s their response
and no errors?
no errors
Why are u created functions inside of it
For the checks
the def check(m)
Which is normal
any idea why it wont work?
how can I send a dm to a user using their id?
bots can only dm users with mutual guilds i dont see why youd want this
You can't use add_roles with just an ID
You need to use get_role
This isn't the server to solicit developers. This server is for asking questions on the Discord API
!d discord.Guild.get_role
get_role(role_id, /)```
Returns a role with the given ID.
thanks
Wrong.
and that would solve everything?
i want to make a command like !bug <explain> and then the <explain> will be sent to the creator, in this case, me
Use something like
role = blabla.get_role(id)
await blabla.add_roles(role)
How to make the same system, but only with a ban? The choice will be server ban or permanent. When a server role is issued, when a permanent ban is usually
https://support.discord.com/hc/ru/articles/4403375759255-Bots-Select-Menus
Has nothing to do with that
u have 4 possible captchas not just 2 right
invoke user as user : Union[discord.Member, discord.User], pass it in your command with user.message
youll have to use argument statements though
so something like ctx, user : Union[discord.Member, discord.User], explain):
and pass with await user.send(pass)
im not sure if thats the proper attr for dming members but
thats the basic idea of it
Anyone made a modmail bot before?
i know how you can make a basic ticket system but not too sure on a modmail
Just wanna know
yeah but elifs will handle all of em the same, its not like the count matters cuz i can always add to it
Ok
ctx.guild.get_roles works for this correct?
im assuming it would
whats modmail do exactly
Is like a bot you can message and get a response from staff are whoever
!d discord.ext.commands.Bot.wait_for
wait_for(event, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.
The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.
In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
Like @novel apex
thatd be a good start
How do I make an emoji appear under your message after a successful kick?
And the bot's message was deleted after a couple of seconds
from discord.ext import commands
client = commands.Bot(command_prefix = '!')
@client.command()
@commands.has_permissions(kick_members=True)
async def kick(ctx, user: discord.Member, *, reason=None):
await user.kick(reason=reason)
await ctx.send(f"{user} был успешно кикнут.") ```
msg = await ctx.send(f"{user} был успешно кикнут.")
await msg.add_reactions('emoji')
It's going to look like this, right?
from discord.ext import commands
client = commands.Bot(command_prefix = '!')
@client.command()
@commands.has_permissions(kick_members=True)
async def kick(ctx, user: discord.Member, *, reason=None):
await user.kick(reason=reason)
msg = await ctx.send(f"{user} был успешно кикнут.")
await msg.add_reactions('✔️') ```
i mean a good start would be with an on_message and have if isinstance(message.channel, discord.channel.DMChannel): to check if its dm's
yes but add the emoji
Thx
there
error
no
Why?
wait it actuaally is
You work around a modmail bot before though?
ive tried but not fully done it
ive done a ticket one but that would be a start to a modmail
!d discord.Message.add_reaction use the class name
await add_reaction(emoji)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Add a reaction to the message.
The emoji may be a unicode emoji or a custom guild [`Emoji`](https://discordpy.readthedocs.io/en/master/api.html#discord.Emoji "discord.Emoji").
You must have the [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission to use this. If nobody else has reacted to the message using this emoji, the [`add_reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.add_reactions "discord.Permissions.add_reactions") permission is required.
one problem
?
show code
No problem
Hold 🙂
import discord
from discord.ext import commands
client = commands.Bot(command_prefix = '!')
@client.command()
@commands.has_permissions(kick_members=True)
async def kick(ctx, user: discord.Member, *, reason=None):
await user.kick(reason=reason)
msg = await ctx.send(f"{user} был успешно кикнут.")
await add_reaction(✔️)
# ban
@commands.has_permissions(ban_members=True)
async def ban(ctx, user: discord.Member, *, reason=None):
await user.ban(reason=reason)
msg = await ctx.send(f"{user} был успешно забанен")
await add_reaction(✔️)
#unban
async def unban(ctx, *, member):
banned_users = await ctx.guild.bans()
member_name, member_discriminator = member.split('#')
for ban_entry in banned_users:
user = ban_entry.user
if (user.name, user.discriminator) == (member_name, member_discriminator):
await ctx.guild.unban(user)
msg = await ctx.send(f"{user} был успешно разбанен")
await add_reaction(✔️)
return
thats wrong it needs to be await msg.add_reaction('emoji'), needs to be in quotes and u need to specify the message
how would it know what message it is adding a reaction to
just like what i did
Did you ask me if i wanna see it?
How to check if bot fully connected to voice and ready to play audio?
anyone know if you can specify which loop you want to use with the @tasks.after_loop?
What's wrong here?
from discord import member
from discord.ext import commands
from dislash import InteractionClient, ActionRow, Button, ButtonStyle
TOKEN = "my token"
intents = discord.Intents.all()
bot = commands.Bot(command_prefix = "!", intents = intents)
@bot.command() # Выдача ролей при помощи select menu
async def roles(ctx):
await ctx.channel.purge(limit=1)
give_roles = discord.Embed(
title = 'Автоматическая выдача ролей',
description = '**Вы можете самостоятельно получить роль вашего сервера выбрав ее название в меню. \
\n При выборе определённых ролей Вам будут открываться соответствующие текстовые и голосовые каналы. \
\n Если Вы не играете ни на одном из серверов, то Вам будет доступен** **__только общий чат.__**\n \
\n **Роли доступные для получения в данный момент:** \
\n🎭 — <@&889169786121097296>\n🌅 — <@&881961587559243877>\n🌈 — <@&881962331544891443>',
color = 0xfff700,)
give_roles.set_thumbnail(url='https://images8.alphacoders.com/102/1026336.jpg')
give_roles.set_footer(text='© Bumbazzz')
await ctx.send(
embed=give_roles,
components = [
Select(
placeholder = "Выберите Ваш сервер",
options = [
SelectOption(label = "Insquad", value = "Insquad🎭", description = "GTA 5 RP | InSquad", emoji = '🎭'),
SelectOption(label = "Sunrise", value = "Sunrise🌅", description = "GTA 5 RP | Sunrise", emoji = '🌅'),
SelectOption(label = "Rainbow", value = "Rainbow🌈", description = "GTA 5 RP | Rainbow", emoji = '🌈')
]
)
]
)
interaction = await bot.wait_for("select_option")
# member = ctx.member()
# await member.add_roles(interaction.values[0])
await interaction.send(content=f"Роль {interaction.values[0]} была вадана!", embed=embed)
How can i change a buttons color on disabled
just change it before disabling
i haven't tried it before, not sure if discord allows to change color of a button
why await voice.connect raise TimeoutError?
await connect(*, timeout=60.0, reconnect=True, cls=<class 'discord.voice_client.VoiceClient'>)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Connects to voice and creates a [`VoiceClient`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceClient "discord.VoiceClient") to establish your connection to the voice server.
This requires [`Intents.voice_states`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.voice_states "discord.Intents.voice_states").
asyncio.TimeoutError – Could not connect to the voice channel in time.
How to fix this?
fix your internet
How can i dont see a kwarg or anything really
Not in docs or git examples
!d discord.Button.style
The style of the button.
Thats settings a buttons color
I want to change it after it set like edit it on disabled
What to do? Interaction error!
Code:
just like disabled, it is an attribute
# Выдача ролей при помощи select menu
@bot.command()
async def rolesp(ctx):
await ctx.channel.purge(limit=1)
give_roles = discord.Embed(
title = 'Автоматическая выдача ролей',
description = '**Вы можете самостоятельно получить роль выбрав ее название в меню. \
\n При выборе своей гендерной роли вы будете выделяться ее цветом. \
\n Роли доступные для получения в данный момент:** \
\n:female_sign: — <@&864246807353884722>\n:male_sign: — <@&864246881667383336>',
color = 0x36393E,)
give_roles.set_thumbnail(url='https://media.discordapp.net/attachments/865681789493051423/917820894234169454/static.png?width=172&height=172')
give_roles.set_footer(text=':zap:Cascade:zap:')
await ctx.send(
embed=give_roles,
components = [
SelectMenu(
placeholder = "Выберите гендерную роль",
options = [
SelectOption(label = "Девушка", value = "Девушка:female_sign:", description = "Вы получите гендерную роль женского пола!", emoji = ':female_sign:'),
SelectOption(label = "Парень", value = "Парень:male_sign:", description = "Вы получите гендерную роль мужского пола!", emoji = ':male_sign:'),
]
)
]
)
interaction = await bot.wait_for("select_option")
# member = ctx.member()
# await member.add_roles(interaction.values[0])
await interaction.send(content=f"Роль {interaction.values[0]} была вадана!", embed=embeds)
bot.run(TOKEN) ```
Button.disabled = True
Button.style = ...```
show me how you disabled it
I disable it with children as you get a list of the components
there are two ways to do it (probably), i need to know which one you chose
View.children?
As i said i get a list of the components in the class with childrenc
arent you subclassing discord.ui.View?
Dont even know whats a sub class as people never explain well i just assume its a class in a class
@bot.command()
async def verify(ctx):
def check(m):
return m.author.id == ctx.author.id
msg = await bot.wait_for('message', check=check)
role = message.guild.get_role(917654915311099944)
embed = discord.Embed(title=f'Verification', description=f'You have `1` attempt to verify. If you fail, you may be re-evaluated by executing the command again', color=clr)
failbed = discord.Embed(title=f'Verification', description=f'You have failed the verification process! Please try again', color=clr)
passbed = discord.Embed(title=f'Verification', description=f'You have passed the verification process! Enjoy your stay', color=clr)
captcha = random.randint(1, 4)
if captcha == '1':
embed.set_image(url=f'https://cdn.discordapp.com/attachments/910579746205745283/917283179843452970/wickCaptcha.png')
await ctx.send(embed=embed)
if msg.content == 'KZEXEH':
await ctx.send(embed=passbed)
await ctx.author.add_roles(role)
else:
await ctx.send(embed=failbed)
elif captcha == '2':
embed.set_image(url=f'https://cdn.discordapp.com/attachments/910579746205745283/917283141130006578/wickCaptcha.png')
await ctx.send(embed=embed)
if msg.content == 'SXOXMM':
await ctx.send(embed=passbed)
await ctx.author.add_roles(role)
else:
await ctx.send(embed=failbed)``` no errors, not sure what to do
welp,
class MyView(discord.ui.View)```
is your code like that
MyView is a subclass of it, it has everything the original class has
including View.children
!d discord.ui.View.children
The list of children attached to this view.
