#discord-bots

1 messages · Page 399 of 1

viscid hornet
#

!d datetime.datetime.strptime

unkempt canyonBOT
#

classmethod datetime.strptime(date_string, format)```
Return a [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime) corresponding to *date\_string*, parsed according to *format*.

If *format* does not contain microseconds or time zone information, this is equivalent to:

```py
datetime(*(time.strptime(date_string, format)[0:6]))
```...
viral heart
#

@viscid hornet I think I got it to work 🤷‍♂️

#
@bot.tree.command(name="info-dayz", description="Shows DayZ server information.")
async def info_dayz(interaction: discord.Interaction):

    payment_remaining_time = datetime.strptime(server_info['Payment_remaining_time'], "%Y-%m-%d %I:%M %p")


    current_time = datetime.now()

    time_remaining = payment_remaining_time - current_time

    if time_remaining.total_seconds() > 0:
        days = time_remaining.days
        hours = time_remaining.seconds // 3600 
        time_until_payment = f"{days} days, {hours} hours"
    else:
        time_until_payment = "Time has passed!"

    embed = discord.Embed(title="DayZ Server Information", color=discord.Color.green())
    embed.add_field(name="Server Name", value=server_info['name'], inline=False)
    embed.add_field(name="Password", value=server_info['password'], inline=False)
    embed.add_field(name="Start Time", value=server_info['start_time'], inline=False)
    embed.add_field(name="Time until next payment", value=time_until_payment, inline=False)
    
    await interaction.response.send_message(embed=embed, ephemeral=True)
viscid hornet
#

i told you just to parse the end time into a datetime object and then put the timestamp in that format

viral heart
#

I'd like to note I use chatgpt to help me with this

viscid hornet
#

dt.strptime("some string here", "your format here") then ts = int(end_dt.timestamp()) and then send <t:{ts}:R>

viscid hornet
unkempt canyonBOT
#

10. Do not copy and paste answers from ChatGPT or similar AI tools.

viscid hornet
#

AI tools aren't reliable, especially for coding

viral heart
#

Its not purely AI, and I know that

fast osprey
#

Chatgpt will keep literally lying to you. I don't know how many times you need to be told that you need to stop using it and actually learn on your own

viral heart
#

Once I actually have the time and ability to learn, I will

#

For the time being, I will do my best to understand as much as I can and attempt to learn

fast osprey
#

Or you could just learn properly

viral heart
#

What's the "proper" way to learn it

fast osprey
#

Read articles on individual concepts, do small focused exercises to cement your understanding of those concepts. Don't ask chatgpt to shit out wrong code you don't understand and then hope strangers will fix it for you

viral heart
#

I'll have to do that when I have free time, right now I have school and alot of work to do each day

#

Once I switch schools I will be able to take an elective that teaches python though

fast osprey
#

Then do it then. What you're doing in the interim is reinforcing bad habits and you're asking people to spend their time for free to help you reinforce those bad habits

#

It really doesn't take that much time to read an article on how something works and try it. You're wasting just as much time trying to get people to fix ChatGPT's outputs. There's not an excuse here

rigid depot
#

What does a Discord bot usually cost?

fast osprey
#

To build? Run?

wanton current
#

probably to comission

rigid depot
#

To sell

stark ingot
#

Would depend on many things

  • What the bot does
  • How much work was needed to go into the bot
  • What the creator charges
  • What the buyers budget is
  • Is hosting included?
  • Is support included? For how long?
  • What are other people selling a similar thing for
fast osprey
#

Also not a remotely python related question

viscid hornet
unkempt canyonBOT
#

9. Do not offer or ask for paid work of any kind.

viscid hornet
# viral heart !rule 9

how is that asking for paid work? i'm asking WHERE to get paid work, not FOR paid work

vocal plover
#

Fiverr or similar really

slate swan
viral heart
#

@umbral flare When you had a DayZ server, did you by anychance go through nitrado

umbral flare
#

Yes

viral heart
#

Do you know how to have a bot get info from the ADM log files

unkempt canyonBOT
#

5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.

slate swan
#

!rule 7

unkempt canyonBOT
#

7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.

viral heart
#

@slate swanWhat I'm asking doesn't violate anything, and as for rule 7 im not entirely sure

slate swan
#

meant to send rule 7

viral heart
#

Well its for my bot so I'd guess it'd be allowed here

slate swan
#

day z servers and their logs have nothing to do with discord bots

viral heart
#

It does when I want my bot to get the info from its log files and send the info into my server for killfeeds/stats/playerlists/locations

fast osprey
#

What you do inside of a discord bot doesnt make it discord bot related if it's not specifically the interface with the discord api

viral heart
#

It uses an API which I've seen discussed here, I just don't how to get the API or use it

slate swan
#

that is the api you'll get help for in this channel

viral heart
#

Okay

royal shore
#

i need help wit this problem

vocal plover
#

did you install discord.py with the optional voice dependencies? your command should've looked something like pip install "discord.py[voice]"

royal shore
#

oh ok

#

like this?

#

@vocal plover

vocal plover
#

yep, just like that

#

that should install whats needed for voice

royal shore
#

ok

#

it installed

#

is that all i need?

#

i add the toke

#

token in the little brakcets

#

@vocal plover

#

@vocal plover the same problem happened

finite salmon
royal shore
#

i did it

royal shore
finite salmon
#

You're missing intents kwarg

royal shore
#

oh

#

so like what i type

#

@finite salmon

finite salmon
#

Judging by your code you only need the privileged message content so,

intents = discord.Intents(messages=True, message_content=True)
client = commands.Bot(command_prefix=",", intents=intents)
royal shore
#

with the bot run at bottom

finite salmon
#

I prefer to explicitly enable the required intents but you could also the the default method of the Intent class and then enable message content

royal shore
#

ok so like how do i put it in the code

finite salmon
#

Take a look at all the intents

finite salmon
royal shore
#

should i do

#

client

finite salmon
#

it should be client.run

royal shore
#

ok

finite salmon
#

Yeah

royal shore
#

@finite salmon

finite salmon
#

Go to the dev portal and enable message content intent

#

In your bot

#

Go to your application and under the bot tab

royal shore
#

ok

#

these?

#

@finite salmon

finite salmon
royal shore
#

I need help

fast osprey
#

Your command says it needs an argument

#

and you aren't passing it in when you're calling it in discord

royal shore
#

so

#

what do i do

blissful crane
#

this is not a code issue

#

you're using your own command in the wrong way

royal shore
#

so

#

what do i do

fast osprey
#

Either
a) your code doesn't need that argument, in which case remove it or make it optional or
b) your code does need it, so you pass it in

royal shore
#

so

#

what do i do how do i fix it

fast osprey
#

I gave you options

royal shore
#

idk what to do

fast osprey
#

are you reading them or just want someone to write code

#

pick one of them

royal shore
#

i want someone to write

#

the code

blissful crane
#

even if you say so, that specific error is not due to code specifically but because you're using the bot in the wrong way

royal shore
#

ok

#

so how do i fix it

runic beacon
#

Hello Everyone

fast osprey
#

If you're not willing to engage with your code and make decisions, you're better off hiring someone

fast osprey
#

this is a decision you make

royal shore
#

A i guess

#

what am i removing

fast osprey
#

Do you know what an argument is

royal shore
fast osprey
#

So then how can you answer if you need an argument if you don't even know what an argument is

raven swan
slate swan
#

whatever you prefer

#

look the way they implemented the features of discord, especially interactions like app commands or buttons, and choose whatever you prefer or find more comprehensive

fast osprey
#

Performance, quality of docs, speed of feature release, and support community are also things you may wish to consider

stark ingot
slate swan
#

iirc you can suffix with #python, hrefs

vocal plover
# raven swan nextcord or discord.py

Functionally both of these will serve you fine, the docs are more or less the same thing, the primary difference is how slash commands are handled:

  • Nextcord implements them in much the same way discord.py did (and does) prefix commands
  • discord.py uses command trees, which is structurally different
    Both have roughly the same in terms of an external ecosystem, both have enough users to get reasonably good support, you can't really go wrong either way, write a small both with both and see whch you enjoy using more, because that's what's important really
young dagger
#

I recommend that you remove the N-word from your code as it is a racial slur

young dagger
raven swan
#

totally fine

royal shore
#

its part of my vocabulary

royal shore
fast osprey
#

You're not asking for help, you're asking for someone to do it for you lol

#

which maybe someone will do but it ain't gonna be me for free

viscid hornet
viral heart
frank osprey
open cobalt
#

who puts racial words into a discord bot. come on do better and grow up

#

and if you a grown human, what went wrong in your childhood?

#

it is better to clear these kind of words from your voc, because it can cause dispute or other uncontrolled behaviour

#

In addition, this word, like in your ready event, was used in slave times, for example, in the USA. It is a derogatory word and not used nicely. So please be aware of the origin of this word. It is not a word to throw out of your mouth.

velvet compass
#

@royal shore Your previous message was removed. Please avoid using slurs in code when asking for help on the server

scarlet tiger
scarlet tiger
velvet compass
#

I have addressed the user and clarified the situation, this discussion does not need to continue in the channel

honest quest
#

anyone know why a json file would be wiped after 11 trbes would register into the command? essentially you do /register to log your info and it then sits on a json file
it seems after we gather around 11 tribe datas, it just wipes the whole filef or some reason

slate swan
#

Don't use JSON as database ^^

honest quest
slate swan
#

time to learn then

#

sqlite is a simple way to get started

timber dragon
young dagger
slate swan
#

!pypi asqlite

unkempt canyonBOT
#

A simple and easy to use async wrapper for sqlite3.

Released on <t:1719317735:D>.

slate swan
#

!pypi aiosqlite3

unkempt canyonBOT
young dagger
slate swan
#

Both are good - the first one is just from Rapptz and may be easier to get started

honest quest
#

anyone know what code you could enter so your command will check to see if there is pre-existing data for the entry, if there isnt. It gives a request back to state their registered but it just adds another entry into the db?

#

trying to get it so the bot reads the data in my db first then will just add on top o fit without it wiping any extra data

mellow leaf
#

Hey

#

can anyone here help me make/develop a discord bot that will have 1000s of users? Itd be a coinflip bot with a balance system and payments.

velvet compass
mellow leaf
#

thats the thing

#

Not at least "Real Money"

velvet compass
#

Yeah, thats still a no dawg

mellow leaf
#

ok

stark ingot
#

Where is the record already exists (using a primary key to ensure uniqueness) it will preform an update command instead

slate swan
#

we're not your personal assistants and take orders like that.

#

neither is this channel an AI prompt chat, so with that mentality you won't get much help

#

deleting your message order and then send "?" isn't gonna help

#

also reading the error will give away the issue instantly, so you can fix the error yourself with the help of the internet

viscid hornet
mellow leaf
#

donutsmp

viscid hornet
mellow leaf
#

its allowed like that

#

theres anotehr casino like it with 2000 members

#

for donutsm

viscid hornet
mellow leaf
fast osprey
#

TOS apply to currencies with *Real-world value, so if this currency is reasonably traded or exchanged for legal tender then it would apply (otherwise not)

slate swan
#

whats wrong with this code?

blissful crane
#

I had to really zoom in to see the 20x20 res error... Anyway, it's an indentation error probably due to an unfinished statement above ```py
if value1 == value2:

