#discord-bots
1 messages · Page 614 of 1
Bro.
@commands.command()
async def serverinfo(self, ctx):
roles_string = ', '.join([r.mention for r in reversed(ctx.guild.roles[1:])])
e = discord.Embed(
colour=0x9641EA,
)
e.set_thumbnail(url=ctx.guild.icon_url)
e.add_field(name='Owner', value=ctx.guild.owner)
e.add_field(name='Channel Categories', value=f"{len(ctx.guild.categories)}")
e.add_field(name='Text Channels', value=f"{len(ctx.guild.text_channels)}")
e.add_field(name='Voice Channels', value=f"{len(ctx.guild.voice_channels)}")
e.add_field(name='Members', value=ctx.guild.member_count)
e.add_field(name='Roles', value=f"{len(ctx.guild.roles)}")
e.add_field(name='Role List', value=roles_string)
e.set_footer(text=f'ID: {ctx.guild.id} | Server Created • {ctx.guild.created_at.__format__("%x")}')
e.set_author(name=ctx.guild.name, icon_url=ctx.guild.icon_url)
await ctx.send(embed=e)
ctx.guild.owner comes back as this in other guilds that aren't mine, but in my own server it comes back correctly: https://e-girls.club/
here's an example what i think it will be
Just ran a class and my vsc died
no thats a separate feature
Saw that on reddit
Oh i thought about something else
Looks cool
They're doing a townhall on it and some other stuff later monday afternoon
Have you seen the outside or have you been inside all month😭
Everything you need is on the interwebs 😂
fuck the outside, i went outside today and my train got delayed by 3 hours
oof
Who needs a train just float 
I think you're confusing trains with boats
No just fly to your destination 
thats a plane
Trains are overrated
anyone?
how do i make a command that edits already sent embeds that was sent from my bot?
you just sent one picture


how many guilds have you checked in
!d discord.Guild.owner
property owner: Optional[discord.member.Member]```
The member that owns the guild.
A few
But, how can I fix it that it'll always display the guild owner
you have to fetch the message, discord.abc.Messageable.fetch_message, but because you want to fetch your bot's message, i would say to go with,
discord.Member.fetch_message
you may use discord.Guild.me to get your bot's Member object
try getting the Member with the id from discord.Guild.owner_id
h = re.findall(r'\d+', "[]()/19373")
print(h)``` why this doesnt print 19373?
nah there are better ways to code,
https://vscode.dev, https://github.dev
you can use them to code and google colab to test your stuff
if you use github.dev, all you gotta do is, go to your repo, and replace .com with .dev
instead of google colab you could download some tools to clone your repo and use pydroid (android) to run your script as well
it supports gui stuff like matplotlib, kivy too
or press the . key
dont think that works on chromebook tho not sure
ah
I see
Linux is a feature that lets you develop software using your Chromebook. You can install Linux command line tools, code editors, and IDEs (integrated development environments) on your Chromebook. Thes
Yes
any idea how this can be useful for discord bots? ive invited a few of my friends as testers and a couple of them have accepted as well
It probably isn't tbh
hmm
its less bloaty tho like if i right click winrar used to take like 30% percent of the height, 7zip just shows one option
Me whos to young and doesnt know about winrar: 
Searched it ik what it is but never used it or knew about it
its for archive files
Yeah ik
It's for game developers who are adding stuff like RPC to their application.
I searched it up
alright thx
.
imagine paying for it while you can get 7 zip for free lol
very old
older than freecodecamp i think
Even older bruh
Bro what do you have against him😭


What is even freecodecamp 
watch his tutorials
Youve seen them all havent you
nope, just some clips but that was enough to know how trash all others are
oops
He lives rent free in your mind
waste of space
😭
Top things myxi hates the most:
1.freecode camp
2.lucas simps
3.freecode camp simps
4.scriptkiddies
5.bad tutorials
6.me😔
7.confusing code
8.people who dont understand anything
9.thats all

6 is False and i hate one more kind of people, who like to call themselves "discord bot developers" not "software developer"
😏
Makes sense
Things i love:
1.disnake
2.you
3.python
4.vsc
5.capybaras

Dont ask ok
not trying to be rude but my friends were talking about capybaras one day they said they eat their own poop
Not trying to be rude but their wrong
Why
Capybaras are intelligent creatures 
Trust me
Since the only thing I code is discord bots, if that doesn't make me a discord bot dev then what does that make me 🤨
i mean i would prefer to be that person who makes those api wrappers instead of using them
A nobody😔
a outcast
So nothing new 😔
😂
😭
Ig but I don't really have a reason to tbh
Sorry i watched a capybara cry😔
Hit deep
What's a capybara
goes on youtube and searches capybara crying

😔
man...

this isnt appropriate to share here
Its capybaras chill
Just a cute animal
:kek:
no
not that something way different
I love dming people photos of capybaras
I should do a capy.bot🤔
Its probably gonna be a multimillion dollar idea and its gonna be bigger than mee6 bot
and you leaked it
Dont copy it please😭


looks like we have solved everyone's discord.py problems
Sad😔
@sullen shoal Now how may i help your mental health and why do you hate free code camp so much🤔
i believe a tutorial should not teach something as if its a unique thing that no one can do, his tutorial felt like he was teaching the syntax of discord.py
what he was actually teaching is cheat sheet of python classes
Very accurate mr.myxi
like they would tell them "put your token here", not "run is a method of Bot, it has a parameter called token we will put our user bot token here as a positional argument", now some people might have different opinions on it but idrc
Yeah i know what you mean
@sullen shoal how do you get a user from a list of reactions like bro i checked docs and i was mad confused
You'd only want to do that if you have hella free time, with my own discord api wrapper in the making I'm totally zoomed out of my free time
😔
Dang😭
at least its something to be truly proud of
Gosh its that easy😭
That is sorta true, but it's a pain in the ass with all the new things coming from discord
Gotta do so much parsing and handling and everything is so interconnected
You got it tho i believe in you

