#discord-bots
1 messages · Page 308 of 1
demn
To me I will always be vested in mentoring others within this field, but this server isn't the best place to do so. Long story short, I'm taking a break from this server
@quick brook Namecheap or Hostinger, good choice for VPS?
lmao, she said she is done with this server, it's 1 message above
AWS and Azure are my top go-to's
what a shame
How can i add it so only a user with a specific role can run a specific command?
!d discord.ext.commands.has_role
@discord.ext.commands.has_role(item)```
A [`check()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.check) that is added that checks if the member invoking the command has the role specified via the name or ID specified.
If a string is specified, you must give the exact name of the role, including caps and spelling.
If an integer is specified, you must give the exact snowflake ID of the role.
If the message is invoked in a private message context then the check will return `False`.
This check raises one of two special exceptions, [`MissingRole`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.MissingRole) if the user is missing a role, or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.NoPrivateMessage) if it is used in a private message. Both inherit from [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CheckFailure).
Changed in version 1.1: Raise [`MissingRole`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.MissingRole) or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.NoPrivateMessage) instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CheckFailure)...
it's a decorator, you put that before the command callback
also read the docs
so so
why did it say only the first word?
it didn't wanna speak more
really?
really
it got tired of it
show ur command code
async def say(ctx, message=None):
await ctx.send(message)
this is actual solution ^
ctx, *, message = ""
local spoonfeeder 🥣
i mean i don't have doc links in my pocket 
async def say(ctx, *, message=None):?
yeah
you cant use self outside class methods
Obviously not
Nice pfp ;-;
if you need something from class as button name or else you need to create a custom button for that
Anyway I'll see
Create a custom button uhhhh
or whatever it is if not button
Ohkay
How can I use the webhook.incoming URL generator to send webhooks to my bot directly and then process them?
JSON is mostlikely used to exchange data
use JSON to store translations
You can do a JSON like Down suggested but it will take time to translate everything your bot outputs into those languages
You’re going to write down every word?
Why not just use google translate?
Honestly, I find it pretty unlikely you’ve translated an entire language, and accounted for different contexts/tenses
For English apparently there’s 1m words alone, and English is one of the simpler languages
Then you have past tense, future tense and present
You also have plural and singular
And if it’s a language with different conjugations like French it gets even more complicated
Using Google translate or some other api is way better
What will you do incase of complex languages
Doing it manually is just not feasible
I’d rather have a few poor translations than just completely missing words
Wdym by translate features?
69 and there's my name, perfect screenshot
Rather than number I'm more impressed by the question
:3
so like
(prefix)setlang japanese
then u do prefix(help)
the texts it sends after u do help it gets translated to japanese or smthng?
class YourClass:
# stuff
Yeah that's some discord issue people have been reporting
Nothing you can really do about
dont you see No pinging pls in their name
"That sign can't stop me because I can't read!"
why does it show it isnt found?
cause load_dotenv looks for .env file if you want to use other name you need to pass it to the function like this load_dotenv("super.env")
alr ty
That sign can't stop me because I can't read!
Can anyone tell few discord bot games
is there anygood package and server than is free and i can use to transfer data from computer to it using python
anything that can be made in CLI can be made in a discord bot game
Tic tac toe, rock paper scissors xd
You mean cloud storage?
yes
U can use google drive for that
no
They have an api to interact with it
api docs for google sucks
No offense to them, but they can turn on DND or silence pings from this server
cause its not for python only its for all
you are missing the point of an API
can this also work on some other computer without it asking passwords?
its not a wrapper like discord.py its a raw API
ik
maybe there is a wrapper in python for google apis
You don't need a password i believe it uses a token
if you know it then how can you say google docs suck
they still suck
maybe you just cant read them?
yea cause they suck
properly
It's not the docs that suck it's a understanding issue
Afaik google gives examples in multiple languages including python
anyway is there any other one cause i dont want my google token to be access from the exe i make
You can access nothing from .exe file
It's used to run a compiled file
Try opening a .exe in your notepad or ide
Actually I want make those game in telegram too
I already made that
I was just messing around
Oh
You can try creating an rpg
RPG ?
same thing for telegram aswell i think
great idea
rock paper ground
Actually ya they are very similar
There are many other options like a chess game, match 5
You can use images for those
Error handling a command when someone dosent have a role, Any idea how to do that
Use decorators, handle the error according to docs
There is an exception for that in the docs
It's similar to other errors
@sg.error
async def sg_error(ctx, error):
if isinstance(error, commands.MissingRequiredArgument):
await ctx.send("MXNKEY! You did not provide the game number!")
print(error)
if isinstance(error, commands.MissingRole):
await ctx.sendE("MxNKEY! You do not have enough permissions to run this command!")
print(error)```
this does not work it gives out some other error
Then handle the other error 
cause you dont have else: ?
huh?
what if the error is not one of those two?
Also "sendE" doesn't seem correct
then it will just get through
thats what im confused abt
Then it should print the error-
wait yeah nvm
i dont see a code for that
added that still same error
this SendE is confusing
🤦
You are using sendE instead of send as simple as that
oh shit
No, just replace it with send
Nothing confusing, just wrong function 🧠
nah bro fr i feel embarrased now
What's the concern with having your token in your code? I understand that it's safer to put it in a seperate file like .env but I never knew why, just pushed the I believe button
If you ever need to share the bot's files you won't have to worry about leaking the token
.env files are usually ignored by Git, or you can set it so if you're using Git
A lot of it is because of replit, and other tutorials just copied it. You can also set files to be ignored when pushing to git so your token doesn’t get leaked
Ah I see. Just an extra layer of protection to stop you from doing something dumb
I think replit has environment variables as a side tab thing though
Basically
It’s also easier to hold all your tokens/api keys in one file
What error is this
Command raised an exception: NotFound: 404 Not Found (error code: 10008): Unknown Message
It sends runs the command twice
Any idea why this is happening?
Its for all the commands too
!traceback always send full tracebacks
Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.
A full traceback could look like:
Traceback (most recent call last):
File "my_file.py", line 5, in <module>
add_three("6")
File "my_file.py", line 2, in add_three
a = num + 3
~~~~^~~
TypeError: can only concatenate str (not "int") to str
If the traceback is long, use our pastebin.
no trace back
Then I won't know where the error came from
you just sent a part of it?
see
That's what happens when you're printing the error, not raising
you have any error handler?
Which you shouldn't do
cause you are most likely doing print(error)
1 sec
syndrome
@sg.error
async def sg_error(ctx, error):
if isinstance(error, commands.MissingRequiredArgument):
await ctx.send("MXNKEY! You did not provide the game number!")
if isinstance(error, commands.MissingRole):
await ctx.send("MNKEY! You do not have enough permissions to run this command!")
else:
print(error)```
I am- how do I fix that
Re-raise the error instead of printing it
raise the error not print it
like this? py raise(error)
It's a statement, but that works
Traceback (most recent call last):
File "C:\Users\HP\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\client.py", line 705, in _run_event
await coro(*args, **kwargs)
File "C:\Users\HP\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\bot_base.py", line 629, in on_message
await self.process_commands(message)
File "C:\Users\HP\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\bot_base.py", line 626, in process_commands
await self.invoke(ctx)
File "C:\Users\HP\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\bot_base.py", line 593, in invoke
await ctx.command.dispatch_error(ctx, exc)
File "C:\Users\HP\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\core.py", line 525, in dispatch_error
stop_propagation = await injected(ctx, error)
File "C:\Users\HP\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\core.py", line 157, in wrapped
ret = await coro(*args, **kwargs)
File "c:\Users\HP\OneDrive\Desktop\pass-2\Mxnkek-scrims-bot\main.py", line 122, in sg_error
raise(error)
File "C:\Users\HP\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\bot_base.py", line 589, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\HP\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\core.py", line 914, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\HP\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\core.py", line 182, in wrapped
raise CommandInvokeError(exc) from exc
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: NotFound: 404 Not Found (error code: 10008): Unknown Message```
yeah- big boy
just raise is enough in this case
@naive briar @slate swan the error
do you have the messages content or whatever it was enabled
The traceback isn't any more useful somehow 

I use commands im not old 😂
Its doing this for all the commands
that error?
Also If I did not mention Im using disnake and if this is useful
u dont have the thing enabled i think bro
which thing
intents? i do
in ur code and dev portal?
yes
intents = disnake.Intents.default()
intents.message_content = True
client = commands.Bot(command_prefix="!", intents=intents)```
If this is the right way
yes thats good
Bro everything was going good until now, I do not remember me changing anythingf
is it the print error from before or wut
when i use a command it uses the command twice
so basically all..?
the bot may or may not be running two times
are u running it on two code editors or vps
@cold oyster
1 editor
just did but didnt work
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 Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
@naive briar @slate swan any help?
?
alr
I have no idea, maybe it's disnake's problem
@glad cradle
top ten disnake users
discord.py dont work 😭
you know you can create a global error handler?
Ye thats my second question after i figure this sh out
...
.
@slate swan told me to raise error 😭
you know this works?
idk i dont use raise but i thought we needed to print the error
and yes it gives the same error and works
raise*****
it still raises error
yeah ill speak but i never tried it situation
all the other rest are print tho
else:
raise
???
im only using the sg command for now
what
!e
try:
0 / 0
except:
print("Re-raising")
raise
another one
@naive briar :x: Your 3.11 eval job has completed with return code 1.
001 | Re-raising
002 | Traceback (most recent call last):
003 | File "/home/main.py", line 2, in <module>
004 | 0 / 0
005 | ~~^~~
006 | ZeroDivisionError: division by zero
syndrome
can you stop offending me?
!ot
Please read our off-topic etiquette before participating in conversations.
so does that mean i can be offended or what
I*; and I didn't know it would offend u
Brooooo just help meee
whats the issue again
bruh
two msgs each cmd or was it the big thing
runs 1 command twice
do u use client.run more than once in ur code
no
are u 100% sure no any other enviorments are running
https://paste.pythondiscord.com/RVPQ
See this
ye
did u try restarting it
yes
what was the last thing u added before hand when it was working b4*
This has error too
i changed nothing, when i was making a tutorial for my staff on how to use the bot it started acting up
What error
was this before or after u put raise instead of print
before and after...?
?
The Discord.py documentation tells me how to create an embed thumbnail from a URL, but is there a way to do it from a file on the PC, or in the project folder? IE: photo.png?
file = discord.File("path/to/your/local/image.png", filename="image.png")
tyty
how did u do that
file = discord.File("path/to/my/image.png", filename="image.png")
embed = discord.Embed()
embed.set_image(url="attachment://image.png")
await channel.send(file=file, embed=embed)
okay @cold oyster good luck on your journey thru python!
should i use .json if i want to make a database?
See [How do I use a local image file for an embed image?](https://discordpy.readthedocs.io/en/stable/faq.html#how-do-i-use-a-local-image-file-for-an-embed-image)
no.
why not
cause json is not a database?
if something works doesnt mean its good
tell me why not to use it
The many reasons why you shouldn't use JSON as a database, and instead opt for SQL.
it works but its not that good
god yall have a page for everything lmao
i think a txt file may or may not be better
thats even worse than a json
i think a txt file would be even worse
ah yes, a database in a text file
okay then what do you recommend
I'd make a database in a PowerPoint document
works at the end of the day tho
Sounds better to be fair
use a tool that is designed to store data ❌
use a text file ✅
🤦
^
what do i use then
sqlite3?
mysql, sqlite, mongodb, postgresql, redis
use a csv file 😋
ight thanks
whatever you like and suits you the most
which is the best


Hi guys , I am new to Python and programming .
Any tips on how I can become a better learner/programmer?🫶
it was good to offend me?
offtopic*
i would say learn more
Copy that 🫡
10-4
I would say #python-discussion is better for such things
And you can go on the resources page
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
See This tutorial @lunar fulcrum
This Python tutorial for beginners show how to get started with Python quickly. Learn to code in 1 hour! Watch this tutorial get started!
🔥 Want to master Python? Get my Python mastery course: http://bit.ly/35BLHHP
👍 Subscribe for more Python tutorials like this: https://goo.gl/6PYaGF
📕 Get my FREE Python cheat sheet: http://bit.ly/2Gp80s6
C...
its programming with mosh
People in this channel should know to not listen to that person 
ive seen people recommend it in this server before, many times
Put a thumbnail for my discord bot, but it seems to have this strange little line around it. I know for a fact that line is not there in the regular img file, so is this a normal thing?
your image is low quality
Thumbnail?
embed thumbnail
And yeah, it's actually in the image
Hm
Put a thumbnail for my discord bot

i understand newbie language

My bad, meant for an embed
Yeah I'm pretty new lol
do u guys know how
to wait for a butto to be clicked
because i have to sleep(20) seconds so my interaction isnt f'd up
someone pls give docs or something man
There's an examples folder
and in there, there's a view folder iirc
!d discord.Embed
class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, 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.
x == y Checks if two embeds are equal.
New in version 2.0...
It has a set_thumbnail method
ty! I got it figured out
Yeah won't solve their issue of the image having a white border
When trying to have the bot react to a message, what is the best way to do so? I figure something like:
message.add_reaction(emoji="\:peach:")
or something along those lines, but keep getting the error PartialMessage.add_reaction() got some positional-only arguments passed as keyword arguments: 'emoji'
any help?
!e
def f(x, /):
print(x)
f(123)
f(x=321)
@buoyant quail :x: Your 3.11 eval job has completed with return code 1.
001 | 123
002 | Traceback (most recent call last):
003 | File "/home/main.py", line 5, in <module>
004 | f(x=321)
005 | TypeError: f() got some positional-only arguments passed as keyword arguments: 'x'
!d discord.Message.add_reaction
It accepts only positional args
await add_reaction(emoji, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Adds a reaction to the message.
The emoji may be a unicode emoji or a custom guild [`Emoji`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Emoji).
You must have [`read_message_history`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.read_message_history) to do this. If nobody else has reacted to the message using this emoji, [`add_reactions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.add_reactions) is required.
Changed in version 2.0: `emoji` parameter is now positional-only.
Changed in version 2.0: This function will now raise [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError) instead of `InvalidArgument`.
You can simply paste in the emoji
message.add_reaction("😊")
I made a mistake
Yeah I'm not sure you can add reactions with the :name: syntax
I ended up figuring it out. Thanks!
#https://discordpy.readthedocs.io/en/stable/ext/commands/commands.html#invocation-context
import discord
from discord.ext import commands
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix='$', intents=intents)
client = discord.Client(intents=intents)
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
token = ''
client.run(token)
@client.event
async def on_message(message):
prefix = '#'
if message.author == client.user:
return
if message.content.startswith(f'{prefix}hello'):
await message.channel.send('Fuck you, this is not what I wanted.')
if message.content.startswith(f'{prefix}command'):
await message.channel.send('Shut the fuck up!')
bot wont respond to the messages at all
even though its online
no error messages
client.run(token)
This like is blocking. That means nothing after it will run
You shouldn't be defining 2 bot instances
Using on_message to create commands is also fundamentally flawed
Use the commands extension
You shouldn't be mixing video tutorials, or using them at all
i see
if you make your discord bot generate invites for every server it is in, is it against tos?
not really to do with code but still yk
Kinda?
If they're private servers, and the users didn't agree to this beforehand Discord wouldn't be too happy
its complicated
cause like, i dont think its against tos to see how many servers your bot is in or which
but making invite links might be, what do you think?
okay thanks
Going of of my question from earlier, I'm now trying to make the bot react with a green_square emoji. Except when I copy the emoji directly into the code, it ends up returning an enknown emoji error ):
Can you paste your code?
I ended up figuring it out with a bit of searching. Turns out I was posting the emojis in the wrong kind of format
Is there a channel or location anywhere here to hire a dev to help you make a bot?
No
class ticket_button(discord.ui.View):
def __init__(self):
super().__init__()
self.Value = None
@discord.ui.button(label="🎫 Buy Now.", style=discord.ButtonStyle.gray)
async def open(self, interaction: discord.Interaction, button: discord.ui.button):
Why when I make a Button like this
after some minutes the buttons stop working
View constructor takes a timeout kwarg, which controls how long the view will last before no longer accepting any interactions
but Im not using it
!d discord.ui.View - the default timeout is 180 seconds 🤷
class discord.ui.View(*, timeout=180.0)```
Represents a UI view.
This object must be inherited to create a UI within Discord.
New in version 2.0.
how to disable timeout?
set it to None
File "C:\Users\Hadi\PycharmProjects\resellers-3\main.py", line 1709, in <module>
class ticket_button(discord.ui.View(timeout=None)):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Hadi\PycharmProjects\resellers-3\venv\Lib\site-packages\discord\ui\view.py", line 192, in __init__
self.__stopped: asyncio.Future[bool] = asyncio.get_running_loop().create_future()
^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: no running event loop ```
you do that while initialising it, not there
There's something similar to that 🫠
class AClass(Something, arg=value): ...
class ticket_button(discord.ui.View, timeout=None):
you mean like this?
No, I just realized that discord.py doesn't implement that
So, how do I disable timeout?
Just set it in super().__init__() of the subclass 🤷
strange request: anyone happen to know where I can find a full list of the Discord emojis in their string-form? IE: [":whale", ":airplane"...]
It's on Google somewhere
And considering discord is using twemoji, you can get that list easily
And there's also https://unicode.org/Public/emoji/ in case you can't find twemoji data, which is easy to get
is status only retreivable through a member object?
Yes
I see thanks
tysm broo
@lunar vine @naive briar @slate swan
Yesterdays issue which I don't think yall could figure out which was bot is running every command twice, I did not have 2 consoles running but still it had that behavior. I simply just reset the bot token and updated it in the codeand it worked. Sorry for the pings just wanted to give out the solution
!d status
How would I go about sending webhooks to my Discord bot?
So how do I set a presence of a bot and also how do I make it change over time like after 1 minute it says watching over mxnkey scrims and after that it says listening to commands
?
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="mxnkey scrims!"))
Where activity is, change that to either listening, streaming or gaming (not to sure about that one) and then name is what you want it to say after, so for example, this would say: "Watching mxnkey scrims!
To change, I would just create a while True loop, make it sleep using time and then change it as you see fit.
@cold oyster
Hi
I don't understand the question. Are you asking about sending webhooks? 
I know how to set presence but not change it over time 
Call the function again and again with while-loops or discord.py's task loops
Yes.
!d discord.Webhook.from_url - you can use this function to create a webhook object, then use the send method of the object
classmethod from_url(url, *, session=..., client=..., bot_token=None)```
Creates a partial [`Webhook`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Webhook) from a webhook URL.
Changed in version 2.0: This function will now raise [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError) instead of `InvalidArgument`.
So from this webhook it creates, I can send payloads to it and process it?
You can send a webhook message to Discord, yes
is there anyway for me to get live data about what user is typing in a SlashOption and then change the choises ?
Appreciate it, thank you!
kind of like a search engine
That is called autocomplete
!d discord.app_commands.autocomplete - you can use this decorator to create one (assuming that you're using discord.py)
@discord.app_commands.autocomplete(**parameters)```
Associates the given parameters with the given autocomplete callback.
Autocomplete is only supported on types that have [`str`](https://docs.python.org/3/library/stdtypes.html#str), [`int`](https://docs.python.org/3/library/functions.html#int), or [`float`](https://docs.python.org/3/library/functions.html#float) values.
[`Checks`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.check) are supported, however they must be attached to the autocomplete callback in order to work. Checks attached to the command are ignored when invoking the autocomplete callback.
For more information, see the [`Command.autocomplete()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.Command.autocomplete) documentation.
Warning
The choices returned from this coroutine are suggestions. The user may ignore them and input their own value...
ok but can i get the live data that the user is typing
because lets say the user searchs for other users in a website and i cant add all the users to that
discord.py will call your autocomplete function once the user changed their input
🐈
🐕

or he could use a task which will update it ever x seconds or minutes or hours depending on how long he wants it to be'
If you're talking about asyncio.Task, that involves the while-loops option
If you're talking about discord.ext.tasks.task, I already mentioned that 🫠
oh sorry i didn't see that 😭
Don't worry about it
tasks.loop 🤫
🤭
In a modal class, in the on_submit thing how do I send a message to a custom channel?
@naive briar @slate swan help :)
- get/fetch channel
- send message to it
!d discord.ext.commands.Bot.get_channel
get_channel(id, /)```
Returns a channel or thread with the given ID.
Changed in version 2.0: `id` parameter is now positional-only.
what does this mean
File "c:\Users\HP\OneDrive\Desktop\pass-2\Mxnkek-scrims-bot\main.py", line 7, in <module>
class StaffApplicationModal(ui.modal, title="Mxnkey Scrims Staff Application"):
File "c:\Users\HP\OneDrive\Desktop\pass-2\Mxnkek-scrims-bot\main.py", line 8, in StaffApplicationModal
name = ui.TextInput(label="What is your real name", placeholder="My name is First Name Last Name", )
TypeError: TextInput.__init__() missing 1 required keyword-only argument: 'custom_id'```
class StaffApplicationModal(ui.modal, title="Mxnkey Scrims Staff Application"):
name = ui.TextInput(label="What is your real name", placeholder="My name is First Name Last Name", )```
This is the line which is getting the error
@slate swan
Can't see any error
means that you need to provide custom_id for it
Traceback (most recent call last):
File "d:\Shrey\Projects\S-Bot\code\__main__.py", line 6, in <module>
bot.load_extensions("code/cogs/")
File "C:\Users\welcome\AppData\Local\Programs\Python\Python311\Lib\site-packages\disnake\ext\commands\common_bot_base.py", line 638, in load_extensions
self.load_extension(extension)
File "C:\Users\welcome\AppData\Local\Programs\Python\Python311\Lib\site-packages\disnake\ext\commands\common_bot_base.py", line 519, in load_extension
spec = importlib.util.find_spec(name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib.util>", line 94, in find_spec
ModuleNotFoundError: No module named 'code.cogs'; 'code' is not a package
Sending code.
i guess you want to import something from folder code
bot = commands.InteractionBot(owner_id=1113345631017254973, test_guilds=[1158032926500462613])
bot.load_extensions("code/cogs/")
i did this
But that something doesn't exist
leme send the file tree also
its separated by dots
code.cogs
what
so i dont include the /
i write code.cogs in load_extensions
yes.
doesnt work
But u will need to loop through each file
show the error :D
Traceback (most recent call last):
File "d:\Shrey\Projects\S-Bot\code\__main__.py", line 6, in <module>
bot.load_extensions("code.cogs")
File "C:\Users\welcome\AppData\Local\Programs\Python\Python311\Lib\site-packages\disnake\ext\commands\common_bot_base.py", line 637, in load_extensions
for extension in disnake.utils.search_directory(path):
File "C:\Users\welcome\AppData\Local\Programs\Python\Python311\Lib\site-packages\disnake\utils.py", line 1271,
in search_directory
raise ValueError(f"Provided path '{abspath}' does not exist")
ValueError: Provided path 'D:\Shrey\Projects\S-Bot\code.cogs' does not exist
show file tree
yeah wait
Try using \ for the path
you have to load each cog individually
you dont include code since you are already in that folder
so it will only be cogs
cogs.basic actually
das the problem, i couldn't do that it would just say that cogs doesnt exist
try this
I don't think that will work
i want to load all the cogs in a directory therefore i used bot.load_extensions()
you cant just imagine methods
wtf
something like this does not exist
you need to loop over each file in that directory
are you sure about that
and load it
im using disnake
then i dont know maybe in disnake there is such method
!pip disnake
it exist, i did it many times before
only now its not working
well then show error you get now
On removing code/cogs and doing cogs:
Traceback (most recent call last):
File "d:\Shrey\Projects\S-Bot\code\__main__.py", line 6, in <module>
bot.load_extensions("cogs")
File "C:\Users\welcome\AppData\Local\Programs\Python\Python311\Lib\site-packages\disnake\ext\commands\common_bot_base.py", line 637, in load_extensions
for extension in disnake.utils.search_directory(path):
File "C:\Users\welcome\AppData\Local\Programs\Python\Python311\Lib\site-packages\disnake\utils.py", line 1271,
in search_directory
raise ValueError(f"Provided path '{abspath}' does not exist")
ValueError: Provided path 'D:\Shrey\Projects\S-Bot\cogs' does not exist
Yeah load_extensions is there and it accepts a path
for some reason its in S-Bot directory i think
The path to code cogs folder should be py D:\\Shrey\\Projects\\S-Bot\\code\\cogs\\
yeah leme try that
!d discord.ext.commands.Bot.load_extensions
No documentation found for the requested symbol.
Right
its disnake
I know, I just read the conversation before sending that
Let me send the actual code in that cog.
basic.py file maybe something is wrong with it
import disnake
from disnake.ext import commands
class BasicCmds(commands.Cog):
def __init__(self, bot):
self.bot: commands.InteractionBot = bot
@ commands.slash_command(name="test", description="Checks if the bot is functioning properly.")
async def test(self, inter: disnake.AppCmdInter):
await inter.send("I am working properly! :D")
def setup(bot):
bot.add_cog(BasicCmds(bot))
Did I set it up correctly
Filenames doesn't matter
no its good
hmm
spec = importlib.util.find_spec(name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib.util>", line 94, in find_spec
ModuleNotFoundError: No module named 'code.cogs'; 'code' is not a package
this is smth i am getting in error and i dont understand it
add __init__.py file inside code folder
what do i add in it
nothing
nope, doesnt work
;-;
first time in my life i used git
and now it doesnt work
you know it has nothnig to do with git?
idk
this error is so weird
@slate swan this error doesn't occur if i open the code folder
and then run the file there by removing the extra code/
@turbid condor
Which error?
So the issue?
yes
I still don't get what you are trying to say
Hmm
to access the folder
but if i switch the folder to code
and then edit the folder names from code/cogs to just cogs
the file runs
Tbh as far as i know black slash is used to specify a path instead of a forward slash
i tried it :(
That is because your interpreter is set to the code folder by default where as previously it used to be S-bot
Welp in the docs they told it was a path
HOLY SHITIT
Instead of folder name
bro you scared the hell out of me
i was on full volume with headphones
and i clicked your link 😭
onlyfans thing
XD
im still shaking
@bot.event
async def on_message(message):
print("ss")
why the bot is not making any thing when I send a message?
it is have permissions
What intents do it have?
all
What permissions do it have?
administrator
!paste show your entire 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 Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
import discord
from discord.ext import commands
from math import *
intents = discord.Intents()
bot = commands.Bot("a", intents=intents)
bot.remove_command("help")
tax_channel_id = 1158366596922888252
@bot.event
async def on_ready():
print("online")
@bot.event
async def on_message(message):
print("ss")
bot.run("")```
its just this
It doesn't have all intents, it have none, in fact
lol
I don‘t know if the code that works at the timeout after the timeout even though the button worked before the timeout was pressed. How can I fix this issue?
can u elaborate a bit
How can I host my bot in replit
How do I get the server name of a person who executed the cmd
#965291480992321536 message it's suggested to not use replit
!d discord.User.display_name
property display_name```
Returns the user’s display name.
For regular users this is just their global name or their username, but if they have a guild specific nickname then that is returned instead.
no need anymore
This returns the name of the server not server name of the person
Thanks for showing this
I also used thought that replit was nice and free server but this thing opened my eyes 👀
Btw can u suggest any free server
you can use oracle's free plan if you have a credit/debit card
I don’t have sadly 🥲
Nothing is free
Even if it says it’s free, the money to run it has to come from somewhere
Yeah oracle did that iirc
Dam ☠️ I used trusted oracal but now 📉
Honestly the “free-est” hosting you could get is just grabbing old computer or buying a cheap one off ebay and hosting it yourself
It’s subsidised by their paid options
You don’t get all the perks of a data enter but long-term it’s cheaper if its just a small or personal application
Hm ya , I have an old pc at home I just have to buy a Wi-Fi adapter
Windows is too heavy ☠️
Yeah windows is not for servers, unless windows server edition is somehow better
Never tried it but because windows is in the name i don’t want to
Ya , that’s why I use Xfce in my laptop
Mint
I can't seem to get the embed hyperlink here to work. Always seems to just print the entire thing as a single string. Am I doing something wrong?
embed.add_field("[link](https...)")
iirc markdown formatting does not work in embed fields
It doesn't? I thought that was the only place they DID work
Ooh, does it only work in the embed description?
I believe it only works in the description
Man that's lame
Maybe the title? Not sure on that one
It makes it easier to make embeds sometimes, because you can just put everything in one string
Actually, it could also be because you’re putting the link as the field name?
What’s embed ?
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 Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
^ this is an embed
Who ?
the name and value in add_field are keyword-only I believe, so you're calling the method incorrectly
I now put it into a string for the description. Am I doing this right? It's still not working
You’re missing the {} for your string formatting
!fstring
Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.
>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."
Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.
Hi 👋
You might want to change this name
their pronouns gives it away, but what if someone was actually named hitler
Ok 🫡
Hey if someone is kind enough to dm to fix a python problem regarding my discord bot?
there's a channel made for that, use it and send it here.
Yeah but I don't really like sending that code here, it's not a normal discord bot and was created for different purposes
you'll get help here. so ask
if you don't want to then you won't get help
asking people to dm you out of nowhere is weird
I have problems with my cryptography bot, for my friend it worked but for me it doesn't work for some reason.
The bot won't respond to any command and it doesn't show any error in the "terminal"
import discord
import asyncio
from discord.ext import commands
from cryptography.fernet import Fernet
import json
intents = discord.Intents.default()
intents.members = True
intents.messages = True # Enable the message content intent
TOKEN = 'TOKEN'
key = Fernet.generate_key()
cipher_suite = Fernet(key)
PREFIX = ["?", ">", ".", "-"]
bot = commands.Bot(command_prefix=PREFIX, intents=intents, case_insensitive=True)
bot.remove_command('help')
try:
with open("encrypted.json", "r") as file:
encrypted_data_dict = json.load(file)
except FileNotFoundError:
encrypted_data_dict = {}
@bot.event
async def on_ready():
print(f'Logged in as {bot.user.name}')
@bot.command()
async def e(ctx, *, data_to_encrypt):
encrypted_data = cipher_suite.encrypt(data_to_encrypt.encode()).decode()
encrypted_data_dict[ctx.author.id] = encrypted_data
with open("encrypted.json", "w") as file:
json.dump(encrypted_data_dict, file, indent=4)
await ctx.send(f'``{encrypted_data}``')
@bot.command()
async def d(ctx, *, encrypted_data):
if ctx.author.id == 821755569248403487:
try:
decrypted_data = cipher_suite.decrypt(encrypted_data.encode()).decode()
await ctx.send(f'Decrypted data: ```{decrypted_data}```')
except Exception as e:
await ctx.send(f'Error: {e}')
else:
await ctx.send("You don't have permission to use this command.")
bot.run(TOKEN)
there's a second JSON file as well
it worked for some time but now it doesn't
Message content intent is message_content, not messages
it won't work
Yeah, reading is useful 👍
ah nvm accidentally put "messages" instead of "message"
@slate swan Thanks for the help, the bot got fixed.
Is it possible for a bot to receive image as an input from either a slash command or form ? But not from on message or normal command
Don’t believe so unless they’re passing a link to the image
^Deff gonna need to have them pass a link for the image
Which they can just send the image in chat, then copy the discord link for that image
It would be cool for discord to add that though
I once did something relatable but it was a .zip file as an input
and the bot received it
it was years ago I don't even remember how
something was related to ctx.message.attachments
my old code shows this await ctx.message.attachments[0].save(file_name)
are discord bots difficult to code
Modal no, slash command option yes
Bots themselves are extremely easy to code
Wouldn’t be possible with slash commands
How would it be an option
Why…
and haven't touched a slash command
works just fine as I don't need other stuff
You can just type hint to discord.Attachment
And discord takes that as an input?
isn't it different from attachments
?
because the user can upload multiple attachments
You know 1.7.3 is extremely outdated right
We're talking about slash command options, not message attachments
1.7.3 also uses old APIs
yeah I don't care because it works with me for my personal bots and local stuff
2nd worst take I’ve seen in this channel tbh
d.py will make it so that discord understands it, and so that you can access the attachment
you literally said "Attachment"
Yes. Slash command option where you upload an attachment
Something that's been existing for months if not years
yeah idk how do you see it that way but surely you're seeing it in a wrong way
Will be like that
hi,
i'm having the
Ignoring exception in command watchlist:
Traceback (most recent call last):
File "C:\Users\acatt\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\bot.py", line 1114, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\acatt\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\commands\core.py", line 375, in invoke
await injected(ctx)
File "C:\Users\acatt\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\commands\core.py", line 132, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction
error
does anyone know any fix to it?
You have to respond to an interaction within 3 seconds
i ran a command and does nothing, saying the interaction didn't respond
You have to respond to an interaction within 3 seconds
Okay?
time.sleep isn't the only thing that'll stall your code for more than 3 seconds
what
do i really have to send my code
or rewrite your sentences to be coherent
wtf
?
If you want
!paste
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 Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
ok
idk how to optimize it myself, i made it and it worked
but not sometimes
any idea
What fork are you using?
Also, requests is blocking
not using a fork
how can i fix that
commands.slash_command() doesn't exist in discord.py
Neither does ApplicationContext
And by extension ApplicationContext.respond() doesn't either
So which fork are you using?
but applicationcontext works
Yes, because you're using a fork
py-cord i think
not using a fork
py-cord i think
Use aiohttp
i was unsure
You can also defer the interaction but pycords slash commands implementation fucking sucks so I wouldn't know how
okay
what do u recommend
cuz the base i use uses it
Why would you use a fork
idk, faster maybe
No?
meaning that it was running twice somehow in some form or fashion'
whatever the 2nd place it was running from might still b runnin
Would anyone here be willing to give my first bot a test run, and tell me if there are any problems or errors? Or any change suggestions?
Why can't you?
What python discord api wrapper should I use now ? Pycord ,discord.py , nextcord ,etc , anything new and better ? I have been away for quite a while
No harm in some community feedback
why do we need to run it thought? want feedback on the code then send the repo to the src code? want us to test your features, then invite the person in interest to your testing server?
How can i fix the intents error
import discord
client = discord.Client()
@client.event
async def on_ready():
print("loggen on as {0.user}".format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith("/test"):
await message.channel.send("test")
Idk man, this is my first time trying this kind of thing
Give explicit intents to the client
!intents
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. Various features of discord.py rely on having particular intents enabled, further detailed in its documentation. Since discord.py v2.0.0, it has become mandatory for developers to explicitly define the values of these intents in their code.
There are standard and privileged intents. To use privileged intents like Presences, Server Members, and Message Content, you have to first enable them in the Discord Developer Portal. In there, go to the Bot page of your application, scroll down to the Privileged Gateway Intents section, and enable the privileged intents that you need. Standard intents can be used without any changes in the developer portal.
Afterwards in your code, 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
# Enable all standard intents and message content
# (prefix commands generally require message content)
intents = Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see discord.py's related guide, and for general information about them, see the Discord developer documentation on intents.
thx
but why doesnt my bot respond
import discord
from discord.flags import Intents
client = discord.Client(intents=discord.Intents.default())
@client.event
async def on_ready():
print("logged on as {0.user}".format(client))
@client.event
async def on_message(message):
if message.content.startswith("/test"):
print("test1")
await message.channel.send("test")
You need message content intent for message commands
how do i do that
ok thx
You should commands.Bot instead of discord.Client which is better as it contains more functionality
Also that test is not a command
It's an on_message event
They can make a command handler out of it
Disnake definitely
Dpy bad me no like
!e print(len("await interaction.response.send_message()") / len("await inter.send()"))
@vale wing :white_check_mark: Your 3.11 eval job has completed with return code 0.
2.2777777777777777
And yeah dpy code is 230% longer!1!1!1
well that's not the main issue about d.py
hi people long time no see
railway isnt free anymore
do you guys know where to host now (other than replit)
Henzter
foc?
what is foc
Please make sure you read this fully
When you look for hosting your bot, you might be tempted to use free services or providers that claim to support hosting discord bots (eg PebbleHost and others). Do not use them. Why? Let me explain.
Free hosts and tiers always have drawbacks - The point of a free tier or a host is to get the user to use their product, and upgrade for all of the good features. Hosts such as replit use shared cpus, oftentimes will run into ratelimits, and have "gotchas" that make you tempted to upgrade to their paid tiers. They also literally remove all control out of how you run your bot. Think about it: Hosts need to make money somehow in order to either break even or gain profit. So naturally they will tempt you into upgrading in order to do that. This is basic economics and quite literally how businesses run.
If you are still looking for a host after reading this, then you have some options. And here are them:
-
Pay up - Pay up and use a VPS provider. My pick is Heznter, but see
?tag vpsfor the full list (if you are on the Python discord server, then see!hostingfor your options). More than likely if you are not an eligible HS or college student, this is your option. -
Self Host - If you are able to self host your own server, then go for it. This is really the only "free" way if you already pay for your electricity bill and have the equipment to do so. Raspberry Pis oftentimes are great for this.
-
GitHub Student Developer Pack - IF you are a enrolled student in an HS or college (you will need to either provide an valid student ID or proof of education of your HS or college), then you may apply for this deal. More info about this can be found here. The deal offers $200 free credits on DigitalOcean for 1 year, so if you are a student and need to host your bot, go for it.
I wonder if gh student allows music college students
what's your university is the first question. you'll have to look it up
im just a secondary school student (which instrument are u majoring btw)
Uh it's not a university it's just music college
What's worse it's russian
then probably not
I doubt they will even recognize the handwriting on my ID 💀
you are eligible for gh student pack if you're over 13 and can prove you're a student, no matter where afaik, i got mine by uploading a picture of my public transport card provided by my school
💀 ok
lemme try
If you do not have a dated student ID to upload, you may upload a current transcript, letter on school letterhead, or any documentation that demonstrates your current enrollment.
Lol imma try too
it's also worthwhile to note that the student pack is as much of a "gotcha" Noelle tried pointing free hosting tiers to be. you get free hosts from the pack, you grow somewhat familiar with the stack and you're tempted to stay after your student pack expires.
just buy a VPS.
with DigitalOcean, they are technically a VPS provider so you can just continue to buy from them if you wanted to
yeah there are 3-4 nice deals in the bundle, iirc there is one for AWS aswell if im not mistaken
Ok snipee tell us more ☺️
you can send raw components
this is a big deal if someone wants something less ram eating than persistent views
and for other things like commands with which you can interact anytime even if they're old responses
not a lot of people wants a low level interface such as raw components though, it's bad UX
auto syncing is also kinda effy, you get ratelimited unnecessarily if you reboot a lot
What does UX have to do here?
im self hosting now
can i save my token in a file
secret.env
TOKEN = 'XXXXXX'
main.py
from secret import TOKEN
await bot.start(TOKEN)
you talk about ux in gui(s)
no
Idk their internals but it would be logical to only sync commands that were changed
disnake doesn't update commands if they weren't changed, it's the same exact logic that you would implement in d.py
Yeah I guessed correctly
Yes except it's done in a slightly different way
!pypi python-dotenv
and you see why that's a silly idea?
how would it 'know' when to sync
without automatically fetching first
Fetching isn't that problematic
btw there's an official extension that adds some abstraction for this so it's not that low level if you use that
unnecessary API calls tho no? you even rarely change slash commands
It's a single call
i mean, isn't this what you do in d.py? or are y'all creating a command just to update the commands (that's inefficient)
i don't? i only sync when i added/change any slash command signatures, after that im good
and i do that after like idk, once a few weeks if im actively developing
Yeah same but manual and without that one api call
Does discord have individual ratelimits for endpoints somewhere
i mean, how do you know if you have added/removed a command from code if you don't fetch, are you sincying manually? otherwise what you're saying doesn't make sense
Preferred way of syncing in dpy is manual yeah
yea im syncing manually
ig the endpoints to get app commands are under the general ratelimits
Then that single request at startup doesn't matter at all
which is 50 requests per second
i mean, before implementing Automatic synchronization they will have taken it into account
as always
well i was just stating opinion tbh, people make it like a bad thing, it's barely there
What were you trying to connect to
im just trying to run main.py
So discord?
Can you send full tb
tb?
Traceback
That's kinda sus but I remember it happens cause of something
no
And please show how you connect to database
You clearly do
NO I DO NOT
Asyncpg there both in error and in code
there's written asyncpg in the error
oo ya forgot to tell u
lmaoooo
i used to host this bot in railway.app but its premium now
You gotta get it then
do u have any source for that?
i suggest to install postgresql https://www.postgresql.org/
Then create a database and update your connection config
Or you could dockerize everything ☺️
the documentation =.=
simple means you can't connect to it
im downloading postgres and idk what is the documentation talking about =.=
what part do you not understand
Can you stop with this
I dont need people who are closed minded and shill a fork and claim it's better when they are baseless claims and go "oh this fork is better than the other"
just look at this 😭
you dont need to read through those
in fact, your error boils down to networking than anything else
This piece of doc is unrelated to your issue
i installed postgres
and idk what to do next lemme read the docs again
ok you installed postgres, and then you connect to the server. Just use asyncpg and refer to the docs for what to do next
don't you need to setup users and the core first? i remember doing it in Linux atleast
yes also that
ya its not setup up correctly
which chapter should i go 😭
You aren't building it from source
this is for postgresql 16
Download for Postgres here: https://www.postgresql.org/download/
I'm still sticking with pg 15 until asyncpg supports 16
thanks
then im using 15 then
Np
what do i do
You don't need stack builder. Either just continue if you want stack builder installed or just cancel it
after i installed it idk where to continue
it mention something about setting environment var
17.4.2 or 17.5.2 or skip it and straight to creating databases
mh is psql added to the PATH? btw this is not the right channel for this
i have no idea what is that
when you installed postgresql the launcher most likely asked you to add psql to PATH, was that Option enabled?
you need that to run psql commands without issues
i have no idea but i can test the command to see if it works
doesnt work ig 💀
Yeah, I cannot really figure out where it was running
you'll need to add it to PATH then, google how to add postgresql to PATH
I'd recommend you don't continue using this channel for this
you didn't need to delete it but alright
🫠

i forgot my password :D
There's pgAdmin app, you don't even need cli
wow thanks
can u help me in #databases later they will scold me again ;-;
Sure
how to make change prefix command?
not per server prefix
the bot in 1 server but I want to change the prefix with a command
Create a function that takes client and message, and then pass that as your argument to command_prefix
In the function you’ll query your DB for the servers specific prefix
You’ll also want to create a set prefix command, and also implement some logic in your on guild remove event to remove the guild from your DB when the bot leaves the server
personally i wouldnt query the db everytime you want to check a servers prefix (its not very efficient/timely)
id load all the prefixes from database into memory on startup
Makes sense only if db is on remote server
If it's on same ping is typically around 3ms so doesn't matter much
Especially taking rest latencies lately into account 💀
meh its also kinda the principal. it makes more sense to use memory for things like that. thats kinda what its meant for. it also saves you from constantly querying the database
since the prefix function he speaks of will query the database every time a message is sent
Now that you mentioned it imma write that down to the list of slash commands advantages
Latencies are defo smoking something when we're not looking
generally though it will always be more efficient to query volatile memory like ram over disc (where your db will be) especially if you're going to making excessive amounts of queries which is what he would be doing with getting a servers custom prefix
@tasks.loop(minutes=30)
async def update_followers(yt_channel_id,ig_channel_id,tk_channel_id,member_count_id,guild_id,update_channel):
print(id)
ig_channel = bot.get_channel(ig_channel_id)
yt_channel = bot.get_channel(yt_channel_id)
tk_channel = bot.get_channel(tk_channel_id)
member_channel = bot.get_channel(member_count_id)
ig_follower_count = get_ig_follower_count()
yt_follower_count = get_yt_follower_count()
tk_follower_count = get_tiktok_follower_count()
get_member_count = guild_id.member_count
u_channel = bot.get_channel(update_channel)
if ig_channel and yt_channel and u_channel:
await ig_channel.edit(name=f"Instagram : {ig_follower_count}")
await yt_channel.edit(name=f"Youtube : {yt_follower_count}")
await tk_channel.edit(name=f"Tiktok : {tk_follower_count}")
await member_channel.edit(name=f"Server Members : {get_member_count}")
await u_channel.send(f'Follower counters updated\nCurrent followers:\n Instagram : {str(ig_follower_count)} \n Youtube : {str(yt_follower_count)} \n Tiktok : {str(tk_follower_count)} \n Server Couunt : {str(get_member_count)}')
print("Update Done")
else:
print("Channels or update channel not found")```
Traceback (most recent call last):
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ext\tasks\__init__.py", line 239, in _loop
await self.coro(*args, **kwargs)
File "c:\Users\ASUS\Desktop\dcBot\main.py", line 119, in update_followers
get_member_count = guild.guild.member_count
^^^^^^^^^^^
AttributeError: 'int' object has no attribute 'guild'
pretty new to bot developement, im trying to make a task that does what you can p much see above but im struggling with the server member counter part. any help?
your guild_id is an int
you need actual Guild object to get amount of members
thats like you would do 123.member_count
!e x = 123; x.member_count
@slate swan :x: Your 3.11 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 1, in <module>
003 | x = 123; x.member_count
004 | ^^^^^^^^^^^^^^
005 | AttributeError: 'int' object has no attribute 'member_count'
how can i get that?
!d discord.ext.commands.Bot.get_guild
get_guild(id, /)```
Returns a guild with the given ID.
Changed in version 2.0: `id` parameter is now positional-only.
can someone help me with a prject
is anyone here familiar with making discord music bots?
music bots are against TOS
huh? since when? i still havea bunch of servers which have their own music bots
oh well they always have been, or atleast for a while now
man
its not like music bots are against TOS its just you cant take music from YouTube, Spotify or simmilar
If that's it, Discord won't allow bots to speak in voice channels in the first place
oh
!ytdl for more info
well i heard there Against TOS so thats my mistake sorry abt that
ohh thats why mine wasnt working. i was using spotify for my database of songs
do u guys know how i can use local files instead?
No Clue
but does anyone have experience with making Servers, Databases and User Authentiction / Accounts
thats unfortunate, thanks anyways
No Problem
Depends on where and how you’re getting the music
yeah