@bot.command() # expected an indent block

slate swan
#

what line

blissful crane
#

put what?

#

I am just explaining why you're getting the error, there's isn't much info for me to give any other advice

blissful crane
#

the command isn't the issue

slate swan
blissful crane
#

the issue is an unfinished statement above the command

blissful crane
#

the command

slate swan
#

what line

#

of the command

blissful crane
#

I don't know what line your command starts at

stark ingot
#

the entire command

slate swan
#

nvm i fix it thank u

tall furnace
#

is there an easy way to have your discord bot detect when you and/or others are live on twitch and send an automated message in a specified text channel announcing it?

slate swan
#

yes there is, since there are bots that do it

look at the twitch api

tall furnace
#

PATSolotl 10-04 rubber ducky

#

also, is my bot supposed to run off of one .py file or multiple? i assume it would just be one as it is a program. with that in mind, the bot could potentially have thousands or tens of thousands of lines of code, correct?

tall furnace
#

ahhh okay okay ty

slate swan
#

and split some logic into files, e.g. database, maybe some helpers/utils, etc.

celest pelican
#

I'm considering writing a project management bot, think (simplified) Jira in Discord. As prior art I only find very bare-bones projects; the most advanced I guess would be KanbanCord, but a) I think it's a missed opportunity not to use channels/forum posts for tickets, and b) it has no concept of a sprint, which is a must-have for me.

Are there existing tools that I'm not aware of? Is this just a bad idea?
And one technical question: Can a forum post be moved between forums?

slate swan
hushed galleon
#

the bot could in theory replicate the post, but redoing its message history would be annoying, so forum tags might be simpler, e.g. mark a set of posts to be done in the current sprint and let users filter by todo + sprint

if filtering by tags is too inconvenient, perhaps the bot can use a second channel to periodically outline the current backlog / sprint tasks?

stark ingot
#

Big downside of forum tags is they sort with or
tag1 or tag2
Not tag1 and tag2

hushed galleon
tropic gulch
#

@slate swan I am interested in your bot let's talk.

slate swan
analog swallow
#
import requests
import asyncio

YOUR_CHANNEL_ID = 1331683490860896290

def load_users():
    with open('users.txt', 'r') as file:
        return [line.strip() for line in file.readlines()]

async def check_users_status(channel, users):
    online_users = {user: None for user in users}
    
    while True:
        for user in users:
            response = requests.get(f'https://api.roblox.com/users/get-by-username?username={user}')
            data = response.json()

            if data and 'id' in data:
                user_id = data['id']
                game_response = requests.get(f'https://api.roblox.com/users/{user_id}/onlinestatus')
                game_data = game_response.json()

                if game_data['IsOnline']:
                    if online_users[user] is None:  # User just joined
                        online_users[user] = True
                        embed = discord.Embed(title=f"{user} has joined the game!", color=discord.Color.green())
                        await channel.send(embed=embed)
                else:
                    if online_users[user] is not None:  # User just left
                        online_users[user] = None
                        embed = discord.Embed(title=f"{user} has left the game.", color=discord.Color.red())
                        await channel.send(embed=embed)

        await asyncio.sleep(30)  # Check every 30 seconds

intents = discord.Intents.default()
intents.message_content = True  

client = discord.Client(intents=intents)

@client.event
async def on_ready():
    print(f'Logged in as {client.user}')
    channel = client.get_channel(YOUR_CHANNEL_ID)
    users = load_users()
    client.loop.create_task(check_users_status(channel, users))

