#discord-bots
1 messages · Page 604 of 1
from discord.ext import commands mb
Never tried just doing that
!d discord.ext.commands.Context.reply
await reply(content=None, **kwargs)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
A shortcut method to [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") to reply to the [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message").
New in version 1.6.
I always import discord but it always says its never used in vsc
?
thats for embeds, typehinting etc
Makes sense
for replying to messages dmh
hello, i have put this into my embed field to ping a role, but it doesnt get pinged <@&816595770052182026>
You mean when a command is invoked it sends a message?
it canr ping in embed titles
Yea like !help or something
Is that for like replying to a message like im doing rn?
Anyone can help me with this error?
discord.ext.commands.errors.ExtensionNotFound: Extension 'dev-panel' could not be loaded.
My code:
if filename.endswith('.py'):
bot.load_extension(filename[:-3])```
yes
im using ```py
elif member.activities[0].ActivityType.listening:
act = f"Listening"
elif member.activities[0].ActivityType.competing:
act = "Competing"``` and i get the error that ActivityType is not an attr, isnt it?
or have i put an attribute in the wrong place
its a class
compare it 2 the class
!d discord.ActivityType
class discord.ActivityType```
Specifies the type of [`Activity`](https://discordpy.readthedocs.io/en/master/api.html#discord.Activity "discord.Activity"). This is used to check how to interpret the activity itself.
well what do you recommend
Thx
Hmm? Sk what happend
comparing the members activity to the class
Learn python first and then go to dpy
@boreal ravine problem is listening and competing and watching arent actual activities
hm
like playing, spotify, and streaming
!d discord.ActivityType.playing
A “Playing” activity type.
!d discord.ActivityType.watching
A “Watching” activity type.
..
!d discord.ActivityType.listening
A “Listening” activity type.
yeah i figured the other 2 lol
!d discord.ActivityType.watching
A “Watching” activity type.
!d discord.ActivityType
class discord.ActivityType```
Specifies the type of [`Activity`](https://discordpy.readthedocs.io/en/master/api.html#discord.Activity "discord.Activity"). This is used to check how to interpret the activity itself.
@slate swan exists :)
Here's types
so would i do something like if member.activitytype.listening is true:
obviously cased properly
no
compare the member activity 2 the class
if ... = discord.ActivityType.listening
oh i see
if listening -
so its like if "nostuff" == str(stuff):
@slate swan all links you need:
https://discordpy.readthedocs.io/en/stable/ext/commands/index.html
https://vcokltfre.dev/
https://pythondiscord.com/resources
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.
We're a large, friendly community focused around the Python programming language. Our community is open to those who wish to learn the language, as well as those looking to help others.
The bot tutorial is up-kept by this community. and vcokltfre is good about keeping everything up to date and has some great explanations for beginners.
Yeah hes the goat
Hello, Im working with json. When I want to for example dump a users id into the json file how do I make it so they all stack up on eachother. Right now I wrote a message and it saved my id, then my friend wrote a message but his id overwrote my id. How can I make this not happen?
you need to load the existing file into a dict(?) object and add to the object and then dump it.
Shouldn't use json as a database
Lovely Youtube Tutorial again 😄
Just a small project. Not using this for anything big. Also, I find json easy, cause I dont have to create or download any apps and accounts and all sorts of stuff.
you dont need to download anything with sqlite3 either
I’m trying to put this into an embed but it’s not working, can someone help?
await ctx.send("Color {}:".format(colour_code), file=discord.File(file, "colour_file.png"))```
Just because it's easy doesn't mean you should do it
And as mentioned sqlite doesn't require a server or something downloaded
How did you try putting it into an embed
embed = discord.Embed(
title=f"Color {colour_code}",
timestamp=datetime.utcnow()
)
embed.set_image(url="https://colour_code.png")
await ctx.send(embed=embed)```
!local-file
Thanks to discord.py, sending local files as embed images is simple. You have to create an instance of discord.File class:
# When you know the file exact path, you can pass it.
file = discord.File("/this/is/path/to/my/file.png", filename="file.png")
# When you have the file-like object, then you can pass this instead path.
with open("/this/is/path/to/my/file.png", "rb") as f:
file = discord.File(f)
When using the file-like object, you have to open it in rb mode. Also, in this case, passing filename to it is not necessary.
Please note that filename can't contain underscores. This is a Discord limitation.
discord.Embed instances have a set_image method which can be used to set an attachment as an image:
embed = discord.Embed()
# Set other fields
embed.set_image(url="attachment://file.png") # Filename here must be exactly same as attachment filename.
After this, you can send an embed with an attachment to Discord:
await channel.send(file=file, embed=embed)
This example uses discord.TextChannel for sending, but any instance of discord.abc.Messageable can be used for sending.
Random question you set a timestamp in a embed in the footer text thing?
set in the constructor or set the Embed.timestamp attr
embed = discord.Embed(
title= str,
url= str
description= str,
color= int / hex
timestamp= dateObj
)
Never knew it had that attr
Thx
either or really.
Thx
Hello, do I need a database to make a discord leveling bot ?
@brittle ingot i have a question
how could i make something for every 12 hours it clears chat
yes
you would need to use the tasks ext of discord.py
with tasks.loop
example
I am pretty new to databases why would need one for a leveling bot?
oh gosh.
well
i know how to use tasks
but would i have to fetch channel and use ctx.channel.purge or whatever
what is it
To keep a record of the users level
ok thnx
so a bot doesn't store information constantly, it can store little snippets, but when its shut off all that data is lost. Saving it in a database makes it so you can store access and update that information regardless of whether you bot is online.
^ better explanation
most likely yes.
!d discord.ext.tasks.loop
discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True, loop=...)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
can't I just keep the records on a json file?
!d discord.Client.get_channel
get_channel(id, /)```
Returns a channel or thread with the given ID.
Not good to keep data in json
it takes an id ..
you could but its not recommended as JSON isn't meant to be used as a database, its more of a way to exchange data across the web or between applications. With that said its easily corruptible
Not a db but a format its used for data exchanging and not saving data
exactly
If i had any useful information for you wass it would be to learn about SQL, you can download Codeacademy app on your phone and learn SQL easily and for free. Then you will be able to apply that to database libraries like PostgreSQL, Sqlite3 or even mariaDB.
More like a clear pipe exchanging water to another bucket which a db is the starting bucket which a db has encryption so it wouldn't be a clear pipe
ok thnx
no problem
#this function checks if the command is being executed in the right channel
def check_channel(ctx):
text_channels=['bot_commands', 'bot_commands', "🤖 bot_commands"]
if str(ctx.channel) in text_channels:
return True
@commands.command()
@commands.check(check_channel)
How can I do the check with a command that's in a cog is the code down bellow right?
#this function checks if the command is being executed in the right channel
def check_channel(self,ctx):
text_channels=['bot_commands', 'bot_commands', "🤖 bot_commands"]
if str(ctx.channel) in text_channels:
return True
@commands.command()
@cog_check(check_channel)
there is a way to make it its own check that you can call like @your-check.
!d discord.ext.commands.check
@discord.ext.commands.check(predicate)```
A decorator that adds a check to the [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") or its subclasses. These checks could be accessed via [`Command.checks`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command.checks "discord.ext.commands.Command.checks").
These checks should be predicates that take in a single parameter taking a [`Context`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Context "discord.ext.commands.Context"). If the check returns a `False`-like value then during invocation a [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure") exception is raised and sent to the [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") event.
If an exception should be thrown in the predicate then it should be a subclass of [`CommandError`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandError "discord.ext.commands.CommandError"). Any exception not subclassed from it will be propagated while those subclassed will be sent to [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error").
so what does the @cog_check() decorator do?
def cmdChannelOnly():
def predicate(ctx):
return ctx.channel.name.contains(['commands', 'cmds'])
return commands.check(predicate)
@commands.command()
@cmdChannelOnly()
async def only_me(self, ctx):
await ctx.send('Only you!')
according to the documentation
Next time put it in a code block so you wont ping any user
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
Just remove py to make it a code block
`code` for inline code
The word cog
you created your own decorator right?
yea
Why a function inside a function? And how did you make it to a decorator never seen it done before
i updated it, because i forgot one vital part.
its in the docs. literally just copy pasted it 😂
Oh bruh😭
So I downloaded pycord for the first time
I'm running into weird errors
Thx
just scroll down slightly and you'll see it
Ty
i apologize i can't help with PyCord or your errors will just get weirder 😂
is pycord that trash 😂 ?
yeah I am currently using disnake
never heard of that either 😂
You said what?
what are u using ?? still with discord.py or using discord.js?
I haven't used python since the discontinuation letter from Danny came out. Look at my status 😂
import discord
import discord.ext.commands
from discord.flags import Intents
with open("secrets/token") as data:
token = data.read().strip()
bot = discord.Bot(
command_prefix = "$",
intents = Intents.all()
)
bot.run(token)
Raising an error saying discord has no attribute Bot when according to the docs, it clearly does?
Disnake is probably the best fork out there,same syntax and most advanced
its commands.Bot and your imports are off
Using pycord huh, sure you got it installed?
Pycord added discord.Bot for slash commands. So uh, yea weird
it is from discord.ext import commands
What should my imports be? I'm waaaay too used to Hikari now. I'm trying out pycord because Hikari has super limited voice support
You can do that too(i think)
then do commands.Bot
Oh thanks
import discord
from discord.ext import commands
bot = commands.Bot(
command_prefix = "",
intents = discord.Intents.all()
)
bot.run(token)
!d
If there using pycord it's valid syntax 🤢
#bot-commands
Python bot requires it be exact sadly
^
that's because it scrapes im pretty sure
Its really bizarre since discord.Bot is definitely valid in pycord
wait you're using PyCord?
Like I've been saying... Tut
Yeeeep
lol my bad, im ded okay 😂
Guess I'm blocked but read this
you aren't blocked.... why would you be
This is annoying
I'll try installing pycord again, but if I can't get it to work I'm going back to hikari lol
You can put it in a try except. So if it's forbidden or fails it sends to ctx.channel
use a try except block. in the except handle discord.Forbidden
Use except
oof lol
Not just except add discord.Forbidden
try:
await member.send()
except discord.Forbidden:
await ctx.send()
can't say i've never done that before
On mobile so not well indented
just a tip:
ctx.channel.send() is the same thing as ctx.send(). no need to add channel.
^
^
Time to learn javascript lmao, this is too much trouble
@slate swan Btw you can use bare except but it isnt recommended as it can raise any error so add discord.Forbidden after so it will except a discord error as dms are locked
Lmao. The dark side 😂
Learning a whole language because a single package import broke lol, fun
I have to learn it at some point, might as well be now
There are lots of libraries I could use lol
You could also just work with discord.py to get used to it… if you haven’t already
And then just move to disnake so you wont migrate to disnake when dpy is unusable
I think once I get my current projects done I’ll make a python bot and test out the current forks
Disnake is good same syntax so its good
All you have to change is from discord to disnake or just import disnake as discord
IK that sebkuip is collaborating with another py dev on a discord.py fork
Well not a fork, they’re rewriting it from scratch. Been kinda cool to see the guts of the library
I need slash commands lol
Thats cool
I installed disnake, this is working
Disnake has slash conmands
If you want to use just slash commands discordjs is your solution, although it’s difficult to do any other type of command
Honest assessment would be to just try disnake since okimiii speaks so highly of it
That sounded snobby wasn’t meant to
Yes 
slash commands are all I really like lol
Using disnake, can I create prefix and slash commands under the same code?
Or do I have to write them separately
Dont know never tried it
And i think in disnake slash commands have their own decorator
Yeah I'll have to define them separately
ctx.voice_state docs?
can someone help me with the wait_for command please? the documentation is so confusing
a_file = open("puzzles.txt","r")
linenum = ""
lines = open('puzzles.txt').read().splitlines()
puzzleline = random.choice(lines)
for number, line in enumerate(a_file):
if puzzleline in line:
linenum = number + 1
break
Titleline = linecache.getline(r"titles.txt", linenum)
hint1 = linecache.getline(r"hint1.txt", linenum)
hint2 = linecache.getline(r"hint2.txt", linenum)
hint3 = linecache.getline(r"hint3.txt", linenum)
incorrect = linecache.getline(r"incorrect.txt", linenum)
solution = linecache.getline(r"solutions.txt", linenum)
answer = linecache.getline(r"answers.txt", linenum)
imageline = linecache.getline(r"images.txt", linenum)
embedVar = discord.Embed(title="Puzzle No. " + str(linenum) + ":" + str(Titleline), description = str(puzzleline), color=0xE95124)
embedVar.set_image(url=imageline)
embedVar.add_field(name="Stuck?", value="Type 'l!hint' for a hint!", inline=False)
embedVar.add_field(name='Want to Stop?', value="Type l!exit or l!stop to stop!", inline=True)
embedVar.set_footer(text="A true gentleman never leaves a puzzle unsolved...")
await message.channel.send(embed=embedVar)```
basically i want to check for a few commands after the await command
did ctx.voice_client have disconnect?
nvm i think i gotit
I'v created a webform in which someone can input data, a username. I want that data (username) to be passed to my discord bot awaiting a response from an admin. I want to execute a conditional based on the admins response. How can i make my bot listen for an input from an external source?
you have to wrap up the main functionality of your command to a function, then add a slash command and a textual command and inside them just call the function
why my bot said Volume of the player set to 1% but no effect on sounds?, no error were showed
Yea
can you help my newer?
https://replit.com/@CG158/Layton-Bot#main.py can someone help, when I run this and execute the l!puzzle command, a error "TypeError: on_message() missing 1 required positional argument: 'self'" pops up
Nvm fixed it lol
I won't recommend making your bot like this, you should use the extension, discord.ext.commands
it is thousand times better
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix="!")
@bot.command()
async def puzzle(ctx):
...
@bot.command(aliases=["about"])
async def what(ctx):
...
for the help command, we have a very useful class to automate the process.
!d discord.ext.commands.HelpCommand
class discord.ext.commands.HelpCommand(*args, **kwargs)```
The base implementation for help command formatting.
Note
Internally instances of this class are deep copied every time the command itself is invoked to prevent a race condition mentioned in [GH-2123](https://github.com/Rapptz/discord.py/issues/2123).
This means that relying on the state of this class to be the same between command invocations would not work as expected.
you can have a look here,
https://github.com/m-y-x-i/simple-disnake-discord-bot/blob/main/cogs/help.py
@slate swan take time, try and see which is easier to maintain
I just make a command named help lmfao
I fixed it but thank you
thats waste of time
Its a recommendation
Eh
check that
100 lines of code and now i will never have to worry about the help command
@slate swan check this its better
https://vcokltfre.dev/
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.
If your learning dpy ^
If your in disnake just replace discord with disnake and you'll be good or just import disnake as discord
replacing it with disnake is recommended, reduces that 30 percent chance of getting confused
Yeah
Hello!
https://rapidapi.com/apidojo/api/yh-finance
I would like to implement this into my discord bot but i dont know how to convert it to python
This API helps to query financial summary, stocks, quotes, movers, etc… to create a financial site/application such as Yahoo Finance at finance.yahoo.com
or thishttps://rapidapi.com/twelvedata/api/twelve-data1
Financial data provided for developers, to enter the world markets. Instant access for real-time and historical data of stocks, forex, crypto, ETFs, indices, and more. Read more in documentation and start here.
There’s literally a python code snippet tho?
lol
use aiohttp or httpx.AsyncClient()
the python snippet there will block the code
ey myxi can you help my problem?
here
i dont have experience with voice stuff
Now u know it (:
pls ://
How didnt you not know that if your iterating through a list of guild.members?
go to your bot's Oauth2 , select General ,
default auth link ..
if you mean the invite bot thingy
no
in new update
discord bots can have a Add to Server Button in the profile
discord doesn't allow to change volume of voice members for everyone that is something the client does
Yea
this
thats what i said bro
how to do that ?
Bruh, Sarthak said the correct way 🤦
i just sent that
what is the use of members intent
you dont need to code for that
it need reason
no i want to change the bot volume
it needs intents ?
no
!d discord.VoiceClient.edit
ohk
Nvm, I forgot the method
then how ? it is possible in discord.py ?
Bro.....
what version are you using?
then ?
newest
the master branch?
didnt specify version so it will be newest
wut?
bro pls tell Oauth2 -> General then ??
default auth link
did you install it from git or just pip install discord.py
what should i select ?
select in app authorisation from the box
if i didnt do that why i ask the cmd problem

because ctx does not have a voice_state
in the master branch , unsure about 1.7.3
wht is in-app auth
ur main file*
bro
cogs
just go to it and play with it
:/
isn't changing volume something ffmpeg does tho
😐
the 'add to server' button
yes
and custom url means ?
how is that related?
just go to it
what to do ?
wut
see , doesnt exist
in-app
ok
did you watch any tutorial for the code?..
ohh i understood it is asking for invite link
why ctx.voice_state.voice.pause work fine?
!d discord.VoiceState
class discord.VoiceState```
Represents a Discord user’s voice state.
select in app auth and check on bot and application commands ( if you want slash cmds ) as well
there is no ctx.voice_state to return VoiceState
i think better to choose the perms again i should give a already existing link ?
your wish
hm
discord doesnt reduce volume, your bot counts as a member too. pretty sure thats something ffmpeg should do tho
Is it only for PC?
but idk its discord anything could happen
not only ffmpeg
idk
yes
Mac and windows both?
yes
And no android or IOS?
its beta
dont think its implemented on android
Ohh
nope
Nope, as usual
kk
Not even message and user commands on mobile 🤦
Its only meant for pc iirc
tnx
mobile devices always get late updates
😩
I am using Discord Beta on mobile tho
can , it still takes a long time
canary if completely different and a lot buggy
Ah, the one with the yellow icon?
You can get on google play?
Yea
yeah i dont remember actually , its yellow in pc tho
or apk mirror
You have to join the beta program iirc
well afaik discord wont put ats button on mobile because the feature for clicking oauth links on pc makes ur life easier rather than going to another website to authorize a bot i think thats why they added the button
they can make it on mobile too tho
yea just like the listen along button for spotify
I dont think putting smth on another app is possible
well how to prevent different vc people disconnect the other vc musics?
another app?
it would anyways redirect you to a browser , which kills the purpose
yes
they got money, they can make it easier on mobile too
like add button would open smth on discord mobile app
Doesnt matter if they have money or not, if they add the button it'll just redirect u to a browser like sarthak said
that would be just like the slash commands , which take 5-10 seconds just to show up on mobile devices
you cant do that on mobile
it doesn't need to, if they try they can do something like what happen when you click the nitro accept button
a floating thing where they can add bots
no need of browser
its their api they can do anythjng
¯\_(ツ)_/¯
thats what im saying
Why do you keep saying this, not everything is possible on discord, the entire platform is shit
The disrespect
While your wearing there logo as a pfp😭
ik the platform is shit but they made it they own it, the entire thing is their, they have money, they have paid programmers and they can even change this to a clone of onlyfans if they want thats im saying
they can implement new stuff
I'm not prepared to properly learn disnake now lol
why?
you dont have to learn it just learn python
you dont need to learn something new
I'm just so comfortable with hikari
I need to learn how to do voice commands on hikari, its a bit of a pain on it though
lol i see , remaking my bot in hikari too
Thats... not how that works lol
voice commands , and the channel purge thingy in hikari sucks , especially when u use raw hikari
I refuse to use raw hikari for that lol
I'm using the lavasnek_rs library
lightbulb/tanjun?
No need to rush or jump to it🤷♂️
if there is like
3 reactions on a message like 🔗⛩️💢
and i want my bot to detect the third reaction that is 💢 and wants it to react on any of the three when it detects 💢, how do it do that
that's exactly how it works, knowledge of python, examples which they have, and docs which they have
Yes, but then I need to take the time to read the docs, thats what I mean by learn disnake
what do you do then
disnake is easier than hikari tho
programming is all about staring the docs thats it
I use hikari and am comfortable with it to a point where I don't need to check the docs regularly
Same is with me but in disnake (dpy fork)
I'm trying out disnake right now, its messing with me lol
!d discord.on_reaction_add
discord.on_reaction_add(reaction, user)```
Called when a message has a reaction added to it. Similar to [`on_message_edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_message_edit "discord.on_message_edit"), if the message is not found in the internal message cache, then this event will not be called. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") instead.
Note
To get the [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") being reacted, access it via [`Reaction.message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Reaction.message "discord.Reaction.message").
This requires [`Intents.reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.reactions "discord.Intents.reactions") to be enabled.
Note
This doesn’t require [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") within a guild context, but due to Discord not providing updated user information in a direct message it’s required for direct messages to receive this event. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") if you need this and do not otherwise want to enable the members intent.
Tnx
You learn something everyday from docs i dont find it boring tbh i find it cool and intriguing🤷♂️
Yw
🙂
I do too, I just don't have much time these days, so I prefer to work with what I understand. At least until I have time to learn again
the new stuff is not alot, it took me like 30 minutes to get to know the new stuff
No need to rush anything do everything at your speed 🤷♂️
slash in hikari-lb
Its just the small stuff thats messing with me. Like how I'll habitually write a load function instead of a setup function for cogs
thats crap
slash in disnake
its better than that
🤷♂️
easy to use
the docs strings are used for the actual description and param description
its 12hour format the third are seconds
the @commands.SlashCommand implementation?
it helps during my exams
Oh thats cool ig
yea i hope thommo finishes with the update soon , so i dont need to rewrite the bot again from v1 to v2
Wdym by extensions?
!pypi discord.py or if you want to stay updated use forks like disnake
!pypi disnake
I like v1 tbh. Although v2 will 100% be worth the upgrade, especially because it handles slash commands and prefix commands in the same way in v2
how to prefent bot disconnected from user that not with the bot when in vc?
anyone ever have this happen with an embed after editing it?
what happened
yeah i liked the Plugin implementation in v1 more
i just edited the message by replacing the embed lol
it was like commands.Cog
you edit to replace the embed
if you are sending the image as discord.File , you cannot edit it
you could use links
And should I be using Visual Studio Code or PyCharm?
your choice
idk how to encode the image to use a data string lol
ill suggest vsc
pycharm eats ram so choose a less ram heavy one if your desktop is potato
Yep. That said, I'm still excited. No need to resolve objects anymore, they do it automatically
vs code all the way
Vsc is more beginner friendly
Ok
And as said its not that heavy on laptops
How do I install the disnake and discord.py and pip that you all recommended
pycharm has more built-in features
I found Pycharm needlessly power hungry
but it's really heavy
Do I go to extensions on VSC and search disnake and pip and discord py?
Pip gets downloaded with python if you checked it which is automatic
cmd
You should learn Python before making a bot though
and kinda looks ugly to me, i tried a few themes but it was still ugly imo
Since you don't know how to install libraries, it means you never got into Python yet
Debatable
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
Ok well I am taking a python class right now, we just do it on a website
I know a decent amount of python, just not with downloaded extensions
Replit?
codehs
discord bots are hard to write before understanding oop at minimum
Never heard of it
So how do i install these? Do i go to the extensions in VSC?
you use the python package managers for third party python modules, like anaconda, pypi
VS code extensions are specific for VS code
@slate swan Discord bots are hard but if you want to jump to them go for it no harm in that
I do but I don't know how to download these things that you are telling me to.
You don't need VSC to install libraries
Only ext you need is the python one
if you want to easily build a discord bot without suffering, you have to take class for python classes :p
the discord.py one?
There is an installation tutorial
No a ext for vsc to understand py
As simple as that
You can follow installation instructions here if you want disnake
people call it bad but it really isn't those dumbfucks dont know shit how good disnake is, skids
Damn, aggressive
so if someone calls it bad, block em
Never said it was bad, just said I like hikari 🤷♂️
that wasnt for you tho
So passive aggressive
Your correct tho
Who's calling it bad lol
there are a lot of them
Probably a whole comunity server
Disnake seems like a good library. I already like it more than pycord
Because pycord bugged out on me
oh yeah that shit is famous cuz of a kid on YouTube
Same syntax as dpy so yeah
ty
I was reading in a thread that pycord commits without proper testing. Not sure how true that is, but its definitely put me off of it
disnake did that once
it's unusable in 2.2.0
yeah it's one of the best forks currently
Same syntax and pretty advance
Kinda basic too
I'll slowly write a bot in it
I really don't understand how to install this. I put it in the code and ran it.
Not sure what I'd make a new bot for, but its fun so 
In the cmd?
What do you mean by "this"
I just put it in the area I am supposed to put the code in.
Installing discord.py
What do you mean area?
@slate swan Go to cmd and type:
pip install discord
And for disnake its just:
pip install disnake
What is cmd?
This
To find it just press alt+r and type cmd
is it the same thing for mac?
And your gonna be in it
Oh you arent on windows
no
Check the mac terminal i dont know how cuz i use windows
just normal mac terminal?
Probably, but I also don't use mac lol
I think idk not a mac user
I can't find game development channel lol
thx
Yw
Same for Mac
Just use the Terminal
Same commands and everything
well
Good to know
I'd switch to mac if I wasn't a broke bitch lol
does anyone know autocode?
Dont see why
Ahh, for me its music production lol, completely unrelated to programming
Thats cool
python3 -m pip install discord should work
Works too
when i do this it should download pip right?
pip is built in
if its not available then there are tools to download it
startswith with "easy" or smth
Mine says
"-bash: pip: command not found"
pip install disnake
Have you downloaded py?
on unix systems it should be pip3
Its weird that you'd have python installed without pip 🤔
I have visual studio code downloaded
if it doesn't work, python3 -m ensurepip will install pip
Has happened to me just repair and i think it will install itself
Maybe pip isnt in environment var
I did that and still didnt work
Its saying i am on version 21.2.3 of pip and that i can go to 21.3.1
what did you do
and then when I do that, it doesnt show up
Yes
which command
Do pip install --upgrade pip
after doing the discord py one
command?
python3 -m pip install -U discord.py
nice
His pip version is out of date
it will work fine
but they could do python3 -m pip install -U pip
@slate swan its not in the path
try pip3
#bot-commands
Pip is probably not in environment vars
did that
did it show anything long
Yeah
what was the output
A bunch of commands
I dunno, I've had trouble installing libraries on older pip versions before
did this now upgraded to pip 21.3.1
Same
Try installing discord.py now, it'll probably work
ok after i upgraded to pip 21.3.1 i downloaded disnake and it worked
using this? python3 -m pip install -U discord.py
Do you have vsc? Yet
that should work
Yes I have vsc
Download the python ext
Already have it
Great
Ive had vsc for like 5 months
Nice
Its a wrong token
Whats the full traceback?
it says requirement already satisfied
You already have it then
Ok so I have downloaded discord py and disnake and pip. Do i need anything else for bots?
Nope
You need to create an application in the discord developer portal and make it a bot
So now I can exit the terminal and create a bot on vsc?
Bro thats d.js
yeah ik abt that
Then yep, you can make a bot now!
As it said its a invalid token
Great. Thank you for the help.
it appears your token isn't making the typeof string. make sure you are storing it inside quotes
also: https://discord.gg/djs
@slate swan to learn how to make a discord bot https://vcokltfre.dev/
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.
Btw if your using disnake just change discord to disnake and youll be good
Yw
This is fine, im just sending that incase you didn't know it existed.
try logging token to the console.
I could've used this two years ago 😭
Rip
read the error
Fax tho🤷♂️
Trying to do "import discord" on line one and it says I have no module named discord.
you didn't properly retrieve the environment variables then
what lib r u using
well now that's gonna eat some brain to explain
Import disnake werent you using disnake?
as you have installed disnake, try it with disnake
Oh ok
import disnake
"big brain"
but they installed discord.py too
Nope
bruh 💀
alright you have two python installations
i heard macs have python2 installed by default

mine didn't :/
Vps's do though
I did import disnake but it isnt working
in the vscode terminal, execute python3 filename.py
where filename is your file's name where you imported the module
I only imported it into the terminal
although i dont know why you as a beginner are starting with discord.py
the owner straight up claims, this is not beginner friendly.
and you will suffer alot
it has many advanced topics of python
you will need time to understand
you have to begin with small projects like calculator, tictactoe
Ok but I will need to get this to work eventually, right?
I have done those projects
I am taking a python class in school and we have done those
We just do it on a website called codehs
what about decorators, python classes, OOP
no
Just let im be dont kill his vibe
Like I just want to get this working. I may not start coding bots now but I just want it to work so later I can
I do stand for what you said but just let him be
well i have been through that as a kid, i learnt nothing and it was a waste of 3 months
Yeah but that was you
We all dont make the same mistake
Just dm me ill help you out
Ehhh, my first dpy bot I knew nothing about OOP and decorators
It makes it a lot easier, but you learn from your mistakes
We all learned from somewhere
University lmao
okay pretty sure thats what going to happen but okay so the problem is that you have two python installations and the one where the modules are not installed has been selected by default
||no||
this will help with it.
surprisingly many of us are self taught 😄
@slate swan ^
Pretty crazy
I mean, no, but also yes
Lmao
Having problems thrown at you that you wouldn't necessarily tackle otherwise speeds up your learning so fast
So how do I get to the other python that has the thingss i installed
i sent a link? @slate swan
Better in my part i work and learn at my own pace unlike in school which you get topics shoved in your throat
I wouldn't be decent at recursion if it didn't get shoved down my throat
Best alternative of discord.py??
you can reinstall it under python three just make sure you are in your root directory not your project directory. Or you can use pip to install pipenv and use pipenv with a pipfile that keeps all your dependencies in your projects virtual ENV
Disnake
Do you want a discord.py fork or a completely different library
And i think you ment fork
Lmao
Recursion was a nightmare topic, until it wasn't
I think I did my commands under python3. I think I did python3 pip install whatever
Everything in python is a nightmare until you understand it
As i said disnake
Disnake for sure
you asked
okay, just make sure you are out of your project directory to make sure run:
cd
then:
python3 -m pip install discord.py
Why is it best??
Same syntax basic and advanced
got all the new features
in terminal?
Slash commands
yes in your VSCode terminal
Top 3
"best" is a personal preference. try it and see if its "best"
advanced?
Slash commands??
Not in that way you might think but features like slash commands
yes those have been implemented
My favourite library is Hikari. Other people love Disnake. Its a preference thing
^
Hello again. I wanted to add something where, when my bot bans someone, it sends a message saying they were banned, this is the code I used
await message.channel.send(message.author , 'has been softbanned')
However I got an error saying TypeError: send() takes from 1 to 2 positional arguments but 3 were given how do I fix this?
you will need to trash the terminal after and open a new one to get back into your projects directory. You could just CD back into it but this way is easier 😂
message.author is wrong
Myxi#1818 | 19/11/21, 11:53:20 AM
yes those have been implemented
@wise tinsel
use f-strings
My VSCode terminal just has nothing happen
format it with python formatting methods. one of them being f strings
f"{message.author} ..."
% is best way to format
I got it
thank you
😏
How come?
It says requirements already satisfied.
two python installations. as i said
it was sarcastic
I know you said that. I looked at the link and I really don't understand how Hello World will be helping me switch to the other python installation.
i do think its good tho. % and .format string method have their uses that fstrings cant do
I've never seen % used, so I was confused
read it all. it was a topic there
Was it Python environments?
yes
it will be showing diffrent installations if you click that
!e
a = "apples"
print("i love %s" % a)
@boreal ravine :white_check_mark: Your eval job has completed with return code 0.
i love apples
first generation of f-strings
That just looks like shorthand for format lol
yes
hey, guys. Help with the error:
@Bot.command()
async def tempban(ctx, member: discord.Member, time=None, reason=None):
if time == "s":
await asyncio.sleep(time*1)
if time == "m":
await asyncio.sleep(time*60)
if time == "h":
await asyncio.sleep(time*60*60)
if time == "d":
await asyncio.sleep(time*60*60*24)
await ctx.send(f"**{member.mention}, был забанен на - {d}**")
embed = discord.Embed(
title = "Вы были временно забаненны",
color = 0x49ff00
)
embed.add_field(
name = "Кто Вас временно забанил:",
value = f"**{ctx.author} ({ctx.author.mention})**",
inline = True
)
embed.add_field(
name = "На сколько Вы были забанены:",
value = f"{time}",
inline = False
)
await member.send(embed=embed)
await member.unban()
emb = discord.Embed(
title = "Вы были разбанены",
color = 0x49ff00
)
emb.add_field(
name = "Время бана:",
value = f"{time}",
inline = True
)
emb.add_field(
name = "Причина:",
value = f"{reason}",
inline = False
)
await member.send(embed=emb)```
error where
share the traceback
its ctx.send
Oh yep
You cant message a random user if you share no guilds with him its how discord works
Yea
Changed it. Thank you. Now it works. Just gotta tweak the code now.
Good luck on your journey!
thats why you read before judging
I did read
anyways good luck
I will probably be back soon because I am not so smart but thank you.
I think you ment human
Pls elaborate
gone
i think even theyre confused about what they want
Maybe
so a command that tells you a user's information, similar to the ?info command in Carl bot?
that can be achieved with different attributes of discord.User and discord.Member
the part that confused me the most was,
when I entered the server
All of it
Yes
It just wasnt in proper order and was misunderstood
A few commas would've helped lol
i think now we are being very lifeless to talk about something so useless
8s there a 24/7 free bot host
I think you ment bored
maybe
Heroku
Not that
Not recommended
Not replit
Thats good too
Why's that?
I'm aware of the limitations, so let's just assume they need it for a small bot.
@bot.command()
async def ping(ctx):
await ctx.send('Pong! {0}'.format(round(bot.latency, 1)))
How do I pass a user ID or user @
So the command will be +ping @torn cape123123123test
I mean yeah it will work but still not great
You didn't give a reason
will you host someone's project you dont know, doesnt even pay 24/7? probably wont. so why would a hosting provider do that? i'd say just buy a cheap vps
.mention?
Heroku isnt made for bots
I will if they're nice and I'm able to
no to pass the command, not member.mentio()
the command will just take +ping
I want it to take +ping then the @ user
I think its like on_member.mention idk please someone correct me
I don't think thats right
Its 2am my brain isnt quite working
Yeah
@bot.command()
async def ping(ctx, user):
await ctx.send('Pong! {0}'.format(round(bot.latency, 1)))```
I think its closer to that
Can you elaborate
typehint to discord.Member
What are you looking for? The command caller?
I'm looking for the user to pass the command as well as an @
So the end-user should input: +ping @ user
Are you looking for a mention in a command i dont understand
typehint user to discord.Member
alr lemme try
or discord.User depends on what you want to do
whats the difference?
discord.User doesn't have a latency attribute, it's only for the bot so remove user and 1
you cant do the actions of banning, add roles and stuff
I understand, thats just sample code
alr ty
As said: user: discord.User
I usually use Member objects so that I can use their display name
Better tbh
in a userinfo command tho, using Union is better. the command will be more powerful
What the heck is Union?
by powerful, I meant that you can show avatar, name and creation date and some other stuff of people you dont know
Member has a guild to it
allows for both types
!e
from typing import Union
def string(text: Union[str, int]):
return text * 5
print(string("h"))
``` i have no experience with typing
@boreal ravine :white_check_mark: Your eval job has completed with return code 0.
hhhhh
Union is used to typehint that it can be of different types, like
def func(key: typing.Union[int, None]): pass
here you're telling that key could either be None or int
Ah so basically saying it can be a str or a int or None
Oh, its just a type hint
nvm, not confusing
Just any type?
Ikr
discord.py tried to convert the parameter to the typehint if available otherwise it will pass the string to the param.
if you use Union (or the | if 3.10) it will try to convert to any of the given types, like
async def command(user: Union[discord.Role, discord.Member])```
here discord.py will first try to convert the argument to Role if successful it will continue but if not it wil convert to the next type given
if both fail it will raise error
Oh, thats interesting
I dunno if I'd write it like that tho, I like knowing exactly what type I'm dealing with at all times
|?
Ikr never knew about it
I probably will never use it, but its cool information
its a new operator of python 3.10, the union operator
same as typing.Union
I thought it was bitwise or
Ah
typing.Union isn't needed anymore then?
if 3.10 yes
user:discord.User
this returns [<User id=477266267175256125 name='Neth' discriminator='6000' bot=False>]
Any way for it to return just the ID
bitwise or is || iirc
id attr
is that just .id?
The user’s unique ID.
alr ty
yes
Gn guys
Hey @hushed siren!
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:
b r u h
i cant send message up to 2k messages
Gn!
gn
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
If the message is 2k characters discord turns it to a txt.file
gn
yes it did
but the bot deleted it
okay anyways here is my problem
so im trying to make an reaction role command and everything works fine but when its time to give me the role it gives me this error:
File "main.py", line 133, in on_raw_reaction_add
await payload.member.add_roles(role)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/member.py", line 777, in add_roles
await req(guild_id, user_id, role.id, reason=reason)
AttributeError: 'NoneType' object has no attribute 'id'
and here is the code:
https://paste.pythondiscord.com/iqakuhuyij.sql
yea its kinda blue and kinda green
you haven't seen hastebin before?
i have
but there is an role?
Hmmmm, tbh idk dpy enough to help
I'd test with checking the object type of role
raise UserNotFound(argument) discord.ext.commands.errors.UserNotFound: User "asdasd" not found.
How am I able to inform the user that they have entered invalid syntax / the wrong user?
is that just error hadnling?
Simple Error Handling for ext.commands - discord.py - error_handler.py
ty
check the type of the role object
okay
Nah its |
and check the name of selected_role so that you know you've done your string formatting right
oh
I need like the bot to give a role if someone says the line -"I am a fool"
If he says that he should be given the fool role which i have made
!d discord.on_message
discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") is created and sent.
This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.messages "discord.Intents.messages") to be enabled.
Warning
Your bot’s own messages and private messages are sent through this event. This can lead cases of ‘recursion’ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
no spoonfeed
bruh
just tell
how do I hide a command from the help command, I used hidden=True , is_hidden=True but it didn't work
!d discord.ext.commands.Bot.help_command
The help command implementation to use. This can be dynamically set at runtime. To remove the help command pass None. For more information on implementing a help command, see Help Commands.
not recommended.
!d discord.ext.commands.command
@discord.ext.commands.command(name=..., cls=..., **attrs)```
A decorator that transforms a function into a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") or if called with [`group()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.group "discord.ext.commands.group"), [`Group`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Group "discord.ext.commands.Group").
By default the `help` attribute is received automatically from the docstring of the function and is cleaned up with the use of `inspect.cleandoc`. If the docstring is `bytes`, then it is decoded into [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") using utf-8 encoding.
All checks added using the [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") & co. decorators are added into the function. There is no way to supply your own checks through this decorator.
if you want to customize your help command, https://discordpy.readthedocs.io/en/master/ext/commands/api.html#ext-commands-help-command
@sullen shoalcan u plz tell the script
I tried it man
so what happened
the command still shows up
show me what you did
@commands.command(aliases=('close',), hidden=True)
@commands.is_owner()
async def stop(self, ctx):
"""Make the bot go offline"""
await ctx.send(embed=nextcord.Embed(description="**Closing bot in 1 sec**", colour=nextcord.Colour.random()))
time.sleep(1)
await self.Intensity.close()
:/
wit , I will check the repo once
is there a way to make python tts bot with your own voice
it's supposed to not show
yeah
this is the wrong channel man
tts discord bot or what
u can't do that ig
yes you can
you can with knowledge of it

thats it
how do you know @sullen shoal
its possible
do you have any code