The wrapper itself is basically depending on a very thin string that being the dispatching system
😔
Well without it I'm very sure you'd have no state, no interconnection and no real time events
Gosh this is hurting my brain
That being unless you want a REST only client
Technically my wrapper does have a REST only but that's internal ig
Is it just me thats confused

U need triple quotes
Since it's a multiline string
That can also be an issue 🤷♂️
i dont think it is
looks like a single line
because python would only show the content on line 478
Well, the code is not the same as the error. So share the right code.
In the error there is a color value to the embed, which isn't in the code you've shared.
Oh hmm
In my opinion he should create a new line for each sentence looks cleaner
#DELETE USER
@commands.command()
async def delete_user(self, ctx):
with open("users.json", "r") as f:
data = json.load(f)
await ctx.send("Are you sure you want to delete your account?")
await asyncio.sleep(1)
confirm = await ctx.send("You have 5 seconds to hit :white_check_mark:")
await confirm.add_reaction(':white_check_mark:')
def check(reaction, user):
return user == confirm.author and user != ctx.bot.user and str(reaction.emoji) == ':white_check_mark:'
try:
reaction, user = await ctx.bot.wait_for('reaction_add', timeout=5.0, check=check)
data.pop([str(ctx.author.id)])
await ctx.reply("Account deleted!")
except asyncio.TimeoutError:
await ctx.send("Delete failed.")
with open("users.json", "w") as f:
json.dump(data, f, indent=4)
I'm having trouble removing users and their data from my json file
specifically the data.pop([str(ctx.author.id)]) part
i know it's wrong, but idk what to put to remove a user
an easier and better from every angle solution to it would be to not use json as a database and use an actual database
it's for a simple text based game though
doesn't matter
working with json is hard in python thats for JS people
.
so ill learn that tomorrow i guess
there are many sources to learn to use a database
Json is more a data exchanging format than a db
what does a database accomplish?
Wdym by "accomplish"
it serves one purpose ✨ storing information ✨
like i just wanna store users level, inventories, money etc in a file
Securely and efficiently*
and then be able to update thosethings
yes
that is a very good use of databases
"data" "base"
Learn sqlite 3 its kinds basic
:/ how different is it from json
i kinda wrote a bunch of my code around json today
Cant compare json to a db
so i’m gonna have to rewrite my code, huh..
🤷♂️
@abstract kindle reason:
#discord-bots message
wait so how do i create one
but its not async so wont recommend it for discord bots
and start using it to store this stuff for my game
Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for.
okay nvm
obv you guys are advanced
im new to python and discord bots, and all im trying to do is write some simply data to a file
just was wondering how to remove something from the json file but if u don’t know then that’s okie
Curious whats the name
!d sqlite
No documentation found for the requested symbol.
sqlite3
!d sqlite3
Source code: Lib/sqlite3/
SQLite is a C library that provides a lightweight disk-based database that doesn’t require a separate server process and allows accessing the database using a nonstandard variant of the SQL query language. Some applications can use SQLite for internal data storage. It’s also possible to prototype an application using SQLite and then port the code to a larger database such as PostgreSQL or Oracle.
The sqlite3 module was written by Gerhard Häring. It provides a SQL interface compliant with the DB-API 2.0 specification described by PEP 249, and requires SQLite 3.7.15 or newer.
You have to load the entire json into a Python object, edit it the object, then write it back to the file.
There (:
Wait is sqlite3 really from python?
Oh hi there dementati
No, it's just a module for communicating with SQLite3 DBs
yeah, i’m doing that
Makes sense
my code is above
i’m just having a hard time removing what i’ve added to the json file
what does that mean. I’ve got asyncs everywhere
and loaded
that’s okay
Havent learned sqlite 3 cuz i haven't used it so whats the purpose if im going to forget it
What's not working?
At first glance the code appears fine, So I'd im... actually nevermind
You can open your own help channel, see #❓|how-to-get-help
data.pop([str(ctx.author.id)]) you've got str(ctx.author.id) inside a list
i did
And the list is never going to be a key
I have help-pancakes open 🙂
Lots of mods here great to see
So I'd imagine you just meant data.pop(str(ctx.author.id))
Cool, see you there
Iirc, this is the most active topical channel 😂
Thats cool ngl
Ye
!d dict.pop
???
just checking
Okay
Gn guys
gn
does the database helps bot to save things which is to be done in future if bot goes offline like,
if i keep a reminder in bot and it goes offline , is there a way when bot comesback online it can send the reminder?
yes databases are very useful for that kind of stuff
thanks for being smart and considering to use an actual database
wha-
unless you're talking about json as the database
oh idk anything abt database
.
can u say with wat i can start with or something like that
how do i get the id of an emoji
The emoji’s ID.
thanks
!d discord.Emoji || you just need an instance
class discord.Emoji```
Represents a custom emoji.
Depending on the way this object was created, some of the attributes can have a value of `None`...
!d discord.Client.get_emoji
get_emoji(id, /)```
Returns an emoji with the given ID.
offline or online
Anyone know a good uptime bot
!d discord.utils.get
discord.utils.get(iterable, **attrs)```
A helper that returns the first element in the iterable that meets all the traits passed in `attrs`. This is an alternative for [`find()`](https://discordpy.readthedocs.io/en/master/api.html#discord.utils.find "discord.utils.find").
When multiple attributes are specified, they are checked using logical AND, not logical OR. Meaning they have to meet every attribute passed in and not one of them.
To have a nested attribute search (i.e. search by `x.y`) then pass in `x__y` as the keyword argument.
If nothing is found that matches the attributes passed, then `None` is returned.
Examples
Basic usage...
project
uptime of?
can anyone help me do coding in python for discord bot . Im begginer
means?
search uptime robot on google
Uptime for repl project
you get these features only when you dontbuy premium
There another website I can’t think of name
i would say, because you have never used a database before, start a basic offline project and use the builtin sqlite3 module of python3
later when you get grasp, you may find an asynchronous alternative of sqlite3 or use some other database by searching it online
dont use sqlite3 for discord.py, its not async, there are asynchronous versions of it you can find by searching
Mongodb is async right
Yeah when you said that i immediately thought of that
https://github.com/mongodb/motor
not sure how all this works never used mongodb before
looks like its kind of extension for pymongo to make it asynchronous too
anyone here
no.
no.
oh i will search in yt
Same
i heard mongodb isnt good for discord bots tho
Weird people say its good
because it isn’t an asynchronous library. However, you can run it in an asynchronous loop.
Motor is async
- asyncmongo is a fuckhead
Then ig I'm weird
the reason i heard was that discord's data is strongly relational but mongodb isnt
No i ment it like: weird, people say its good
Oh
Yeah lmfao
And that's why you use commas 😔
Fuck commas
It doesn't make it any harder to use it lol
Space gang for life
idk deta works for me till now
yeah ik that's why i closed my discord bot project
Then whats a good async db?
I did and im falling asleep i just cant fall asleep with questions on my mind idk if its adhd idek
uh postgresql?
I mean
You can choose any database
Most of them have an asynchronous library for it
So doesn't really matter, choose the one you like
yeah
curiosity
is bad.
why you always appear at random moments
for the same reason as everyone else.
sometimes i help, but normally people just say stupid stuff
import discord
from discord.ext import commands
import datetime
class Unban(commands.Cog):
def __init__(self, client):
self.client = client
@commands.command()
@commands.has_permissions(ban_members = True)
async def unban(self, ctx, *, member):
banned_users = await ctx.guild.bans()
name, discrimator = member.split('#')
for ban in banned_users:
user = ban.user
if(user.name, user.discrimator) == (name, discrimator):
await ctx.guild.unban(user)
embed = discord.Embed(
title = f'{user.name} has been unbanned',
colour = discord.Colour.red()
)
embed.add_field(name = 'Unbanned at', value = ctx.author.mention)
embed.timestamp = datetime.datetime.utcnow()
embed.set_footer(text=ctx.author.name, icon_url=ctx.author.avatar_url)
await ctx.send(embed = embed)
def setup(client):
client.add_cog(Unban(client))
what mistake have i done?
it dosent unban
why not just code it yourself
github.com added a search field years ago

looks like youre following a bad tutorial
why not use MemberConverter
fr
C++
member = discord.Object(id=0) # user ID
try:
await guild.unban(member)
except discord.NotFound:
# member not banned / doesnt exist
ok
you say the most random stuff ever
use .id instead of comparing a member object
also dont follow tutorials
I am for that kinda stuff
and dont use .split('#') its not a good idea
ok
let dpy convert it for you, so i can do !ban 714731543309844561 or !ban invalid-user#1119 or !ban @heavy folio
for your command, what you have to do is !ban invalid-user#1119 and thats the only way, which is not recommended
@heavy folio ayo do u know a discord.py tutorial
on yt cuz i am on phone rn
There are no good YouTube tutorials
Tutorials are fundamentally flawed in concept when it comes to teaching you something like a programming language. The simple reason for this is a programming language is how you create whatever you want, a tutorial is something that teaches you how to do what the tutorial is teaching.
I recommend reading through all of these points if you want to understand why
A couple of points against tutorials...especially video tutorials:
-
Tutorials teach you how to create a project, a specific program, a specific script, etc. This causes many many people to only know how to do this one specific thing.
-
A programming language is an entire language itself, this is obvious in of itself but for this point think of this compared to a real language...people have accents, there's multiple ways to say the same thing, there's multiple pronunciations for some words. This same kind of concept applies to programming languages, there are many ways to achieve the same thing, there are code styles which people pick up from learning. Sometimes...these practices can be bad and if you're just learning, how would you know if the tutorial is using some bad practice? Trust me...this happens a lot
-
Tutorials are made for that specific version of whatever it's using...whether this be python, the discord.py library, some other library it's using...etc. As time goes on that can very quickly become outdated
-
Sometimes there are "advanced" or hard concepts that are covered in a tutorial, you're not guaranteed to understand all of it right off the bat. It is extremely hard to provide the relevant documentation for every single concept covered....there would be so much.
-
Specifically for this library, the people who look for tutorials are typically new to the language...this library is not meant for beginners, there are some advanced concepts (EG asyncio) that are covered, and jumping straight into that as a beginner is very bad.
~ R. Danny
imma read full
!e
print ("hello world")
@slow silo :white_check_mark: Your eval job has completed with return code 0.
hello world
Pls rich
Wrong server bud
In #bot-commands only
@green folio :white_check_mark: Your eval job has completed with return code 0.
6
#bot-commands
!e
a = 728282892929
b = 82829102018299
print(a+b)
@slate swan :white_check_mark: Your eval job has completed with return code 0.
83557384911228
!e
a = 7282828929297277283889
b = 8282910201829983829299
print(a+b)
@slate swan :white_check_mark: Your eval job has completed with return code 0.
15565739131127261113188
TypeError: edit() missing 1 required positional argument: 'self'```
???
VSC>REPLIT The Tables have turned
Bro, u need an instance of discord.Message, not the class itself
ahahhahaha
its inside a callback so idk how i can get the instance but i'll try to do something
Do u have access to inter?
The interaction*
U can just do inter.message or something
dm if u can make a bt for me
bt?
It’s just await message.edit
Never mind, I didn’t scroll down first
i got it working now thx for the help tho
Cool!
bot bruh
do yall use vscode themes? @maiden fable and what else do ya code on
how can i list all members of the server that have a specific role?
If you have the discord.Role object then you can use the .members attribute
!d discord.Role.members
property members: List[Member]```
Returns all the members with this role.
How you get the discord.Role object depends on the context of what you're doing
Hi guys i need help with an idea, I'm thinking of practising learning python again by making a discord bot that throws whatever upcoming events straight down to a dedicated channel in the server, how do i go about that please?
ok
hello,
i am trying to blacklist words as well as gifs, but it seems that my code doesn't work with the gifs
@bot.event
async def on_message(message):
if message.author == bot.user:
return
if message.author.bot:
return
with open('words.txt') as f:
if message.content in f.read():
await message.reply("This word is blacklisted")
!code
@client.event
async def on_message(message, user: discord.Member):
if message.startswith('s'):
await user.send('you said s')
it gives me an error message
i am trying to blacklist the gifs which contains the blacklisted words
error message ?
I would recommend to open it at startup instead of opening it again and again on every message.
then save it either as an attribute of the cog subclass or Bot instance
oh thanks 🙂
!e
class foo:
def __init__(self):
pass
bot = foo()
bot.var = 'your content'
print(bot.var)```
@sullen shoal :white_check_mark: Your eval job has completed with return code 0.
your content
could you help me how can I blacklist the gifs with the blacklisted words in their link
!e
words = ("hello\nlol\npenis").splitlines()
test_urls = ('wkwneffwfwlol', 'wefewefwfwfwpenis', 'wkejnfwkfjefwkhello')
for url in test_urls:
for word in words:
if word in url:
print(f"{url} is blacklisted")```
@sullen shoal :white_check_mark: Your eval job has completed with return code 0.
001 | wkwneffwfwlol is blacklisted
002 | wefewefwfwfwpenis is blacklisted
003 | wkejnfwkfjefwkhello is blacklisted
not the shortest way to do it but i have to go now so i wrote i could remember
@sick talon
thanks! I will try it 🙂
it worked thanks
VSC
Yes I use a theme and custom font, but I barely use VSC. I'd rather use an IDE than a source code editor.
guys
I don’t use VSC
@bot.command(name="subscribe")
async def subscribe(ctx : commands.Context):
embed = discord.Embed
embed.title = "Subscribe To Mr StupidCraft!"
embed.url = "https://www.youtube.com/channel/UCjn9hmO7O1fUmNhpvvB5YuQ"
embed.set_author("MR StupidCraft")
embed.color = 0xf1c40f
embed.set_author("Mr Stupid Craft")
embed.set_thumbnail("https://imgur.com/a/hHY5E4p")
embed.set_image("https://imgur.com/a/d1bDVDY")
embed.set_footer("Please Subscribe!")
await ctx.channel.send(embed=embed)
here i am getting an error thats
that
missing argument
show the entire traceback
Ayyy myxi
hello
then how mr winrar
Should it be discord.Embed()?
Ignoring exception in command subscribe:
Traceback (most recent call last):
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line
85, in wrapped
ret = await coro(*args, **kwargs)
File "d:\Mystuff\Discord\Bot\StupidCraft\main.py", line
24, in subscribe
embed.set_author("MR StupidCraft")
TypeError: Embed.set_author() missing 1 required keyword-only argument: 'name'
The above exception was the direct cause of the following
exception:
Traceback (most recent call last):
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line
863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line
94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: Embed.set_author() missing 1 required keyword-only argument: 'name'
There should be something.add_field()
set_author(name="something")
initialize the class
oooh
howim new
Yes
Read the error
Try searching it up before you ask
set_footer(text="something")
Discord should be your last resort
add () to the end of Embed
class discord.Embed(*, colour=Embed.Empty, color=Embed.Empty, title=Embed.Empty, type='rich', url=Embed.Empty, description=Embed.Empty, timestamp=None)```
Represents a Discord embed.
len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.
bool(b) Returns whether the embed has any data set.
New in version 2.0.
Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty").
For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") for you.
For the kwargs for methods
!d discord.Embed.set_author
set_author(*, name, url=Embed.Empty, icon_url=Embed.Empty)```
Sets the author for the embed content.
This function returns the class instance to allow for fluent-style chaining.
all the arguments after * are keyword only arguments
I wonder if there is anyone creative
because when it comes to bot naming I am definitely very creative
do cogs still support discord.ui.buttons
i mean can cogs run discord buttons like @discord.ui.button and stuff
Pretty sure they do
phew, what about view= would it do an unexpected error or a
or an actual result lmfao
@sullen shoal no need of () after discord.embed
hey but how do we use images
those images arent loading
read the docs
You need the png link of your image
you'll have to save it in your file
https://i.krypt0n.co.uk/a80266ed.png This url
using os you can get the file directory or you can just open it normally without os
Not needed...
oh?
Just give a valid URL to the image
ok
hey can someone show me an example of a load and unload command for cogs?
Instead of https://imgur.com/a/hHY5E4p, put https://i.imgur.com/1CDS9hy.jpeg
Instead of https://imgur.com/a/d1bDVDY, put https://i.imgur.com/ZqLyIEt.jpeg
by example do you mean a code you can just copy paste and use yourself or..?
FORGET I EVER SENT THE CODE
no, like see my load command code isn't working lmfao its saying module "cogs" not found even tho i never imported it 💀
👉 👈
You load a string
"cogs.something"
Share the error..?
i did 'cogs.{extension}' 💀
' and " are the same
lemme show the error
await ctx.command.invoke(ctx)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/ext/commands/core.py", line 825, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/ext/commands/core.py", line 134, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ModuleNotFoundError: No module named 'cog```
no module named cogs 💀
learn to code yourself
share the whole traceback?
imagine not making a bot urself its easy af
just find a tutorial
dont use txt btw
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/ext/commands/bot.py", line 960, in invoke
await ctx.command.invoke(ctx)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/ext/commands/core.py", line 825, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/ext/commands/core.py", line 134, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ModuleNotFoundError: No module named 'cogs'```
just watch a tutorial 🤣
Tutorials are fundamentally flawed in concept when it comes to teaching you something like a programming language. The simple reason for this is a programming language is how you create whatever you want, a tutorial is something that teaches you how to do what the tutorial is teaching.
I recommend reading through all of these points if you want to understand why
A couple of points against tutorials...especially video tutorials:
-
Tutorials teach you how to create a project, a specific program, a specific script, etc. This causes many many people to only know how to do this one specific thing.
-
A programming language is an entire language itself, this is obvious in of itself but for this point think of this compared to a real language...people have accents, there's multiple ways to say the same thing, there's multiple pronunciations for some words. This same kind of concept applies to programming languages, there are many ways to achieve the same thing, there are code styles which people pick up from learning. Sometimes...these practices can be bad and if you're just learning, how would you know if the tutorial is using some bad practice? Trust me...this happens a lot
-
Tutorials are made for that specific version of whatever it's using...whether this be python, the discord.py library, some other library it's using...etc. As time goes on that can very quickly become outdated
-
Sometimes there are "advanced" or hard concepts that are covered in a tutorial, you're not guaranteed to understand all of it right off the bat. It is extremely hard to provide the relevant documentation for every single concept covered....there would be so much.
-
Specifically for this library, the people who look for tutorials are typically new to the language...this library is not meant for beginners, there are some advanced concepts (EG asyncio) that are covered, and jumping straight into that as a beginner is very bad.
~ R. Danny
import cogs
i didnt import cogs
exactly
i mean a mdoule like import cogs like that type of importing
thats not what i did :c
a copy pasta?
oke
is cogs a folder/file in your dir
yes
i did ~ R. Danny at the bottom for a reason
ok
oh I did not read the whole thing, my bad 😅
look at this dont see anything wrong
lol
the folder contains the 450 lines of code bot and the langs which contains the cog
nah
i mean like the 450 lines of code is not in spanish.py
why are you crossing out the names?
its cringe
oh
I am so stupid I put a colon where it shouldn't be and I didn't realize it for 5 minutes
send it, without crossing anything out
forgot
i dont see any dir/file named cogs
wait it has to be named cogs?
ofc?
your importing cogs
im really really really really really really stupid
theres nothing named cogs so what does it import then
one is IDE the second one is a text editor
both have different uses
Visual Studio is not made for all languages
vsc
why tho
it supports like a billion languages and if it doesnt you have extensions
None, as you can't compare them
They have a complete different use case
vs and vsc are the same, vs is just more suitable for complicated languages
imo its the same
bro pls stop
It's not.
oh wait
Can ask in #editors-ides about it
....
so i should use visual studio right
ye but not for python
the text editor is enough for python
why tho
I like sublime text editor
been usin it for 1y now with python html css and js
works fine?
woah 💀
this is #discord-bots i am not going to explain the difference between an IDE and text editor here
hey wait did you use https://discord-app-maker.app to make ur pfp
lol
aint gonna use pycharm either
avatar-maker i mean
yeah, lightweight and fancy
nice
sublime and vsc best bruvs
sublime is the chiller version
theres not much going on when you debug
when you debug in vsc you feel like you launched a whole airstrike with concurrent threads and stuff
but when you run a file in vsc its like sublime
Just go in #editors-ides at this point
oh yeah
agreed
You can't.
That's how Discord works
It's called footer for a reason
use author
Lol
BRUuuuuu put header
now what's a header in an embed
btw can i make my bot as such like a chatbot with ai responses i have seen those kind of bots.@slate swan@slate swan@sullen shoal
dont use pycharm for beginners it isnt recommended
I mean there is no reason to use pycharm
help
everything from that 12gb ide you can get in 600mb
@heavy folio
i have double slash command in discord how to remove them
yes
use neuralintents module or some other
idk about that
dpy doesnt have slash commands
hi
ask in your fork's support server, not here
Indeed, PyCharm is in fact between 170 and 600 MB
i am using disnake
My installation of PyCharm is 394mb
then ask there, not here
Why wouldn't they be allowed to ask here?
i thought they dont help with forks here..
if my command is like this
@bot.command()
async def test(ctx, channel: discord.abc.GuildChannel, *, message):
...
how do i make it so that if i dont mention the channel it'll send the message in the current channel like !test hello world
well this channel isnt for specifically discord.py
i asked for help once and people said "ask in your fork's support" lmao
must be some dumb skid
In the past the channel topic said 'discord.py' only
There are no statements about other relevant Python libraries

how to get  from emoji object
anyways send code
idk just do emoji name and id together
its kind of a bug of discord's api, i forgot the workaround, you could ask in the support channel of disnake
you wanna get that from a command's arg or
:incoming_envelope: :ok_hand: applied mute to @wise tinsel until <t:1637581574:f> (9 minutes and 58 seconds) (reason: newlines rule: sent 14 consecutive newlines in 10s).
flood
!tag 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.

<@&831776746206265384> Probably another mistake for the spam filter (code sent) :p
I got an emoji object
!unmute 818428347151024199
:incoming_envelope: :ok_hand: pardoned infraction mute for @wise tinsel.
Thanks, do note that we already get pinged for auto-mutes 😄
You can use the pasting service https://paste.pythondiscord.com/
Oh, my bad, didn't know ^^
^ @wise tinsel
Please delete it
well one way would be to not typehint it, then get the channel, if its None, join the channel argument with message then send it to discord.ext.commands.Context.channel
And regenerate your token
nah discord detects it 
i tried that it didnt work
nvm
it should work? if done correctly
this i s a test bot
how would i make it a channel if it isnt typehinted
its gonna be a string
not channel object
will typing.Optional work?
not really
oh ok
^
other solutions will make the command ugly, i mean while using it
i think discord.Object could be used, let me check the docs
how to get emote object from text
i think the best solution would be to just catch the error
what kind of text
class discord.PartialEmoji```
Represents a “partial” emoji.
This model will be given in two scenarios:
• “Raw” data events such as [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add")
• Custom emoji that the bot cannot see from e.g. [`Message.reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message.reactions "discord.Message.reactions")...
@bot.command(aliases = ["Whois", "WHOIS", "userinfo", "Userinfo","UserInfo", "USERINFO","USERinfo","userINFO","UserINFO"])
@commands.cooldown(1, 4, commands.BucketType.user)
async def whois(ctx,user:discord.Member=None):
if ctx.channel.id != 835236006713098304:
async with ctx.typing():
await asyncio.sleep(0.4)
if user is None:
user = ctx.author
emb2=discord.Embed(color=0x2e2f33).add_field(name="Nickname:", value=f"`{user}`").add_field(name="ID:", value=f"`{user.id}`")
memberavatar = user.avatar_url
emb2.timestamp = datetime.utcnow()
emb2.set_footer(text=f"Запросил: {ctx.author}",icon_url=f"{ctx.author.avatar_url}")
await ctx.message.delete()
await ctx.send(embed=emb2)
await emb2.delete()
await asyncio.sleep(7)
Why my bot not delete self embed?
assign a variable to the send function and then delete that one
being famous be like
works thx
if you dont wanna check it, it's better you leave imo 😌
!d discord.ext.commands.Bot.case_insensitive exists btw
Whether the commands should be case insensitive. Defaults to False. This attribute does not carry over to groups. You must set it to every group if you require group commands to be case insensitive as well.
Chaos on thats why @lament oaron perms given to everyone
Its been 2 mins
They pinged me 200 times tho
how many bots are there allowed in a discord server?
is there a limit?
orstatement can be used to remove some spaghetti,x or y, here ifxisNoneit will set the value toy- why are you triggering the typing mode for just 0.4 seconds? it is not necessary
ctx.messagereturns thediscord.Messagethe user invoked the command with.sendmethod will return theMessageobject your bot sent. so you assign it this way,msg = await ctx.send(...)
@sullen shoal This worked lol
u tryna get 5k members all bots?
:/
ye
ofc not
im just asking if theres a limit
install module first
learn english before python
installed and importd
Hi anyone here decent with voice channel creations
and importd
not a nice way to talk
true but what i said is also true
whats that
overwrites_team1 = {
guild.default_role: discord.PermissionOverwrite(view_channel=False),
guild.get_role(verified_role): discord.PermissionOverwrite(view_channel=True, connect=False),
guild.me: discord.PermissionOverwrite(view_channel=True, connect=True),
guild.get_role(staff_role): discord.PermissionOverwrite(connect=True, speak=True)
}
overwrites_team2 = {
guild.default_role: discord.PermissionOverwrite(view_channel=False),
guild.get_role(verified_role): discord.PermissionOverwrite(view_channel=True, connect=False),
guild.me: discord.PermissionOverwrite(view_channel=True, connect=True),
guild.get_role(staff_role): discord.PermissionOverwrite(connect=True, speak=True)
}
for x in team1:
overwrites_team1[guild.get_member(x)] = discord.PermissionOverwrite(connect=True)
for y in team2:
overwrites_team2[guild.get_member(y)] = discord.PermissionOverwrite(connect=True)
team1_channel = await guild.create_voice_channel(f"Team 1 - {game_id}", overwrites=overwrites_team1,
category='6Mans', user_limit=qsize / 2)
team2_channel = await guild.create_voice_channel(f"Team 2 - {game_id}", overwrites=overwrites_team2,
category='6Mans', user_limit=qsize / 2)
I get this error:
File "D:\6Mans\Heps6Mans\Main\mainwithdict.py", line 277, in randteamchoice
team1_channel = await guild.create_voice_channel(f"Team 1 - {game_id}", overwrites=overwrites_team1,
File "C:\Users\1\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\guild.py", line 987, in create_voice_channel
data = await self._create_channel(name, overwrites, ChannelType.voice, category, reason=reason, **options)
File "C:\Users\1\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\guild.py", line 844, in _create_channel
'id': target.id
AttributeError: 'NoneType' object has no attribute 'id'```
target is none
Yes
I mean you gotta learn atleast decent english, gonna need it for almost everything
not readable, fix the formatting
Use py
i mean you can still understand him right?
no, can you?
@sullen shoal
yes
Looked like he said "Everyone, my discord bot is not running. The error is module not found"
how do you know he didn't mean 'My discord bot is not ruined' for whatever reason
i'm making a snipe command i want it to snipe emojis but i've got no idea tbh , can someone help me , i've made it already and when sniping emojis it just sends :text_emoji_name:
are you talking about the custom ones
?whois 165023948638126080
yeah ones are from outside the same server
!whois 165023948638126080
bots cant access emojis from servers it cant fucking access
i asked in dpy and the said they can in some way or another
like yk how some bots steal emojis
i'm guessing that would have something in common
!d discord.PartialEmoji this maybe, but I havent used partial emoji once at all
class discord.PartialEmoji```
Represents a “partial” emoji.
This model will be given in two scenarios:
• “Raw” data events such as [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add")
• Custom emoji that the bot cannot see from e.g. [`Message.reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message.reactions "discord.Message.reactions")...
false
bots can use emojis from external servers
and can use animated ones too
false
Yes they can
i didnt mean that bruh 💀
Even animated ones
stick up with your false
?
No idea dude , you may use some APIs or something
You can ask hunter he has a chatbot
im stating facts
mind if u help ?
bots cant access emojis from servers the bot isnt in 😐
sure
True
ask away
they just said they can
yeah, i did too
read what i said
For a bot to send an emoji you just need an id
Ok
i'm making a snipe command i want it to snipe emojis but i've got no idea tbh , can someone help me , i've made it already and when sniping emojis it just sends :text_emoji_name:
i fucking said that oml
@jade crater how is this false
you can't sent An emoji normally until it's in bot's cache
can you explain
no, i said false because you were wrong, i did say it can use emojis from other servers
but how can i make my bot do that ?
I meant that it cant use emojis in servers the bot isnt in
Yes it can
You just need the name and id
i said that too 🤦♂️
i also didn't said bots can use emojis from servers that the bot is not a member of
how'd i be able to get that
also you can use any emojis (yes from any discord servers) in buttons or dropdowns

yeah i've thought the same since dank uses some emojis that isnt in the server i was in
<:name:id>
but how'd i be able to get that from a users message ?
how would that work, I thought discord members were equal to bots? they cant use emojis from other servers without nitro (bots can access other emotes from othe servers but im talking about servers it isnt it)
\emoji
dont think thats what he wanted though
its not
yes, i know
That's how you get the elasped name , but bot will send only the emojis from server it is in

I didn't completely replied
elasped name ?
my bad
full id
but i'm not sure how to make that work , since if a user has a message and an emoji , would that still work ?
Is it possible to make different profiles for the bot on different servers? For like when I add my bot to multiple servers, I can explain it a bit more if this was unclear
The <:emojiname:emojiid> is a called the elasped name
oh i get that

dont think bots have access to custom profile pictures yet
i think discord-api was planning on doing that soon, not sure though
its going to be useful for servers if they add, they could customize the bot to their liking
or name it as their own bot
Sorry, that is not what I meant. I meant like all servers have different channels and ID's. How do I make the bot able to work on all servers at same time without any problems.
Now when I'm thinking about it this is probably a stupid question
i think youre asking some stupid question, this library is async, if the code is async too, it will work for all channels and servers at the same time
you may want to use a database (use async ones)
if your bot's commands don't block the event loop then it's ok
Yeah thanks, I think I probably got it even before I asked the question. I was just a bit slow XD
how do we get list of all members of a server?
property members: List[discord.member.Member]```
A list of members that belong to this guild.
i tried it but only bot's name came
!intents
Using intents in discord.py
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.
To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.
Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.
oh
only your bot's name?
yea
then maybe you don't have the member's intent enabled
ok lemme try
just copy pasting the above code will not work btw, you have to enable it in the dev panel
this one?
yes
ok
just turn all of them on
thanks mate it worked
using py if member.premium_since - relativedelta(days=31): boost = ":2MboostBadge:" how can i check if a user has been boosting for over a month? im trying to make my bot return a users proper badge
subtract from the current date 31 days and then check if premium_since is <= than your subtracted datetime object
if member.premium_since <= relativedelta(days=31) <= relativedelta(days=90):```
like this?
wtf
no
how did you even get to that conclusion
tbh, its morning. im not fully present yet
¯_(ツ)_/¯
alright, lemme change up the question
how can i check if someones been boosting using premium_since for over 31 days, but less than 90
!d datetime.datetime.month
Between 1 and 12 inclusive.
premium since returns datetime object iirc
iirc?
if i remember correctly
it does
datetime.now() - relativedelta(days=90) >= premium_since <= datetime.now() - relativedelta(days=30)
ive never really played around with datetime but variables are like, my specialty
8:10am and ive already hurt my brain. this makes sense
Between 1 and the number of days in the given month of the given year.
doesn't return how many days ago
im confused what does terror actually want
they wanna check if the date of premium_since (since when they started boosting) is between 90 days ago and 30 days ago
im using a ton of rmotes
emotes*
im trying to tie how long a users been boosting for to get their proper boost badge
oh then subtracting the current date from that should work if i dont suck at maths
weird, im getting an import error. apparently dateutil isnt a module
spelt wrong
!d dateutil
yeah thats weird, its saying its not imported
pip install dateutils
did that
how should i install it
tils
ive never seen that error
.premium_since.replace(tzinfo=None)
in the middle bit?
does the bot have message perms?
if datetime.now() - relativedelta(days=90) >= member.premium_since.replace(tzinfo=None) <= datetime.now() - relativedelta(days=31): right?
yes
yes
full admin perms
if it didnt, it shd have thrown error
ij see the issue
wait nvm
you have a closing bracket on discord.Embed
yeah idk
try reloading the bot maybe?
ok
in this, if i didnt give a name or id of member(avamember) in that server, it gives error
so i am trying tomake in such a way that if some starting words of a name of some member is given, it should still be able to find the member.
since it gives error , is there anyother way to get wat the argument given was?
i have a class which adds certain buttons to a message in discord, i want the buttons to only be interacted with by the person who issued the command for them, how can i do this?
class ChooseClass(nextcord.ui.View):
def __init__(self):
super().__init__()
self.value = None
# button for knight class
@nextcord.ui.button(label="Knight", style=nextcord.ButtonStyle.green)
async def knight(self, button:nextcord.ui.Button, interaction: nextcord.Interaction):
self.value = "knight"
self.stop()
# button for archer class
@nextcord.ui.button(label="Archer", style=nextcord.ButtonStyle.red)
async def archer(self, button:nextcord.ui.Button, interaction: nextcord.Interaction):
self.value = "archer"
self.stop()
# button for wizard class
@nextcord.ui.button(label="Wizard", style=nextcord.ButtonStyle.blurple)
async def wizard(self, button:nextcord.ui.Button, interaction: nextcord.Interaction):
self.value = "wizard"
self.stop()
above is the code i used in my class
class discord.ui.Button(*, style=<ButtonStyle.secondary: 2>, label=None, disabled=False, custom_id=None, url=None, emoji=None, row=None)```
Represents a UI button.
New in version 2.0.
I have this code however it does not create the channel in a category can someone help me out
channel = await guild.create_text_channel("📃Application",category=discord.utils.get(ctx.guild.categories, name='APPLICATION'),overwrites=overwrites)
hm
the buttons show up and work properly, i just want them to be accessible by only the person who ran the command to see them
i.e. only that person can click them
do you have a context or message for which the button was sent?
@bot.command(name="start")
async def Chooseclass(ctx):
print("Ran command 'start'!")
view = ChooseClass()
embed = nextcord.Embed(title="**Choose a class to begin!**",description="You must choose one of the options to continue playing!")
embed.add_field(name="**Knight**", value="Your weapon will be your trusty old sword, you shall use it to defeat any that dare cross your path!",inline=False)
embed.add_field(name="**Archer**", value="Your weapon will be a bow and arrow, it may come useful for ranged combat!",inline=False)
embed.add_field(name="**Wizard**", value="Your magical powers lie in your wand! use the wisely to defeat your foe!",inline=False)
embed.set_footer(text="Choose wisely! You cannot change your class once you select it!")
embed.set_author(name="Start your adventure!")
await ctx.send(embed=embed, view=view)
await view.wait()
whenever someone runs the start command, the buttons appear along with the embed message @slate swan
pls daily
wrong channel brutha
PATH = "./Hello/Please/Help/Me/helpNeeded.py"
import discord
class MyClient(discord.Client):
async def on_ready(self):
print('Logged in as')
print(self.user.name)
print(self.user.id)
print('------')
async def on_message(self, message):
if message.author.id == self.user.id:
return
if message.content.startswith('!hello'):
await message.reply('hi', mention_author=True)
client = MyClient()
client.run('token')
i want my bot to respond back to this, but it doesnt
so i type and send "!hello"
and the bot responds with "hi"
was the bot online
but it doesnt
yeah
any errors in terminal?
none
can the bot talk
yeah, it has admin perms and the channel is open to public
instead of message.reply, try message.channel.send
i want it to reply
oh wait yeah they are different things..
both will work, idk why it doesnt work though
try having the code outside the class and not inside one
wont work
no event decorator?
y would it need that
to work
wdym
since you are in a cog
no
try adding, @commands.Cog.listener
its in a class, methods dont need decorators
it isnt a cog
its in a class
yes
it will if you change the code up just a little
maybe the problem is that its in a virutal enviorment
it wont work if he moves it outside the class
probably
I mean, I don't see any other mistake 🙂
do you understand that commands.Cog is not the same as discord.Client
yeah?
yes
does subclassing the client help though?
import discord
client = discord.Client
@client.event
async def on_ready():
print('Logged in as')
print(self.user.name)
print(self.user.id)
print('------')
@client.event
async def on_message():
if message.author.id == self.user.id:
return
if message.content.startswith('!hello'):
await message.reply('hi', mention_author=True)
client.run('token')
this should work (if you move outside the class)
dont copy the code btw, the indentation is all messed up
his code looked fine earlier
but it didnt work fine did it
I said code, the "working" part probably is his fault
isnt a client event and a discord.client event two different events?
client.event is a function, discord.Client is a class
.
i told you not to copy it whole
i didnt
well anyways, fix the indentation
i only added @client.event
how do you do the tiny text in embeds?
set_footer
!d discord.Embed.set_footer
set_footer(*, text=Embed.Empty, icon_url=Embed.Empty)```
Sets the footer for the embed content.
This function returns the class instance to allow for fluent-style chaining.
thanks
your @client.event is insde the first async function, which will break the code
write it as its own function outside any other function
like you wrote the on_ready function