client.run('')```
#

My error^ I'm trying to make it send an embed when a user joins a game but its giving that error

sharp hazel
analog swallow
#

apis isnt even a api is it

sharp hazel
#

requests.post(url=..., json=....)

sharp hazel
analog swallow
slate swan
patent hull
#

You should also use aiohttp (installed within discord.py) and use the built-in ext.tasks submodule to create loops

last cradle
#

how to determine if a user has a banner, animated icon, and a custom emote in there statuses?

patent hull
#

If a user has a banner, then user.banner is not None, to check whether they're icon is animated, check if user.avatar.animated is True

#

!d discord.User.banner

unkempt canyonBOT
#

property banner```
Returns the user’s banner asset, if available.

New in version 2.0...
slate swan
#

how can i make slash command discoerd bot?

#

i cant finde gut tutorials on it

#

good*

stark ingot
#

What library are you using?

slate swan
stark ingot
slate swan
#

ok thanks il try

#

!paste

unkempt canyonBOT
#
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 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.

slate swan
#

error

#

error text

stark ingot
#

You leaked your token, please reset it asap

slate swan
#

thanks

#

its not that important its a test token

#

but ty

stark ingot
slate swan
#

ty

#

were should i paste ?

#

this soloution

stark ingot
#

Probably close to the top of the code

slate swan
#

ok

stark ingot
#

right after imports should work

slate swan
#

i tried fix always error i try with nodes

#

i read about it it should be good

slate swan
#

@stark ingot I am gona make it with nextcord

#

Works for me

stark ingot
#

Sounds good, nextcord is a very good library from what I hear

coral flax
golden portal
#

yes

#

!d discord.app_commands.user_install

unkempt canyonBOT
#

@discord.app_commands.user_install(func=None)```
A decorator that indicates this command should be installed for users.

This is **not** implemented as a [`check()`](https://discordpy.readthedocs.io/en/stable/interactions/api.html#discord.app_commands.check), and is instead verified by Discord server side.

Due to a Discord limitation, this decorator does nothing in subcommands and is ignored...
golden portal
#

see examples

golden portal
#

it's a single deco yea

drifting arrow
#

What can I use instead of

    async def cog_load(self):
        self.battlemetrics = Battlemetrics(self.tokens['tokens']['battlemetrics_token'])
        await self.announcer.start()
```?
#

cog listener?

drifting arrow
#

And the other loop doesnt get initiated

#

Ended up moving the await self.announcer.start() to the __init__ section

#

it works ¯_(ツ)_/¯

hushed galleon
drifting arrow
#

oh lol

hushed galleon
#

you had unintentionally awaited the return value of Loop.start(), an asyncio.Task that was running the infinite loop

#

so your method probably got stuck waiting for your announcer loop to stop before it could run the next line

summer fog
#

Hello. I'm created music discord bot using python.I want host it AWS EC2 ubuntu server but I got this yt-dlp module you tube loging cookies error I'm try cookies add manually but still don't work. Please anyone can help me fix this problem.

unkempt canyonBOT
#

5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.

slate swan
#

!ytdl - actually easier to understand

unkempt canyonBOT
#
Our youtube-dl, or equivalents, policy

Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.

For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:

The following restrictions apply to your use of the Service. You are not allowed to:

1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service;  (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;

3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;

9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
summer fog
young dagger
timber dragon
#

Thus, you will not get help for it here.

slate swan
summer fog
fast osprey
#

By removing any of your code that touches youtube

stark ingot
#

Make your own music or find a platform that gives you permission to stream music

deft mural
fast osprey
#

spotify has terms in their tos, too

#

^

#

A platform has no incentive to give you free rights to redistribute content and screw over their creators lol

opal vortex
#

it can fry when roaches decide to find their way inside it too.

shrewd apex
#

would roaches survive the cpu temp first tho 👀

opal vortex
#

they love heat esp in the winter lol

shrewd apex
#

damn ducky_concerned

opal vortex
#

after all they can survive an atomic bomb

shrewd apex
#

fair enough

#

roaches for a reason

opal vortex
#

only way to kill them is line your laptop/pc with roach killer chemicals that they will most likely eat.

#

but even then they still could die inside of it after laying eggs.

#

💀

viscid hornet
#

wait there's guild install too??

#

holy shit, i feel like such a dumbass for doing ```py
@allowed_installs(guilds = True, users = True)

fast osprey
#

It's just syntactic sugar shortcuts

slate swan
#

upgrade to 2.4

#

eh, it's just the parameters of the function

#

!d discord.app_commands.choices

unkempt canyonBOT
#

@discord.app_commands.choices(**parameters)```
Instructs the given parameters by their name to use the given choices for their choices.

Example...
viscid hornet
#

or can the user still just put in whatever they want

slate swan
#

Choices are choices

sick birch
#

autocomplete does not

viscid hornet
stark ingot
#

Limited to 25 choices tho

viscid hornet
#

is this an Invite object or a static link?

#

!d discord.Invite

unkempt canyonBOT
#

class discord.Invite```
Represents a Discord [`Guild`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Guild) or [`abc.GuildChannel`](https://discordpy.readthedocs.io/en/stable/api.html#discord.abc.GuildChannel) invite.

Depending on the way this object was created, some of the attributes can have a value of `None`...
finite salmon
#

Or do I have to make my own

sick birch
finite salmon
blissful crane
#

if you want to make bot owner only commands you should make them prefix since you can hide prefix commands from users, but if you really don't want. Make it a test-guild only command

finite salmon
#

Yeah we sync it to an admin guild, but that guild has both admins and owners, we only want owners to use those commands not admins

#

We'll just make our own decorator for it ig

stark ingot
midnight quail
#

Hello guys

wintry rose
#

i have peaked

young dagger
#

Should I list all updates for each event or just the latest one?

timid spade
#

getting the

even tho they are enabled in dev portal

wanton current
#

You need to enable them in the code as well.

timid spade
#

did, chat gpt'ed it

#

but still the warning is there

#

tried disable and then enable again too

wanton current
#

and did you pass it into your bot constructor

timid spade
#

intents=intents

#

yes

#

should i reset token? i am runing this app after like an year now

wanton current
#

if you saved and everything, then you either have the wrong token, or you changed the intents for the wrong bot (on the dev portal); most likely

timid spade
timid spade
#

that token was so old, idk maybe that caused the issue

wanton current
#

nice

wintry rose
#

await interaction.response.send_message(poll=discord.poll(question="test",answers=['testanswer1','testanswer2']))
i ran this and it said module isnt callable

timber dragon
#

Poll*, it's a class

wintry rose
#

i hate classes

timber dragon
#

welcome to OOP!

wintry rose
timber dragon
#

read the docs

#

chatgpt doesn't know shit

wintry rose
#

probably should have guessed that the first problem would be the thing i put in there with no rhyme or reason

wanton current
wintry rose
#

is it like poll.add_answer()

#

like with embeds

timber dragon
#

did you check the docs?

wintry rose
#

i dont know how to read python docs imma be real

timber dragon
wintry rose
timber dragon
#

they're fairly easy to understand

wintry rose
timber dragon
#

yup!

wintry rose
#

its still saying its not callable

wanton current
#

big P

wintry rose
#

oh mb

wanton current
#

discord.poll would be the file (module) discord/poll.py

wintry rose
#

isnt there a way to test certain lines and not the entire program

wanton current
#

Usually you can use breakpoints and stuff, but I'm not sure they play so well with async stuff

wintry rose
#

i kinda figured but i had to figure out timedelta

#

also suprisingly simple

#

do the slash commands work as classes

#

nvm im dumb

wanton current
#

lol

wintry rose
#

uh oh am i sped

#

is this not how you do it???????????

stark ingot
#

it is send_message() as per the docs

wintry rose
#

mb

cunning briar
#
import discord
from discord.ext import commands
import os

TOKEN = "hided"


intents = discord.Intents.default()
intents.messages = True  


client = commands.Bot(command_prefix='!', intents=intents)

@client.event
async def on_ready():
    print("BOT READY")

@client.command()
async def hello(ctx):
    await ctx.send("hello")

client.run(TOKEN)
``` why the bot doesnt respond
#

when i say !hello it doesnt respond

stark ingot
#

You do not have the message content intent enabled. You need to have this to read message content.

viscid hornet
stark ingot
#

I strongly recommend that you do not use prefix commands though. Slash commands will be easier in the long run

slate swan
slate swan
#

they dont come to you to check if you've called them, saving energy aka bandwidth

cunning briar
#

  File "C:\Users\dv\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 858, in runner
    await self.start(token, reconnect=reconnect)
  File "C:\Users\dv\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 787, in start
    await self.connect(reconnect=reconnect)
  File "C:\Users\dv\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 711, in connect
    raise PrivilegedIntentsRequired(exc.shard_id) from None
discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead.
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x0291F9B8>
Traceback (most recent call last):
  File "C:\Users\dv\AppData\Local\Programs\Python\Python38-32\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\Users\dv\AppData\Local\Programs\Python\Python38-32\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Users\dv\AppData\Local\Programs\Python\Python38-32\lib\asyncio\base_events.py", line 719, in call_soon
    self._check_closed()
  File "C:\Users\dv\AppData\Local\Programs\Python\Python38-32\lib\asyncio\base_events.py", line 508, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
stark ingot
#

Did you look at the error?

viscid hornet
slate swan
stark ingot
#

Depending on your setup you can get rid of the gateway all together which is more than marginal

slate swan
#

think of it like this - a waiter who is constantly coming up to you and checking if you wanna pay the bill

#

(prefix commands, takes lots of energy)

viscid hornet
slate swan
#

and a booth where you can pay your bill at (slash commands)

fervent surge
slate swan
#

from 2015? yea

sick birch
#

what are these?

sick birch
#

bookmarks and reminders maybe

#

save any message to DMs to look at later, and schedule a message to be sent at a later time

#

.bookmark

lament depotBOT
#
You blew it.

Your input was invalid: You must either provide a reference to a valid message, or reply to one.

The lookup strategy for a message is as follows (in order):

  1. Lookup by '{channel ID}-{message ID}' (retrieved by shift-clicking on 'Copy ID')
  2. Lookup by message ID (the message must be in the current channel)
  3. Lookup by message URL

Usage:```
.bookmark [target_message] [title=Bookmark]

sick birch
#

!remind

unkempt canyonBOT
#
Missing required argument

expiration

sick birch
#

basically those commands

#

i find myself using these fairly often

#

bookmarks when i see an interesting message i may want to look into later, and reminds if I want to get back to someone on a topic later

#

not formal enough to need a dedicated knowledge management app or todo app

#

sure yeah

viscid hornet
#

as in how do i implement a date and time? could i parse one through regex?

quick gust
#

yes

slate swan
#

i already have a function for this: ```py
def parse_time_string(self, time_str: str) -> int:
total_seconds = 0
time_units = {
'y': 31536000, # years
'mo': 2592000, # months
'w': 604800, # weeks
'd': 86400, # days
'h': 3600, # hours
'm': 60, # minutes
's': 1 # seconds
}
pattern = r'(\d+)([y|mo|w|d|h|m|s])'
matches = re.findall(pattern, time_str)

for value, unit in matches:
total_seconds += int(value) * time_units[unit]

return total_seconds

last cradle
#

is there a way to determine if user has a animated avatar and a custom or animated emoji in there status

slate swan
#

yes

last cradle
#

how

slate swan
#

animated avatar hashes start with a_

last cradle
#

and thats gonna be a work around to determine if user has nitro….

quick gust
#

no because not every nitro user has an animated pfp

slate swan
#

and yeah it's not 100% sure the user has nitro with that

last cradle
#

ok

slate swan
#

will for some/lots of people be accurate, but not everyone

last cradle
#

what else do i do other than banner :o

quick gust
#

no reliable way, I'm pretty sure

fast osprey
#

You don't because discord doesnt tell you if someone has nitro intentionally. Why does it matter if they do?

last cradle
#

word

stark ingot
#

Because you have the wrong names for the flag object

quick gust
#

!d discord.PublicUserFlags

unkempt canyonBOT
fast osprey
#

What happens when it doesn't work? What does "work" mean here?

#

Also you really shouldn't be spawning channels for tickets. Use threads

stark ingot
#

Can you delete your messages and use the paste service, this is too hard to read

#

!paste

unkempt canyonBOT
#
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 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.

pallid plank
#

good god

pallid plank
sick birch
#

that part is important otherwise your reminders won't be persisted across restarts

viscid hornet
unkempt canyonBOT
#
Command: remind

Commands for managing your reminders.

Source Code
stark ingot
#

how would it know the timezone?

wanton current
#

r. danny has commands for settings timezones

sick birch
#

either that or relative times (which i find is more common)

#

i.e x time from now

stark ingot
#

I am trying to figure out how to make a datetime input rn. I dont want to store a timezone of a user but I also dont want the user to have to input it

sick birch
#

well you don't have many options there

stark ingot
#

yeah...

viscid hornet
exotic hazel
viscid hornet
stark ingot
#

-# Another reason that timezones should not exist

rough ridge
#

How do I color text? I've tried using escape characters and code blocks, but it doesn't show up on mobile.

blissful crane
#

discord lacks in that regard which is a big shame. There isn't much you can do unfortunately

rough ridge
#

The code over here seems to be colored properly, even on mobile, but when I try and replicate it, it never works...

blissful crane
#

how are you replicating

stark ingot
#

!code

unkempt canyonBOT
#
Formatting code on Discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

tawdry wolf
#

how do i split my commands in multiple files? And what are "cogs"?

frank osprey
#

ah yes them dam cogs 7024_man_of_culture

scarlet tiger
#

I'm not sure if Cogs are created the same way in all libraries

fast osprey
#

Extensions are just external files that get loaded into the bot. Whether they contain cogs or how many is an implementation choice

frank osprey
#

Wait so everything goes of the main bot.py file?

#

you know what i mean

fast osprey
frank osprey
#

ah maybe not then dont worry

last cradle
#

how do they make the title clickable

scarlet tiger
glad cradle
#

!d discord.Embed

unkempt canyonBOT
#

class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, timestamp=None)```
Represents a Discord embed...
glad cradle
#

if you pass title and url the title will get a hyperlink to the url

#

@last cradle

last cradle
scarlet tiger
vague moon
#

Hello,I made a discord bot in python and I want to host it with a free how,does someone know a free hosting for discord bot?

unkempt canyonBOT
#
Discord Bot Hosting

Using free hosting options like repl.it for continuous 24/7 bot hosting is strongly discouraged.
Instead, opt for a virtual private server (VPS) or use your own spare hardware if you'd rather not pay for hosting.

See our Discord Bot Hosting Guide on our website that compares many hosting providers, both free and paid.

You may also use #965291480992321536 to discuss different discord bot hosting options.

young dagger
#

But that's just me, because I wouldn't trust a free VPS

woeful sparrow
#

can I have one link button that when someone presses this button, the embed's footer changes?

viscid hornet
#

URL buttons don't have a callback (i think)

#

the callback is pre-defined by discord

woeful sparrow
# viscid hornet why? whats your use case?

I want when someone sends an mp3 file, my bot to download it, upload it to my database and give a link to the user so that he can download the file, and I want to put the link to a button, and when someone presses this button, after the user presses it, the footer of the embed where the button is, changes and says how many times the button has been pressed

viscid hornet
#

they already have the file

#

and discord already lets you send files

#

this would make sense if it was a pastebin, not if it was discord

woeful sparrow
#

it's for a server with unreleased songs that in the past they had a term and their server shut down because of the songs and so it's a way that their server won't be termed

tall furnace
#

@bot.command()
async def testing(ctx):
def check(message):
return message.author == ctx.author and message.channel == ctx.channel
await ctx.send("What would you like capitalized?"),
msg = await bot.wait_for('message', check=check)

await ctx.send(msg.content.upper)
#

this line of code made my bot reply with:
D_CordBotAlpha
APP
— Today at 5:02 PM
<built-in method upper of str object at 0x000001703168F7E0>

woeful sparrow
wanton current
woeful sparrow
tall furnace
#

i should have hit tab in pycharm lmao

thanks boys, i thought i gave my bot a stroke for a second letmethink

unkempt canyonBOT
#
Formatting code on Discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

viscid hornet
#

!rule 5 - and also this

unkempt canyonBOT
#

5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.

severe sonnet
#

how do i get the author id from a discord message when another person is reacting to the message?

#

for example, i wanna this message get my id and the reaction get the other person id

#

which is kinda the same person

stark ingot
#

Cached messages can be accessed with Reaction.message

sick birch
#

if it’s not cached you’ll need to do a lookup using the message id. Though I don’t know if on_reaction gets triggered for uncached messages

stark ingot
severe sonnet
viscid hornet
#

!d discord.Reaction.message

unkempt canyonBOT
viscid hornet
#

bosh

severe sonnet
#

!discord.reaction.member

stark ingot
severe sonnet
#

that's strange

#

now i don't know which gets the member

#

trying to acess the reaction owner

#

who made the reaction

hushed galleon
hushed galleon
#

then you have to manually get/fetch the member from payload.user_id

#

oh right, there is payload.member as well

#

!d discord.RawReactionActionEvent.member

unkempt canyonBOT
severe sonnet
#

the problem is that i get error when i try using the payload:

#

which is reaction: discord.Reaction

severe sonnet
#

anyways

#

i just added a checker, and it was suppose to be raw version not reaction

#

i got the wrong relative

#

also, why trying to import the package it shows an error?

slate swan
#

how's your file structure

viscid hornet
#

i'm assuming you have a database.py file inside your cwd?

severe sonnet
#

how do i get the id of my bot?

#

using self.client?

#

!d client

blissful crane
austere musk
#

Hey guys i don't know if that is a glitch with me or not but I can use my bot anywhere even if the bot not in the server so is there something to disable from portal to fix that?

slate swan
#

That's a user installed app

errant moss
#

Hey! I am having a troubled related to my code...
So i am trying to send dms to multiple users but when i try to test it the bot is unable to send dms to users which i have valid id's of.

The bot is in same server as they are also ids are valid but it gives an error

User with ID [ID] not found.

slate swan
#

What is the code & user id

errant moss
# slate swan What is the code & user id
async def send_test_dm():
    users = get_user()
    for user_id in users:
        try:
            user = await bot.fetch_user(user_id)
            if user:
                embed = discord.Embed(title="Test DM", description="This is a test DM to check if the bot can send messages.", color=0x1a52f9)
                await user.send(embed=embed)
            else:
                print(f"User with ID {user_id} is None.")
        except discord.errors.NotFound:
            print(f"User with ID {user_id} not found.")
        except Exception as e:
            print(f"An error occurred while sending DM to user {user_id}: {e}")```
#

here it is and the user id is mine.

#
def get_user():
    with open('user.json', 'r') as f:
        users = json.load(f)
    return users
#

also the ID are stored in a String format

slate swan
#

remove your try except and let the normal error print

errant moss
#

ok

slate swan
#

!d discord.ext.commands.Bot.fetch_user

unkempt canyonBOT
#

await fetch_user(user_id, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Retrieves a [`User`](https://discordpy.readthedocs.io/en/stable/api.html#discord.User) based on their ID. You do not have to share any guilds with the user to get this information, however many operations do require that you do...
slate swan
#

Expects a user ID which are integers, not strings

#

int(user_id)

errant moss
#

the error which i am getting suggests discord is not being able to find the users

slate swan
#

both with string and int

errant moss
#

i even tried printing

slate swan
#

and it prints?

errant moss
# slate swan and it prints?
async def send_test_dm():
    users = get_user()
    for user_id in users:
            print(f"Attempting to fetch user with ID: {user_id}")
            user = await bot.fetch_user(user_id)
            print(f"User: {user}")```
slate swan
#

What does it print?

errant moss
#

then the error shows up

slate swan
#

whom's id is that?

errant moss
slate swan
#

nope

errant moss
#

@errant moss

slate swan
#

1314084551265357876

errant moss
slate swan
#

12648712739817328 != 1314084551265357876

errant moss
viscid hornet
slate swan
errant moss
slate swan
errant moss
slate swan
#

vscode?

#

search for "12648712739817328" in all your files

#

you likely have that somewhere

#

or the user.json file is not saved properly

errant moss
errant moss
slate swan
#

it gets the wrong id, so no

#

your user.json file is likely not saved properly or you're reading from the wrong file

#

your code gets the ID 12648712739817328 which is not your id

#

and not a user id at all

#

discord wasn't existing at that time

errant moss
#

wtf i just noticed now its fetching wrong id

slate swan
#

that id was "generated" <t:1423086088> - so not possible

errant moss
#

Wtf

#

i can try entering my id manualy

#

rather than retriving it

slate swan
#

that will work

errant moss
#

12648712739817328
@slate swan but why is it fetching this id

#

i dont have it anywhere

slate swan
#

using vscode?

errant moss
#

i just found out🤣

slate swan
#

use the magnifying glass icon on the left (ctrl+shift+f or something like that) and search for it

errant moss
severe sonnet
#

okay so, i need the reference in the docs about the list of those who reacted, can anyone give me an href?

quick gust
#

!d discord.Message.reactions

unkempt canyonBOT
quick gust
#

a list of discord.Reactions to a message

errant moss
severe sonnet
#

so it's kinda different

quick gust
#

oh then you'll have to manually form and store a list

#

every time a reaction is added, update the list

#

this seems pretty weird tho and there might be a better option for whatever your use case is

severe sonnet
quick gust
#

or actually

quick gust
#

!d discord.RawReactionActionEvent.message_id

unkempt canyonBOT
quick gust
#

so it will be something like payload.message_id

#

use it to get the message

austere musk
severe sonnet
#

okay so, which function is related to stage/voice stuff?

#

i need that to check how long a person was in a voice chat/stage

sick birch
severe sonnet
#

is there a function that checks the on joining

#

and on leaving?

sick birch
#

You can obtain the current time using datetime.now() of both join and leaves, and subtract these datetimes to receive a timedelta object

severe sonnet
#

i see, also on_voice_state_update it doesn't seems to have a way to grab the user

#

unless

severe sonnet
sick birch
unkempt canyonBOT
#

class datetime.timedelta(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0)```
All arguments are optional and default to 0. Arguments may be integers or floats, and may be positive or negative.

Only *days*, *seconds* and *microseconds* are stored internally. Arguments are converted to those units...
severe sonnet
#

how do i grab all members that joined the voice chat?

winter sentinel
#

hello I need some help with a discord bot building like I want a discord bot that plays music,how can I script it?

finite salmon
#

love blessing my eyes by opening dpy docs

severe sonnet
viscid hornet
#

!d discord.VoiceState.channel

unkempt canyonBOT
#

The voice channel that the user is currently connected to. None if the user is not currently in a voice channel.

finite salmon
# severe sonnet uhhhmm, i'm using `on_voice_state_update` i don't know if i can do that

https://discordpy.readthedocs.io/en/stable/api.html?highlight=on_voice_state_update#discord.on_voice_state_update

on_voice_state_update takes in 3 parameter: member, before and after.

before and after are of the type discord.VoiceState (https://discordpy.readthedocs.io/en/stable/api.html?highlight=on_voice_state_update#discord.VoiceState)

If you scroll down that link you'll find the channel attribute which is of the type VoiceChannel or StageChannel (you needn't worry which type you end up getting since they both have members attribute) and thats the type which you need

#

youd mostly want to use the voicestate from the before argument you get which is the orignal vc which you want to get the members from

#

if thats what you want

severe sonnet
#

how do i check if the channel is private?

fast osprey
#

Define private. Just whether or not @everyone has view?

severe sonnet
#

i have no idea, the guy who contracted me told me to see a document i don't have acess

#

so i don't know what he want with private voice chat

#

guess i should ignore that step form the docs i received from my client

fast osprey
#

Hard to implement stuff without the requirements lol

severe sonnet
#

yeo

#

guess i should just ignore that part

#

since i have no idea what to implement

#

how do i check the time that two people made voice chat activities together

#

such as gartic phone

viscid hornet
#

!d discord.Activity

unkempt canyonBOT
#

class discord.Activity(**kwargs)```
Represents an activity in Discord.

This could be an activity such as streaming, playing, listening or watching.

For memory optimisation purposes, some activities are offered in slimmed down versions...
viscid hornet
severe sonnet
#

okay next i need to know how to check when the user started an activity, not just gartic but any activity

#

in voice channel

#

thought i don't know if this fits in on_voice_state_update

viscid hornet
severe sonnet
viscid hornet
severe sonnet
fast osprey
#

There is a presence event

viscid hornet
#

@fast osprey i decided to search my own database with dpy's docs in it shrug

severe sonnet
fast osprey
#

!d discord.on_presence_update

unkempt canyonBOT
#

discord.on_presence_update(before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Member) updates their presence.

This is called when one or more of the following things change...
severe sonnet
#

okay so, i'm lost on getting the time where the old update the member started the activity

#

and when they ended their activity

fast osprey
#

The event fires when they change their presence

severe sonnet
versed basalt
#

im having an issue where I can integrate my bot with a server, but the bot never actually joins the server. Maybe im missing something simple since its been a while since I worked on this bot, but has anyone run into something similar?

The bot runs and doesent throw any errors at me, tried removinf the integration and readding it, made sure it had the right scopes and intents, re did token etc

#

it just never shows up as a user on the server

stark ingot
#

what scopes are you choosing?

versed basalt
#

applications.commands

stark ingot
#

For the bot to show in the server I belive you also need to select bot

versed basalt
#

ty i remember that process now, i knew it was something dumb on my part

#

yep that did it

unkempt canyonBOT
#

property activity```
Returns the primary activity the user is currently doing. Could be `None` if no activity is being done.

Note

Due to a Discord API limitation, this may be `None` if the user is listening to a song on Spotify with a title longer than 128 characters. See [GH-1738](https://github.com/Rapptz/discord.py/issues/1738) for more information...
viscid hornet
#

!d discord.Activity.start

unkempt canyonBOT
viscid hornet
#

!d discord.Activity.end

unkempt canyonBOT
#

property end```
When the user will stop doing this activity in UTC, if applicable.
severe sonnet
#

okay so, in activity is it possible to list all the participants of the activity?

severe sonnet
#

it's because i'm working on a collective point gaining system

#

all those that was in the activity gains points

viscid hornet
versed basalt
#

my bot no longer has the "supports slash commands" badge, and slash commands are not showing up. Are these things correlated or coincidental?

#

this is a "new" bot using code of mine that has previousley worked fine.

stark ingot
#

Make sure you sync the commands and then use ctrl+r to refresh your discord.
Also I believe that the commands need to be global for your bot to get the badge

shut zenith
#

Can sb help me to connect my bot?

#

I can't connect it to my server for sum reason

scarlet tiger
shut zenith
#

sorry

#

one sec

shut zenith
#
from discord.ext import commands

# Create an instance of the bot with the required intents
intents = discord.Intents.default()
intents.message_content = True  # Allows reading message content

bot = commands.Bot(command_prefix='!', intents=intents)

# Event when the bot is ready
@bot.event
async def on_ready():
    print(f'Logged in as {bot.user}')

# Command that sends the rules
@bot.command()
async def rules(ctx):
    rules_message = """
    ℝ𝕦𝕝𝕖𝕤
    𝒓𝒖𝒍𝒆 1: 𝒖𝒔𝒆 𝒕𝒉𝒆 𝒄𝒉𝒂𝒏𝒏𝒆𝒍𝒔 𝒂𝒑𝒑𝒓𝒐𝒑𝒓𝒊𝒂𝒕𝒆𝒍𝒚.
    𝒓𝒖𝒍𝒆 2: 𝒏𝒐 𝒑𝒊𝒏𝒈𝒊𝒏𝒈 𝒆𝒗𝒆𝒓𝒚𝒐𝒏𝒆 𝒇𝒐𝒓 𝒏𝒐 𝒓𝒆𝒂𝒔𝒐𝒏 𝒂𝒕 𝒂𝒍𝒍 𝒐𝒓 𝒑𝒓𝒐𝒎𝒐 𝒓𝒆𝒂𝒔𝒐𝒏𝒔.
    𝒓𝒖𝒍𝒆 3: 𝒕𝒉𝒓𝒆𝒂𝒕𝒆𝒏𝒊𝒏𝒈 𝒐𝒓 𝒂𝒃𝒖𝒔𝒊𝒏𝒈.
    𝒓𝒖𝒍𝒆 4: 𝒊𝒏𝒂𝒄𝒕𝒊𝒗𝒊𝒕𝒚 𝒊𝒔 𝒂 𝒅𝒆𝒎𝒐𝒕𝒊𝒐𝒏.
    """
    await ctx.send(rules_message)

# Run the bot with your token
bot.run('**TOKEN**')```
#

and it's not working

quick gust
#

explain not working

#

what's the error

viscid hornet
winter sentinel
#

guys can someone give me a script for a discord bot that plays music on a vc?

wanton current
winter sentinel
#

ty

stark ingot
winter sentinel
#

alright

#

i will make sure to follow the steps carefully

drifting arrow
#

This is not what you want to see when you're setting up a new repo for a discordbot XD

full ether
#

better than your token getting leaked and not knowing about, tbf

drifting arrow
#

true true

#

turns out I forgot to delete my zip file before uploading my repo lol

#

I shared this a while ago, but i've been tweaking it and fixing bugs here and there

#

What originally turned out to be a quick 5 minute job, in and out. turned out to be like several days lol

shut zenith
drifting arrow
#

So what ya'll working on

shut zenith
#

Do ur guys use replit or?

fast osprey
#

replit is an environment for prototyping small sites. Not for hosting long-living processes.

shut zenith
#

Oh ok

#

Wat should I use for the bot?

fast osprey
#

!hosting

unkempt canyonBOT
#
Discord Bot Hosting

Using free hosting options like repl.it for continuous 24/7 bot hosting is strongly discouraged.
Instead, opt for a virtual private server (VPS) or use your own spare hardware if you'd rather not pay for hosting.

See our Discord Bot Hosting Guide on our website that compares many hosting providers, both free and paid.

You may also use #965291480992321536 to discuss different discord bot hosting options.

stark ingot
stark ingot
#

For coding or hosting?

fast osprey
shut zenith
#

ya like for the bot

stark ingot
#

For coding or hosting though
Coding is where you type the code and run it to test and make sure it works
Hosting is where you run it 24/7
-# This is a very simplified definition

shut zenith
#

Oh ic

#

Like for coding?

#

sry Im not very good at this

stark ingot
#

Replit is fine when it is working and not broken.
If you have a computer you can install an IDE, some of the most popular IDEs for python are Thonny, Pycharm, and VS Code

shut zenith
#

My computer has no space left😭

#

Too much stuffs for skl

#

Is there like a template for something that I can use for the bot?

stark ingot
#

You tecnically do not have to use an IDE but it makes things easier.
You can also use notepad or notepad++

stark ingot
shut zenith
stark ingot
#

Yeah discord bots are not a beginner project, but we wont stop you from doing it.
You could start with a few smaller projects and work your way up to discord bot.

drifting arrow
#

There are probably free bot hosting websites out there, but they're free for a reason.
Most bot hosting websites will charge you around $5 USD (i think?) a month to host your bot and they usually have 24/7 uptime.
I find it affordable if you wanna run bots on small groups of servers etc. They aren't meant to be powerful but if you're popular enough you can afford a better hosting, at which point you'll move from the general pterodactyl hosting services you find around to a more dedicated machine which can cost a bit more

#

This is just from my personal experience and what I've seen people do.

fast osprey
#

IMO, anything that markets itself as a "bot host" is scamming you. There's no such thing as a bot host. There's just machines. Anyone trying to sell you that (free or otherwise) is trying to take advantage of lack of experience.

Industry recognized, legitimate hosts will give you a box and let you do whatever you want with it. Small ones can run cheap, but none will be free forever unless there's a catch

drifting arrow
fast osprey
#

Oh for just coding environments they're a dime a dozen

#

pythonanywhere, etc etc

drifting arrow
#

You get what you pay for, and for what you mentioned "give you a box", do you honestly think you're getting that for 5 bucks a month?

fast osprey
#

Yes? I have a hetzner cloud vps for less than 5 euro a month

drifting arrow
#

alright mr "i did my research"

#

:(

fast osprey
drifting arrow
#

Some of us just googled "bot hosting" and clicked the first link

fast osprey
#

With hosting there's not a singular correct answer. But the ratio of self-marketed "bot hosts" I've seen that are either a) overcharging or b) literally a honeypot scam to get your token is in the high 90%'s

drifting arrow
#

Oh, the ones I use are legitimate services. In fact there's a really good Australian one I use who has been incredibly responsive whenever I needed help adjusting. He doesnt host just bots he also hosts games as well. And it's awesome.

I won't give the name because I dont wanna "advertise" but I can if u dm me.

#

I believe he's Australian.

#

idk. I wanna believe he is.

shut zenith
#

Can sb help me check whats going on pls

fast osprey
#

Don't put your token into files you send to people, or remove it before sending

#

also code you sent doesn't match the error

shut zenith
shut zenith
#

How do u read the codes so fast

#

But it is in str tho

fast osprey
#

error doesn't lie

#

Maybe you're not running the code you think you are

fast osprey
#

your traceback clearly has a line that's literally client.run(token). That's the code it's running

#

if the code you're looking at doesn't have that exact line, then you're not running the code you're looking at

shut zenith
#

Can u pls help me double check?

fast osprey
#

token is none

shut zenith
#

But didn't I set token = os.getenv("My_Token")?

fast osprey
#

That doesn't mean it's not None

shut zenith
#

Im not sure wdym by None then😭

fast osprey
#

If you don't know what None is, then you might want to do simpler projects to learn

shut zenith
#

Do u know how can I fix it?

fast osprey
#

By learning what None is

shut zenith
fast osprey
#

Basic coding challenges to start with. It really depends on how you learn. But things like a bot layer on several concepts and you're trying to learn all of them at once

young dagger
#

token is a variable used in client.run(token)

#

Which should be in the env file

drifting arrow
#

None is none. basic human english

shut zenith
shut zenith
glad cradle
viscid hornet
#

is there any way i can upscale the resolution of my 16x16 pixel art?

slate swan
viscid hornet
slate swan
#

then, unfortunate

viscid hornet
pallid plank
#

Make a 160x160 photo where each pixel from the 16x16 is 10 pixels wide

#

Or something like that

slate swan
# viscid hornet is there any way i can upscale the resolution of my 16x16 pixel art?

that pic is blurry indicating some linearity or anti-aliasing filters... you can definitely upscale any pixelate arts like that to any resolution as what EasternFarmer said try upscaling using any image processing software you have or whatever tool or method you use and then implement the image without the aforementioned filters search for some parameter like "Nearest", "Sharp" or "Point-sampling"

viscid hornet
slate swan
viscid hornet
slate swan
# viscid hornet anything programmatic?

only check for putting image filter as "Nearest", "Sharp" or "Point-sampling" see what option you might get, also check if you can use pillow module for implementing the image in your bot code

broken folio
#

need help with my whole bot's code. it doesnt start, always ratelimited, responds to slash commands without issues tho. just need help to optimize it, i'll be very thankful!
2k lines

exotic hazel
#

!paste

unkempt canyonBOT
#
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 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.

stark ingot
#

^ along with any errors or logs you get

thorn imp
#

I wondering can tell me is my code is efficient or not
I send the code in dm

stark ingot
#

Why do you need to send it in DM?
You are allowed to send code here, if it is too long use the paste service in the message a few above this

broken folio
#

need help with my whole bot's code. it doesnt start, always ratelimited, responds to slash commands without issues tho. just need help to optimize it, i'll be very thankful!
2k lines

i'm gonna send it in dm as i don't really want it to be seen by everyone

viscid hornet
broken folio
#

i don't

viscid hornet
#

unless it's something that breaks TOS, why are you hiding the source code?

viscid hornet
#

!paste - @broken folio put your code in here and then share the link

unkempt canyonBOT
#
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 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.

broken folio
viscid hornet
broken folio
viscid hornet
#

but that's for later

#

can you share just the file you're having issues with?

broken folio
viscid hornet
#

!traceback - and also this

unkempt canyonBOT
#
Traceback

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.

broken folio
#

can i just send you it in dms?

viscid hornet
broken folio
#

there's no issue, i just need help optimizing it

viscid hornet
#

zip it and send it to me

slate swan
broken folio
broken folio
#

the bot starts sending member avatar updates in servers right when i run it (without being ready) & also does slash-commands

slate swan
broken folio
#

i tried making the member avatar updates by setting a cooldown for each channel but, no luck

slate swan
#

don't send the full code

broken folio
#

there are like 6 slash commands & etc, idk what's causing it

#

but the bot has gone bigger and i think something is up

slate swan
fast osprey
#

"It says already ratelimited" what is "it" and what precisely is it saying

broken folio
broken folio
slate swan
# broken folio

try waiting for that period of time, also, you mentioned that your file is 2k lines big, why not use cogs? (aka separate files for each command)

broken folio
viscid hornet
#

!d discord.ext.commands.Bot.fetch_guild

unkempt canyonBOT
#

await fetch_guild(guild_id, /, *, with_counts=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Retrieves a [`Guild`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Guild) from an ID...
viscid hornet
#

@slate swan

#

you incessant little shit

slate swan
slate swan
fast osprey
#

What triggers this log? Actual resource level rate limits tell you what the resource is. This message typically happens when chunking large guilds

viscid hornet
fast osprey
#

Why is this bot generating invite links to a random channel in every guild it joins and saving that to local storage (with no user input, instruction, or consent)

#

Reeks of backdooring

hollow belfry
#

this my first time

#

im so confused

fast osprey
#

discord is not a default module installed in the standard library. You need to install it

vital yoke
#

I want to make a bot that posts a message to bunch of channels across several servers with a role ping (Basically a new bot.) Server admins can add the bot and subscribe a channel to the bot in the specified channel with the role id to ping. I'm wondering which would be better in terms of API rate limits: have the bot send the message directly or have the bot make a webhook and then use the webhook?

fast osprey
#

webhooks

vital yoke
fast osprey
#

Are you sharing that ip with someone?

vital yoke
#

Idk if it's a dedicated host or not, I assume it's shared

#

Could be wrong

fast osprey
#

It's about the ip, not the host itself

#

if randos are using the same ip, then you need to get off that host if you want your stuff to work reliably

vital yoke
#

I think it's a dedicated IP as the bot has never had issues before

fast osprey
#

Things not breaking before doesn't mean it's right

#

Just takes one idiot rando to spam discord on that ip to bring you down as well

#

The hosting service should be pretty clear about this

stark ingot
#

Is the reason announcement channels dont work is because you want the role ping?

scenic pike
#

Is possible to make custom status without activity?

stark ingot
#

Yeah, you just cant use the discord emoji field, only unicode emojis

#

How you do this might depend on the library you use

timber dragon
#

It should just be as simple as activity = discord.CustomActivity(name=...) in dpy and forks

scenic pike
#

Ty friends

slate swan
stark ingot
#

Only if they want to use discord.py, it is not the default that everyone should use.
Also btw they got there problem solved in another channel

flint quest
#

Let’s say I wanna create a discord bot but it should also save data to a DB and then I also want frontend made in JS with something like Next.js as framework and shadcn/ui as UI library because it looks nice, how would these even communicate with the discord bot?

#

I don’t want help with the code but more just a roadmap like what i need to implement e.g. if i make a file named bot.py for the bot and server.py for maybe fastapi and then how to port it to the frontend

fast osprey
#

It really depends what this front end materially does

flint quest
#

Well it’s really just for stats

#

Like the data collected with the discord bot might just be how many times a specific slash commands has been executed in the past 24 hours and then that’s gets saved to a relational db and the frontend just reads from that i guess

#

But if I have a function defined that fetches let’s say an API endpoint and checks if it is alive for like random quotes and so on, i want that functionality on the frontend to show

#

This wouldn’t be ideal with a db

fast osprey
#

what is fetching from the api? The bot, or this frontend?

flint quest
#

I’m gonna try to word it better.

A discord bot has a slash command that will monitor an API endpoint and check to see if it’s alive, let’s say it does this every 300 seconds, basically once it’s ran it should return a status or boolean indicating it’s up and I want my frontend to take use of that return value.

fast osprey
#

and why wouldn't a database work here?

flint quest
#

Though I have no idea how to access it from the frontend, maybe this value can be saved to a relational db like sqlite and then read, but this wouldn’t be ideal if there are a lot of entries I would like to believe, and with that I mean around 1000 entries a day, instead I thought of either IPC or a FastAPI server that gets access to those statuses somehow.

flint quest
# fast osprey and why wouldn't a database work here?

I’m just assuming it’s not ideal to write and read from a db every 300 seconds and sometimes it’s not exactly 300 seconds all these API endpoints may have been monitored at different times so it could read/write every 5 seconds or so

fast osprey
#

That's an insanely insignificant scale for what sqlite even handles

#

Generally I strongly recommend going with the simplest approach. If you overoptimize for scale you don't have (and don't even anticipate having), you're going to make unnecessarily heavy solutions

#

Polling a db at that scale is completely fine

sick birch
flint quest
#

Oh ok, well in that case that might just be the option, to use discord.py for the bot which is the backend and that will write results/statistics to the database and then next js for the frontend which will read the database and display them nicely on the frontend dashboard for the bot

#

FastAPI wouldn’t even be needed with this approach

sick birch
#

that way you won't have duplicated schemas on your nextjs backend and the discord bot, both accessing the database

flint quest
#

so it would be the discord bot with the slash command let’s call that file bot.py and then a fastapi app let’s call that server.py and the bot should just send a request to the fastapi endpoint that handles this and then the fastapi will store the info in the db and will also have routes for reading data with different filtering options and the next js app just requests those fastapi endpoints for reading data (or maybe also write data)

fast osprey
#

Which of those two processes does specific things is up to you. But probably the most meaningful choice here is make sure that you are running these in two separate processes

flint quest
#

yeah well i will need to run the bot, fastapi app and next js separately so i guess i should be fine

#

Honestly i’ll try my best and then ask for further help but now that I have a plan i’m gonna have to experiment a lot and do some trial and error

#

So thanks for the help, i finally have a project structure to follow.

fast osprey
#

At some scale you might want to consider message queues or sockets or something, or just to do it out of curiosity. But IMO this is a fine start and is like 99% likely to be totally functional for what you're trying to do

sick birch
thorn imp
thorn imp
thorn imp
thorn imp
blissful crane
#

they don't often have examples

fast osprey
#

It's also not clear what you're even trying to do

thorn imp
thorn imp
blissful crane
#

you don't need an example to learn how to use the function, the docs are good enough

thorn imp
scarlet tiger
thorn imp
scarlet tiger
thorn imp
scarlet tiger
scarlet tiger
scarlet tiger
#

sure

woeful hill
thorn imp
thorn imp
#

Will be very helpfull

flint quest
#

I will have to run both separately e.g.:
python bot.py
python api.py

sick birch
#

the way I'd do it is make a container for each, put them in docker-compoes and just run docker compose up

flint quest
#

So it runs directly both of them?

#

Instead of having to open two terminal windows and run them that way

flint quest
#

Yeah that sounds good

sick birch
#

you'll still want two terminal windows if you want to look at both of their logs at the same time. but if you don't it can run in the background if you use docker compose up -d

bright oasis
#

Hi everyone I have a problem with my .env file with the variable the terminal the variable cannot be found

viscid hornet
slate swan
slate swan
proud vector
frank osprey
#

ah guy quick question how to i move from py-cord to discord.py ?

is it as simple as "pip uninstall py-cord then doing dis.py ?