#discord-bots

1 messages ยท Page 1021 of 1

slate swan
#

I used to host bots in Pydroid3 :V

slate swan
slate swan
abstract kindle
#

When you guys work with users, do you store all your user data in databases?

pliant gulch
sick birch
#

store their IDs

#

easiest way tbh

abstract kindle
#

How would you use OOP

#

Currently, I have a user class, and it's methods just update the corresponding user in my database

#

But that involves creating an object every time I need to update it

sick birch
#

You're just making your own ORM at that point

abstract kindle
#

There's no way to store actual objects in a database, is there?

slate swan
sick birch
abstract kindle
#

What do you mean get all info later?

sick birch
#

Fetch or get

slate swan
#

^

abstract kindle
#

I'm talking like info as in like a balance for an economy server

sick birch
#

Just have columns for that then

abstract kindle
#

columns in the database?

slate swan
sick birch
#

yup

#

assuming you're using relational of course

abstract kindle
#

I think we misunderstand each other lol, I only store the ID's from the Member object in my database

sick birch
#

as you should, yes

slate swan
abstract kindle
#

But I have many other things in the database that are not related to discord.Member

sick birch
#

I think you're asking about how to model your data?

abstract kindle
#

The best way to work with the data through object oriented programming

sick birch
#

ORM

slate swan
#

isnt that what data models are

abstract kindle
#

I'm still a beginner to coding so I apologize if I sound like an idiot

sick birch
#

No no, you've come to the same conclusion many people have

#

Which is why ORMs exist

abstract kindle
#
class User:
    def __init__(self, bot, user_id: int, name: str, role: ERole):
        self.bot = bot
        self.user_id = user_id
        self.name = name
        self.in_game = False
        self.isBot = False
        self.role = role
#

I have this class here, and I create objects by grabbing the corresponding info from the database

sick birch
#

That's EXACTLY what an ORM does. You just made your own little ORM, congrats! ๐ŸŽ‰

abstract kindle
#

Oh

#

Here's a class method

 async def update_balance(self, amount):
        await self.bot.db.update_one({"_id": self.user_id}, {"$inc": {"money": amount}})
sick birch
#

Ah, NoSQL database?

abstract kindle
#

MongoDB

sick birch
#

Thought so

#

I'd suggest you look into something like SQLAlchemy

abstract kindle
#

So would this be the best way to do it? I'm basically wondering if its best to create a User object every time a command is run

sick birch
#

Probably not

#

It's quite inefficient

abstract kindle
#

Alternatives?

sick birch
#

You could go for functional

#

Just methods to perform CRUD ops on your database, no dealing w/ classes or object models

abstract kindle
#

I see...

#

So just have a method that takes the id and then updates / reads from there?

sick birch
#

Sure, sound simple enough

abstract kindle
#

Is the only difference the fact that no objects would be created

sick birch
#

Right

abstract kindle
#

Ah, but if I'm using those methods in many different cogs, I would have to import them over to each, correct?

sick birch
#

Yes, but that's not inefficient in the way that it may take up memory

abstract kindle
#

I see

#

could just store them all in 1 file and from file import *

#

Interesting. I'm basically planning to rewrite my bot this summer, but I want to make sure I do it efficiently, cause coding big projects while still learning can get messy

sick birch
#

it can be useful to sketch out a blueprint on a physical paper

#

That's not something we do much anymore, but it helps me a lot

abstract kindle
#

Same here though, visualization is great

#

I wonder. So I have a class called ERole which is basically used to setup embeds for when the user works.
I also have subclasses of ERole for the different level of role which will determine their wage.

class ERole:
    def __init__(self, name, wage, work_dialogue, emoji, price, description):
        self.name = name
        self.wage = wage
        self.dialogue = work_dialogue
        self.emoji = emoji
        self.price = price
        self.description = description


class Peasant(ERole):
    def __init__(self):
        description = "Born into the lower class, destined for the upper class."
        super().__init__("Peasant", 2500, self.peasant_work(), ":palms_up_together:", 0, description)
        self.perms = None
        self.raw_perks = None

    @staticmethod
    def peasant_work():
        responses = ["You actually manage to scrape up some bits. How wonderful.",
                     "Someone donated a little more than normal. How kind.",
                     "You are a peasant. Feel bad."]
        return random.choice(responses)

Is it efficient to create many subclasses like this when they all have the same class_work() methods?

#

Could I just store these levels of ERole in a dictionary and just have one class to take care of it all?

sick birch
#

This is a common design pattern

abstract kindle
#

Mine, or the dictionary thing?

sick birch
#

Usually in languages where it's supported, you'd use abstract classes or interfaces

sick birch
#

I can't testify to it's efficiency, I can, however tell you that it's a common design pattern you see a lot

abstract kindle
#

Well I'm on the right track I guess. It just takes up quite a few lines of code where it seems like it could be simplfied

sick birch
#

If you want to learn more about common design patterns and how to implement them, I'd suggest you give the book "Design Patterns Elements of Reusable Object-Oriented Software" a read

stone beacon
#

Since that's all you need

abstract kindle
#

Read more below. Also nice pfp, that's literally my wall paper rn

#

I'm storing other things like a balance and cooldowns

#

Not just discord.Member attributes

stone beacon
sick birch
abstract kindle
#

It currently looks something like this. How many columns is usual? I'm planning on adding many many things for each user, and I don't want to have so many columns that it gets messy

sick birch
abstract kindle
#

One way I've thought of is having another collection for each category of thing. For example, for users Farming, I have a farming collection, and I might have a separate collection for mining etc.

#

Lol

sick birch
#

It also seems like you have discord-related data in there like "isBot" and "name" which you can obtain from the ID

abstract kindle
#

I'm doing exactly what you suggest, once I look it up I realize I'm doing it.
I have another table where a shared column is their id

#

the name is primarily so I can edit user data in the database without having to cross check ID's

#

because that would be a huge pain lol

sick birch
abstract kindle
#

I frequently change things though, since I'm still developing it. Although I suppose I could just copy ID's and filter through the DB by that ID

#

OH MY! If I used table joins, does that mean I wouldn't have to do this thing??

#
    async def hook():
        bot.mongo_client = AsyncIOMotorClient(data['mongo_url'])
        bot.db = bot.mongo_client['discordbot']['users']
        bot.dbpets = bot.mongo_client['discordbot']['pets']
        bot.dbfarms = bot.mongo_client['discordbot']['farms']
sick birch
#

I uh, don't know if NoSQL databases have joins

#

As that's really only a feature of relational databases

abstract kindle
#

I see. What I have works, so that's enough

#

Okay, I'm off to bed. See yall later

sick birch
#

Yup

#

night

jade tartan
#
@commands.has_role("Admin") # This must be exactly the name of the appropriate role
async def addrole(ctx):
    member = ctx.message.author
    role = get(member.guild.roles, name="Verified Male")
    role = get(member.guild.roles, name="[M] 18+ Verified")
    role = get(member.guild.roles, name="Verified Female")
    role = get(member.guild.roles, name="[F] 18+ Verified")
    await member.add_roles(role)``` when i mention the role to give to the user it gives a different role
#

So how do i make it give the right mentioned role?

slate swan
#

Use \n in the description field for a new line

and for this, put > before the text

And please, be original and don't copy other bots NotLikeThis

jade tartan
#

Yeah you might definitely get nuked

slate swan
alpine pewter
#
    @nextcord.slash_command(guild_ids=guild_ids)
    async def ark_ban(self, interaction : Interaction, gamertag : str = SlashOption(description="Enter the user's gamertag.")):
        server_ids = [1065, 1051, 1048, 1040, 1047, 104, 1047, 104, 10456, 10470, 1042, 1049, 1059, 1050]
        if (not interaction.user.guild_permissions.administrator):
            embed = nextcord.Embed(title="`โŒ` `System Exception Error!`", description="**Exception Error, Checklist:**\nEnsure user permissions are met.\nCheck the API's current status.", color=3066993)
            embed.set_thumbnail(url = "https://i.imgur.com/FmzHoKr.png")
            await interaction.send(embed=embed, ephemeral=False)
            return

        else:
            headers = {"Authorization" : key.nitrado_key}
            params = { "identifier" : gamertag}
            async with aiohttp.ClientSession() as session:
                for id in server_ids:
                    url = f"https://api.nitrado.net/services/{id}/gameservers/games/banlist"
                    response = await (await session.post(url, headers=headers, params=params)).json()
                    print(response)
                    
                embed = nextcord.Embed(description=f"**`>`** **`โœ… - System Success:`**\nThe user have been banned!\nResponse: `({gamertag})`", color=3066993)
                await interaction.response.send_message(embed=embed, ephemeral=False)

Can someone help with this? The command works fine -
Whenever I use it, it takes about 5s-10s to get through the for-loop. Though before it finishes, it tries to send the embed at the end. It turns out being...
"The application did not respond"

#

Would I use a defer() or how should I go about it?

jade tartan
#
@commands.has_role("Admin") # This must be exactly the name of the appropriate role
async def addrole(ctx):
    member = ctx.message.author
    role = get(member.guild.roles, name="Verified Male")
    role = get(member.guild.roles, name="[M] 18+ Verified")
    role = get(member.guild.roles, name="Verified Female")
    role = get(member.guild.roles, name="[F] 18+ Verified")
    await member.add_roles(role)``` when i mention the role to give to the user it gives a different role
slate swan
alpine pewter
# jade tartan Errors?

Right, sorry.
[Bot] nextcord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction

#

I believe it's bec it responds before the loop is complete, not sure if that's right

stone beacon
#

Try defering

slate swan
#

Then you can add_role(role)

alpine pewter
stone beacon
#

interaction.response.defer()

alpine pewter
#

Right under the async def ark_ban ?

stone beacon
#

Cuz discord kills the entire process after like 4 seconds of your bot not responding

stone beacon
alpine pewter
#

Okay, wasn't sure if it was to go somewhere else

jade tartan
#

ok one more is it await ctx.remove_roles(role) to remove a role from the user?

#

as well as define ctx

slate swan
#

nope

#

Definitely not on ctx

#

On ctx.author, yes.

jade tartan
#

so await member.remove_roles(role)

slate swan
#

Or define a member

stone beacon
jade tartan
slate swan
#

Yep

jade tartan
#

wow i know alot of stuff

#

cool

stone beacon
#

Congrats

alpine pewter
# stone beacon yh lemme know if it works
03.05 05:34:07 [Bot] File "/The Hideout (Development)/Source/nitrado.py", line 38, in ark_ban
03.05 05:34:07 [Bot] await interaction.response.send_message(embed=embed, ephemeral=False)
03.05 05:34:07 [Bot] File "/.local/lib/python3.9/site-packages/nextcord/interactions.py", line 679, in send_message
03.05 05:34:07 [Bot] raise InteractionResponded(self._parent)
03.05 05:34:08 [Bot] nextcord.errors.InteractionResponded: This interaction has already been responded to before
#

Would I need to put a followup at the end?

stone beacon
#

interaction.followup() should return the webhook yes

#

and you can .send() on the webhook

alpine pewter
#

So, just put await interaction.followup.send() at the end?

stone beacon
#

In theory

alpine pewter
stone beacon
#

Poor dinosaurs gonna go on a rampage without their master

slate swan
#

hi can anyone give me a example of how to use Select ui ?

#
@commands.command(name="help")
async def help(ctx):
    embed = discord.Embed(color=000000, title="VENOX ANTI-NUKEโ„ข")
    embed.set_footer(text=f"Venox anti-nukeโ„ข   | Ping {int(round(client.latency * 1000))}ms!")
    embed = discord.Embed(
      title=" | Help, Prefix:_",
      description="testing"
    )
    embed.add_field(name=f"**misc**", value="")
    embed.add_field(name=f"**security**", value="")
    embed.add_field(name=f"**commands**", value="")
    
    msg = await ctx.send(embed=embed)
``` is this correct?
#

try it?

#

yes

#

bot is saying command not found

#

did u removed the default help command?

#

nope

#

then remove

#

in ur bot instance

#

help_command = False

slate swan
#

show ?

#

what?

#

where u did

#

do help_command = None

#

(command_prefix=prefix, intents=intents,help_command=None)

#

like this

#

or do

#

bot.remove_command("help")

slate swan
slate swan
#

also

slate swan
slate swan
slate swan
slate swan
stray carbon
#
import nextcord
from nextcord import slash_command
from nextcord.ext import commands

class C(commands.Cog):
    def __init__(self, bot: commands.Bot):
        self.bot = bot

    @slash_command(guild_ids=[927234027277135923], description="Test command")
    async def my_slash_command(self, interaction: nextcord.Interaction):
        await interaction.response.send_message("This is a slash command in a cog!")
        
def setup(bot):
    bot.add_cog(C(bot))

slash cmd not showing

stone beacon
#

Make sure the guild Id is correct and your bot can use application commands in the discord developer portal

#

Although idr if the last one is needed

stray carbon
#

from nextcord.ext import commands

slate swan
stray carbon
#

for commands.Cog?

stone beacon
#

Good

slate swan
#

You need to invite the bot correctly with the right scope, that's it

#

Nothing to do with the developer portal

stray carbon
#

i invited with applications.commands scope

#

+it was able to make slash cmds when i was using dpy with same bot

#

not working with nextcord

#

do we need to sync here too?

stone beacon
#

That is automatically done

#

U sure the guild ID is correct?

#

If so then idk

stray carbon
#

oof

loud junco
#

why is this not working

#

oof

quaint epoch
#

do embed.add_field(name='Ends at:', value=f'{discord.utils.format_dt(datetime)}')

stray carbon
# stone beacon That is automatically done

Warning (from warnings module):
File "C:\Users\Akai\AppData\Local\Programs\Python\Python38\lib\site-packages\nextcord\health_check.py", line 20
warn(message, DistributionWarning, stacklevel=0)
DistributionWarning: discord.py is installed which is incompatible with nextcord. Please remove this library by using pip3 uninstall discord.py

This couldnt be this reason right?

quaint epoch
#

also you made a typo, it's minutes, not mintues

stray carbon
#

i dont want to uninstall yet

loud junco
# loud junco

this thing can only read " " instead of ' ' and " "

#

bruh

quaint epoch
#

time to make an embed command!

slate swan
#
@client.command()
async def help(ctx):
    embed = discord.Embed(color=000000, title="VENOX ANTI-NUKE:tm:")
    embed.set_footer(text=f"Venox anti-nuke:tm:   | Ping {int(round(client.latency * 1000))}ms!")
    embed = discord.Embed(
      title=" | Help, Prefix:_",
      description=" | help" \n
                  " invite"   
    )
    
    embed.add_field(name=f"_misc", value="Shows the command related to bot")
    embed.add_field(name=f"_security", value="Shows The Bot Features")

    
    msg = await ctx.send(embed=embed)

``` is this correct according to the screenshot?
#

use \n to change lines

#

where?

#

!e print("changed\nLine")

unkempt canyonBOT
#

@slate swan :white_check_mark: Your eval job has completed with return code 0.

001 | changed
002 | Line
slate swan
#

?

strong vessel
#

discord bot invite link with permission set to 0 (no permissions) it will still be able to read and send message, is there any purpose putting the permission in the invite link? Since it adds the additional step on inviting when there is nonzero permission?

viscid wren
#
RuntimeWarning: coroutine 'BotBase.load_extension' was never awaited
  bot.load_extension(f'cogs.{filename[:-3]}')
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
#

help?

slate swan
#

await it

slate swan
#

i dont know

#

ok

loud junco
#

what does re stands for here

#

in the user = re.sub(blahblah)

slate swan
loud junco
#

oo

#

is it necessary?

#

or can i do it without re

slate swan
# loud junco or can i do it without re

you can do it, its just a better way to use regex (regular expression) here since you want the id of the mentioned user otherwise you'd have to do a lot of stuff instead, but you need to have an understanding of how it happens

loud junco
#

i already have many things imported

#

idw to let my bot explode

spring flax
#

for checking errors in an isinstance, like if isinstance(error, commands.NotFound). how can I pass several errors at once to do the same thing?

loud junco
#

i think

visual island
paper sluice
#

Just. Learn some basics of regex, it's very useful when u have to clean some data before using it

paper sluice
#

There are vids on yet

loud junco
#

idk whats that

paper sluice
#

Yt*

loud junco
#

imma just stick to traditional method

#

whats the full import name

#

import regex? @paper sluice

viscid wren
#

Someone can give an example of a bot and cog setup for the new discord version

visual island
viscid wren
#

?

#

its ""

loud junco
#

' ' will still work

#

i prefer ' '

#

but most people prefer " "

visual island
#

!d datetime.datetime.strftime | You can use this to format the datetime object, take a look at https://strftime.org/ this cheat sheet for the supported format.

unkempt canyonBOT
#

datetime.strftime(format)```
Return a string representing the date and time, controlled by an explicit format string. For a complete list of formatting directives, see [strftime() and strptime() Behavior](https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior).
supple thorn
#

And awaiting your load_extension

loud junco
#

help ;-;

nimble plume
#

hi im class and i want to await something how can i

loud junco
#
@bot.event
async def on_message(message) :
  if message.channel.id == 970895283250675813 : 
    data = message.content.split(" ")
    user = re.sub("\D", "", data[4])
    print(user)
    userid = bot.get_user(str(user)) or await bot.fetch_user(str(user))# Call the method to add it to database or something

    db[userid + 'cooked_pogchop'] = db[userid + 'cooked_pogchop'] + 50
        # Do anything else here that you want to do
    
    await bot.process_commands(message) 
unkempt canyonBOT
#

Concurrency in Python

Python provides the ability to run multiple tasks and coroutines simultaneously with the use of the asyncio library, which is included in the Python standard library.

This works by running these coroutines in an event loop, where the context of the running coroutine switches periodically to allow all other coroutines to run, thus giving the appearance of running at the same time. This is different to using threads or processes in that all code runs in the main process and thread, although it is possible to run coroutines in other threads.

To call an async function we can either await it, or run it in an event loop which we get from asyncio.

To create a coroutine that can be used with asyncio we need to define a function using the async keyword:

async def main():
    await something_awaitable()

Which means we can call await something_awaitable() directly from within the function. If this were a non-async function, it would raise the exception SyntaxError: 'await' outside async function

To run the top level async function from outside the event loop we need to use asyncio.run(), like this:

import asyncio

async def main():
    await something_awaitable()

asyncio.run(main())

Note that in the asyncio.run(), where we appear to be calling main(), this does not execute the code in main. Rather, it creates and returns a new coroutine object (i.e main() is not main()) which is then handled and run by the event loop via asyncio.run().

To learn more about asyncio and its use, see the asyncio documentation.

loud junco
nimble plume
supple thorn
#

Your spacing triggers me

loud junco
#

yes

supple thorn
nimble plume
#

how can i await there

#

should i async __init__

supple thorn
nimble plume
#

then

supple thorn
#

Why do you have a bot and s arguments in that init

nimble plume
#

i want to fetch a channel

#

thats why i need await

#

@supple thorn

slate swan
nimble plume
#

o my god

#

what the heck is that

nimble plume
slate swan
#

what's wrong with ctx?

nimble plume
#

ur whole code is wrong

slate swan
#

ok

supple thorn
# loud junco

You're indexing higher than what's inside the list

nimble plume
#

Cokecan/pepsi help me pls

supple thorn
#

Cokecan

slate swan
#

where can i learn cogs?

nimble plume
#

google

#

@supple thorn pls help

supple thorn
supple thorn
#

Help him

supple thorn
nimble plume
#

Several people help me

loud junco
#

ya

nimble plume
#

cokecane said

#

to help me

loud junco
#

several people go help him

#

one is not enough

nimble plume
#

๐Ÿ˜ฆ help me

loud junco
#

lol what help do u need

nimble plume
#

@loud junco @alpine notch help me

nimble plume
#

@loud junco

loud junco
#

but

#

why do u wanna await in a class

#

u wanna make a command or what

nimble plume
#

i want to fetch

loud junco
#

fetch what

slate swan
#

ping pong

nimble plume
#

pls help

loud junco
nimble plume
#

i wanto to fetch channel

loud junco
#

fetch channel???

nimble plume
#

or msg

loud junco
#

channel id or what

slate swan
nimble plume
#

get_channel().fetch_message()

loud junco
#

=.=

nimble plume
#

this is corocan

loud junco
nimble plume
#

i need it await

loud junco
nimble plume
#

pls help

nimble plume
loud junco
#

oo

slate swan
#

coroutine*

loud junco
#

async ur class?

nimble plume
#

how

loud junco
#

async class URCLASS

slate swan
#

and what are you trying to do

nimble plume
loud junco
#

he is struggling to async and await

slate swan
loud junco
#

struggles to async and await but wants to hack nasa

loud junco
nimble plume
#

i already hacked with html

#

now im doing with python

loud junco
#

ok enough of trash talk

#

get back to work

nimble plume
#

ok

#

how can i async a class

loud junco
#

add async infront

slate swan
#

nu

loud junco
#

๐Ÿคฃ

nimble plume
#

async int(Newbie007):

loud junco
#

huh

nimble plume
#

ok

slate swan
#

newbie, what are you even trying to do ๐Ÿ˜‘

nimble plume
#

await

loud junco
#

he is trying to fetch msg or channel

#

and idk what is he saying

slate swan
#

what in the world is the significance of a class there?

loud junco
#

:/

paper sluice
#

i opened the chat and the first thing i see is async init, wow

nimble plume
#

async on Class Newie(Newbie007):
@loud junco like this

loud junco
#

go back to ur chemistry exam study HEHEHEEH

nimble plume
#

then Class async on Newbie(007)

paper sluice
nimble plume
paper sluice
#

what does it do?

nimble plume
#

takes my brain cells

paper sluice
#

aight, im leaving earth, bye guys

loud junco
#

!d async

unkempt canyonBOT
#

8.9. Coroutines

New in version 3.5.

nimble plume
#

why should we use async

loud junco
nimble plume
#

why?

loud junco
#

but u dont even know what it is

nimble plume
loud junco
#

then use it

#

๐Ÿ‘

nimble plume
#

then it show error tob and something was never awaited

#

and Enable tobac prefrs nfor enabvle suck sdjg

#

like that

loud junco
#

Asynchronous programming is a technique that enables your program to start a potentially long-running task, and then rather than having to wait until that task has finished, to be able to continue to be responsive to other events while the task runs.

nimble plume
#

wow ur 1000 wps

#

python is very very very hard

loud junco
#

nola
u go try javascript

#

:/

nimble plume
#

javascript is easy

loud junco
#

wow i started from javascript

nimble plume
#

i have created many bots with it

#

like 100

loud junco
#

wow

#

100 hello bot?

nimble plume
#

no

#

100 bot with 1 cmd

loud junco
#

shessssh

nimble plume
#

like 1 for ban

loud junco
#

1 for ban

nimble plume
#

1 for kick

loud junco
#

1 for ban

nimble plume
#

yes

slate swan
#

Command raised an exception: NameError: name 'urllib' is not defined

supple thorn
slate swan
#

this chat never makes sense

loud junco
nimble plume
nimble plume
#

5 alts

slate swan
loud junco
#

HWHAWHWAHAW

loud junco
nimble plume
#

no

slate swan
slate swan
# loud junco noice problem solved
@client.command()
async def meme(ctx):
     memeApi = urllib.request.urlopen('https://meme-api.herokuapp.com/gimme')

     memeData  = json.load(memeApi)

     memeUrl = memeData['url']
     memeName = memeData['title']
     

     embed = discord.Embed(title=memeName)
     embed.set_image(url=memeUrl)
     await ctx.send(embed=embed)
nimble plume
slate swan
#

and its blocking, use aiohttp instead

supple thorn
nimble plume
#

aiohttps

slate swan
supple thorn
#

Left it all for sarth when he came

supple thorn
unkempt canyonBOT
nimble plume
supple thorn
#

There's no s

nimble plume
#

i dont have server sorry its a server framework

slate swan
slate swan
nimble plume
#

go then eat nuts

loud junco
#

deez nuts

slate swan
nimble plume
slate swan
nimble plume
#

invalid syntax

supple thorn
#

!rule 8

unkempt canyonBOT
#

8. Do not help with ongoing exams. When helping with homework, help people learn how to do the assignment without doing it for them.

nimble plume
slate swan
#

?

nimble plume
#

now help me

slate swan
unkempt canyonBOT
#

@slate swan :warning: Your eval job has completed with return code 0.

[No output]
nimble plume
#

see invalid syntax

supple thorn
nimble plume
#

[no output]

slate swan
#

seriously learn things first before suggesting something you dont know about

nimble plume
#

im Newbie007 that was trolling u all

#

since i comed in the chat

slate swan
#

Hi

#

welcome back sparky

#

๐Ÿ‘‹

slate swan
#

Clash royal

loud junco
#

e

slate swan
#

!ot

unkempt canyonBOT
slate swan
#

how to quickly translate large text into another block?

#

!d str.split

#

split and send them seperately

#

nvm that wont work

tropic flame
#

seggs

supple thorn
jade tartan
#
    async with aiofiles.open("ticket_configs.txt", mode="a") as temp:
        pass

    async with aiofiles.open("ticket_configs.txt", mode="r") as file:
        lines = await file.readlines()
        for line in lines:
            data = line.split(" ")
            client.ticket_configs[int(data[0])] = [int(data[1]), int(data[2]), int(data[3])]
supple thorn
jade tartan
#
    async with aiofiles.open("ticket_configs.txt", mode="a") as temp:
IndentationError: unexpected indent```
unkempt canyonBOT
#

Indentation

Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.

Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.

Example

def foo():
    bar = 'baz'  # indented one level
    if bar == 'baz':
        print('ham')  # indented two levels
    return bar  # indented one level

The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.

Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines

More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation

slate swan
jade tartan
#

I tried every indentation it doesnt work

slate swan
#

!e py a = "a long stringgg" first_5_chars = a[:5] print(first_5_chars)

unkempt canyonBOT
#

@slate swan :white_check_mark: Your eval job has completed with return code 0.

a lon
slate swan
#

like this

supple thorn
tropic flame
supple thorn
#

The context manager is indented for no reason

jade tartan
#

because there is not indentation error for it

supple thorn
jade tartan
#

Ig thats wrong still

#
            async with aiofiles.open("ticket_configs.txt", mode="a") as temp:
                pass

            async with aiofiles.open("ticket_configs.txt", mode="r") as file:
            lines = await file.readlines()
            for line in lines:
                data = line.split(" ")
            client.ticket_configs[int(data[0])] = [int(data[1]), int(data[2]), int(data[3])]
#

Hello

nimble plume
#

Hi

#

I'm newbie0007 ill help you

jade tartan
#

OK am not sure where the indentation for this code goes

#

I have tried so many ways

jade tartan
slate swan
#

Alright, I'm creating a bot, but for some reason not all of my slash commands load in. All of the commands who looks like this loads in:py @slash_command(guild_ids = ids) async def add_autorole(self, ctx): but when it looks like this it doesn't load in: ```py
@slash_command(guild_ids = ids)
async def remove_autorole(self, ctx, role: discord.Option(discord.Role, "Choose a role.")):

nimble plume
#

hi how can i async a class pls help

supple thorn
#

๐Ÿ—ฟ

#

Wait is it named discord.Option?

slate swan
nimble plume
#

hi how can i async a class pls help

slate swan
supple thorn
slate swan
#

They don't have pycord in their docs

supple thorn
#

Sad

paper sluice
supple thorn
#

Hi ryuga

paper sluice
#

๐Ÿ‘‹

nimble plume
nimble plume
#

several people

paper sluice
nimble plume
#

i got wrong help

#

from several people

nimble plume
slate swan
paper sluice
#

ehh? async contextmanger?

nimble plume
#

can i do like

class Newbbie007():
    def __init__(self,bot : commands.Bot,s : commands.Context):
        self.bot = bot
        async def dis():
paper sluice
#

yes, but why would u want to do that?

nimble plume
#

why not?

nimble plume
paper sluice
#

fetch what?

nimble plume
#

channel

paper sluice
#

huh? can u explain what ur trying to do?

nimble plume
#

no

slate swan
#

the accuracy ๐Ÿ˜”

visual island
# nimble plume hi how can i async a class pls help

I don't really suggest this but:

class Foo:
    async def __init__(self):
         # now you can await stuff here

    async def __new__(cls, *args, **kwargs):
         self = super().__new__(cls)
         await self.__init__()
         return self

Or if you mean "trying to await something outside async function", then you can use asyncio.run(async_func()) or if there's a running event loop already, you can use loop.create_task(async_func()).

paper sluice
slate swan
#

lmao

nimble plume
#

2.69

supple thorn
#

He's trying to fetch a channel

supple thorn
#

Also a message

paper sluice
#

๐Ÿ‘€

#

but why an async method inside init?

slate swan
#

you cant use them inside init function of a class

#

iirc

nimble plume
#

what do i do

#

i want to await inside init

slate swan
nimble plume
#

i want to fetch

#

channel

#

@slate swan

slate swan
#

oh wait lmao, i did

#

i printed the function

nimble plume
#

lol

slate swan
#

but nvm, async init errors out

nimble plume
#

so

#

what do i do

slate swan
slate swan
nimble plume
#

yes

slate swan
#

or a class?

nimble plume
#

im subclassing'

slate swan
nimble plume
#

i have

slate swan
nimble plume
#

await

slate swan
#

owo

paper sluice
# slate swan

!e

import asyncio

def bar():
    print('lol')
    
    
class Foo:
    async def __init__(self):
        return bar()

    async def __new__(cls, *args, **kwargs):
         self = super().__new__(cls)
         await self.__init__()
         return self
    
asyncio.run(Foo())

unkempt canyonBOT
#

@paper sluice :white_check_mark: Your eval job has completed with return code 0.

lol
slate swan
nimble plume
#

yes

slate swan
#

ashleyyyy

nimble plume
slate swan
#

on ready event

#

no

#

then what is startup?

#

๐Ÿ’€

slate swan
nimble plume
#

but i want to fetch channel when i call the class

slate swan
#

when the bot starts, not readies up

#

then on_connect ig

slate swan
nimble plume
#

i want

slate swan
#

Why

paper sluice
nimble plume
#

pls help

#

how do i await inside __init__

slate swan
#

uk.. how about to make an async function then create task in init? @nimble plume

nimble plume
#

i maked another async function insidide the init

slate swan
#

i mean.. this is about subclassing bot class, right?

slate swan
#

just confirming

#

ooo i see

nimble plume
#

ok so ill

#

def __init___(self): async def newbie007():

slate swan
#

either way i suggest

#

make an async function in that class

placid skiff
#

WTF am i readin

nimble plume
slate swan
#

lmao

supple thorn
slate swan
#

me who got brain damaged at this point

nimble plume
#

duck dont copy me

slate swan
#

wait this is confusign me wtf

paper sluice
unkempt canyonBOT
#

@paper sluice :white_check_mark: Your eval job has completed with return code 0.

lol
nimble plume
slate swan
#

LMAO

nimble plume
#

ill make a while a ==1
and then it will run an aync function

#

ill change a to 1 in my class

#

and it will work fine

supple thorn
nimble plume
#

!e
async def bar():
print('lol')

class Foo:
async def init(self):
await bar()

async def __new__(cls, *args, **kwargs):
     self = super().__new__(cls)
     await self.__init__()
     return self
unkempt canyonBOT
#

@nimble plume :warning: Your eval job has completed with return code 0.

[No output]
nimble plume
#

i got brain damage

placid skiff
slate swan
nimble plume
#

Ryuga pro

placid skiff
#

expecially i'm trying to understanding what the hell of use this should have

maiden fable
#

I am not thinking that

slate swan
#

lmao

paper sluice
maiden fable
#

I'm thinking HOW tf did he make the new and init async without any errors

nimble plume
#

hi how can i await inside __init__

placid skiff
placid skiff
#

i never saw an async __init__

nimble plume
#

help what do i do

heavy folio
#

i dont think __init__ can be async

#

what are you trying to do?

nimble plume
heavy folio
#

but why?

placid skiff
#

and i would've never thought that someone would use an async __init__

nimble plume
placid skiff
nimble plume
#

concultion?

#

NOTHING

#

i didnt get help

paper sluice
nimble plume
#

i cant understand

heavy folio
paper sluice
#

im not even gonna "not recommend" this

nimble plume
#

then

#

what do i do

paper sluice
nimble plume
#

ill delete my python file

paper sluice
#

ยฏ_(ใƒ„)_/ยฏ

nimble plume
#

nobody helping me

nimble plume
#

ill simply put that async in my cmd and then pass the message object

slate swan
#

how to make it not stand out?

paper sluice
#

what ๐Ÿ˜ณ

slate swan
paper sluice
#

u dont want it in bold?

slate swan
#

yea

paper sluice
#

put it in the description of the embed

slate swan
#

the translator works poorly

nimble plume
#

im still stuck

#

pls help

heavy folio
slate swan
paper sluice
slate swan
#

i need it to be in one line, can i leave out the title value?

paper sluice
#

i think u can

#

try it out

nimble plume
#

๐Ÿ˜ฆ

slate swan
#

wait

#

yes

#

it work

#

thx

#

Guys, I forgot, how to run the bot in terminal, I just remember only old way

python3 discord-bot.py

of course it says an error, please say to me, correct command which must I write in the terminal

I installed this in the cmd before all commands:

pip install discord.py
heavy folio
#

what's the error

slate swan
#

um im not sure what to do
i want like it create options according to list

ids = [1,2,3,4,5]           disnake.SelectOption(label=,description='Nothing', emoji='๐ŸŸฉ')
paper sluice
#
for label in ids:
    view.app_option(disnake.SelectOption(label=label,description='Nothing', emoji='๐ŸŸฉ'))
slate swan
#

ye i did that

#

but its inside []

paper sluice
#

no its add_item, not option

slate swan
#

options = [
]

#

how to make it so that if the user is not muted, it will write "user is not muted"

#
# unmute
    @commands.command()
    @commands.has_permissions(manage_messages=True, administrator=True)
    async def unmute(self, ctx, member: discord.Member):
        emb = discord.Embed(description=f":white_check_mark:Member **{member.name}** has been unmuted, have a nice chat!", colour = discord.Color.gold())
        embed=discord.Embed(title =f"You were unmuted on the server {ctx.guild.name}")
        mutedRole = discord.utils.get(ctx.guild.roles, name = "muted")
        await member.remove_roles(mutedRole)
        await ctx.reply(embed=emb)
        await member.send(embed=embed)```
upbeat gust
paper sluice
#

@slate swan are u subclassing view?

wanton veldt
#
async def make_embed(ctx):
    def check(message):
        return message.author == ctx.author and message.channel == ctx.channel

    await ctx.send('Waiting for a title')
    title = await client.wait_for('message', check=check)
  
    await ctx.send('Waiting for a description')
    desc = await client.wait_for('message', check=check)

    await ctx.send('Waiting for a image(URL ONLY: https://i.imgur.com/...)')
    img = await client.wait_for('message', check=check)

    embed = discord.Embed(title=title.content, description=desc.content, color=0x72d345)
    embed.set_thumbnail(url=img)
    await ctx.send(embed=embd)```
#

can someone test this code for me?

slate swan
paper sluice
upbeat gust
slate swan
#

thx

wanton veldt
#

i m at school rn and i was doing that

vale wing
#

Workdir is probably incorrect

#

And what error does it give

slate swan
#

python3 : The name "python3" is not recognized as the name of a cmdlet, function, script file, or executable. Check the spelling of the name
, as well as the presence and correctness of the path, and then try again.
string:1 character:1

  • python3 discord-bot.py
  •    + CategoryInfo : ObjectNotFound: (python3:String) [], CommandNotFoundException
       + FullyQualifiedErrorId : CommandNotFoundException
#

This error

#

try using py since windows usually has that namespace

vale wing
#

Try py and python

slate swan
#

py3? or py

#

py

#

ok

vale wing
#

If doesn't work you didn't add python to path

#

It's done on setup or via editing some system stuff which idk about

vale wing
slate swan
#

did you see my error?

vale wing
slate swan
#

external library

#

did you install discord-py-slash-commands

vale wing
#

But seems like you managed to launch it

vale wing
#

!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 floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

slate swan
#

well you gotta install it first to use it..

vale wing
#

Put your traceback to there

slate swan
#

???

#

No error

vale wing
slate swan
#

please

#

but... it's very important.

#

I need slash commands

slate swan
#

it saod

vale wing
#

I don't recommend this library for slash commands

slate swan
#

ERROR: Could not find a version that satisfies the requirement discord-py-slash-commands (from versions: none)
ERROR: No matching distribution found for discord-py-slash-commands

#

^

vale wing
#

Use dpy 2.0 or fork like disnake

#

The implementation of slash commands in disnake is pretty easy, here's example of non cog implementation

import disnake
from disnake.ext import commands

bot = commands.Bot(intents=disnake.Intents.all())

@bot.slash_command()
async def hi(inter: disnake.ApplicationCommandInteraction):
    await inter.send(f"Hi {inter.author.mention}")

bot.run("token")```
slate swan
#

how do i write the name of the person who sent the message?

vale wing
unkempt canyonBOT
vale wing
#

!d discord.ext.commands.Context.author

unkempt canyonBOT
slate swan
#

thx

slate swan
#

where error?I write 1 command, and it sends an attachment to infinity in private messages and chat

#
# mute
    @commands.command()
    @commands.has_permissions(manage_messages=True)
    async def mute(self, ctx, member: discord.Member, *, reason = "No reason provided"):
        guild = ctx.guild
        mutedRole = discord.utils.get(guild.roles, name="muted")
        emb = discord.Embed(description=f":white_check_mark:Member {member.name} has been muted!:bee:", colour = discord.Color.gold())
        emb.add_field(name="Moderator:", value=f"{ctx.author.mention}")
        embed = discord.Embed(title=f"You were muted on the server {ctx.guild.name}", description =f"Reason:{reason}", colour=discord.Color.gold())
        if not mutedRole:
            mutedRole = await guild.create_role(name="muted")
        for channel in guild.channels:
            await channel.set_permissions(mutedRole, speak=False, send_messages=False, read_message_history=True, read_messages=True)
            await member.add_roles(mutedRole, reason=reason)
            await member.send(embed=embed)
            await ctx.reply(embed=emb)```
supple thorn
#

You're looping through all of the guild's channel then sending the embed in dms for every channel

#

Why do you have a for loop

quaint epoch
unkempt canyonBOT
#

await timeout(until, /, *, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Applies a time out to a member until the specified date time or for the
given [`datetime.timedelta`](https://docs.python.org/3/library/datetime.html#datetime.timedelta "(in Python v3.10)").

You must have the [`moderate_members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.moderate_members "discord.Permissions.moderate_members") permission to
use this...
quaint epoch
#

use this instead

slate swan
#

what if my bot has a big delay?

#

add_role and timeout has the same endpoint so that won't matter

#

if you mean the request delay

maiden fable
#

Uh, anyone here who got nitro? Not the classic one

#

I want to test if on_member_update is fired when someone changes the guild pfp

slate swan
quaint epoch
#

define invisible users

#

you mean lurkers? like hunter right now?

#

๐Ÿ‘€ i c u

#

kek, how

#

alr

#

but then how

#

๐Ÿ‘€

#

i refuse to believe this

maiden fable
quaint epoch
#

presence updates?

#

member updates? USER UPDATES? what is it?

#

i don't wanna play hot and cold

#

๐Ÿ”ซ tell me rn

#

kek

#

i will figure it out

#

kek

#

hmm

#

69

vocal plover
#

I knew someone would say 69 lol

quaint epoch
vocal plover
#

I was very tempted myself tbh

#

idk what you're doing but I guarantee that is not the best way lemon_scared

quaint epoch
#

cya

loud junco
#

so many (((()))))

quaint epoch
loud junco
quaint epoch
#

and_hurt_you()

slate swan
#

the urge of running the !ot cmd

slate swan
quaint epoch
#

imma make a >is_lurking <member> command

supple thorn
#

We must find the secrets

quaint epoch
#

is gonna be useful, aboo ๐Ÿ‘€

#

aboo is always watching

loud junco
#

jkjk

supple thorn
quaint epoch
#

i will send code after a bit

supple thorn
#

Where do we look

#

Where in the internals did you look

quaint epoch
#

didn't i tell you before

#

!d disnake.utils.format_dt

unkempt canyonBOT
#

disnake.utils.format_dt(dt, /, style='f')```
A helper function to format a [`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "(in Python v3.10)"), [`int`](https://docs.python.org/3/library/functions.html#int "(in Python v3.10)") or [`float`](https://docs.python.org/3/library/functions.html#float "(in Python v3.10)") for presentation within Discord.

This allows for a locale-independent way of presenting data using Discord specific Markdown...
supple thorn
#

Response from what?

loud junco
#

its been a long time my friend

supple thorn
#

80% accurate hmmm

slate swan
supple thorn
#

Seems like it'a guessing

#

I see your vagueness

slate swan
#

anonymous did you even check it, that it differed for an offline user and an invisible one?

supple thorn
#

Test with me

loud junco
supple thorn
#

Kek

loud junco
#

i mean ur question
hi

supple thorn
#

Sounds like a hit or miss

#

But you'll know i'll be invis

slate swan
#

!d datetime.datetime.strftime use this to format the time

unkempt canyonBOT
#

datetime.strftime(format)```
Return a string representing the date and time, controlled by an explicit format string. For a complete list of formatting directives, see [strftime() and strptime() Behavior](https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior).
supple thorn
#

How is this fair data

#

If you already know i am invis

#

Why

loud junco
#
@bot.event
async def on_command_error(ctx, error):
  if isinstance(error, commands.CommandOnCooldown):
    seccd = round(error.cooldown.get_retry_after())
    mincd = 0
    hrcd = 0
    rseccd = 0
    rmincd = 0

    if seccd > 59:  
      
      rseccd = int(seccd % 60)
      mincd = int((seccd - rseccd) / 60)
      if mincd > 59:
        rmincd = int(mincd % 60)
        hrcd = int((mincd - rmincd) / 60)
    else:
      rseccd = seccd
    await ctx.send(f'''
Dont spam :/ 
Try again in another **{hrcd}h {rmincd}m {rseccd}s**
''')
```i did this
supple thorn
#

A hole

loud junco
#

LOL

#

but it works

supple thorn
#

double 7 single O is searching the internals so hard

slate swan
supple thorn
#

Why are you manually doing the cooldown

slate swan
#

!d datetime.timedelta

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...
sage otter
#

The humanize module would be so nice for this.

loud junco
slate swan
#

and easier too

slate swan
#

fine fine

loud junco
#

visible pain

slate swan
#

๐Ÿƒโ€โ™‚๏ธ yus

loud junco
#

idk what else to add to my rpg bot

visual island
vocal plover
#

here's a payload for that; the last line has avatar which is the new guild avatar, which you can see is different from the one in the user object

placid skiff
#

you have to do it via API untill devs add it, if they would add it

vocal plover
#

But it literally just did

placid skiff
#

Bruh on_member_update is triggered with those changes

vocal plover
#

that's evidently not up to date

placid skiff
#

bruh it's the latest D_D

visual island
vocal plover
#

But again, it literally just did lmao

vocal plover
#

I'm watching the raw events and when I change my server avatar the event is dispatched

loud junco
#

how do i close this bruh

#

:D_D:

#

look like :D and D:
more than D_D

quaint epoch
#

you don't

#

keep it open

#

;)

#

anyway, just wrote an ENTIRE COG that listens to events

loud junco
#

ITS NOT CLOSING

quaint epoch
#

and determines if a user is afk or lurking

#

well, if the user doesn't perform ANY actions, it can't determine anything

vocal plover
#

v9

#

I'll try with v8/v7 now

#

sorry my brain read that as API version, gateway v6

vocal plover
#

regardless, behaviour is consistent across v6 and v10, I definitely receive guild avatar updates (i did just manually change it to gw v10 to be sure)

loud junco
#

is it worth it to buy hacker plan on replit

slate swan
#

no

slate swan
vocal plover
#

No, you're better just buying a vps

#

hey koala

slate swan
#

hi vco

#

iirc some vps are cheaper then the hacker plan

loud junco
#

some example of good vps?

slate swan
#

check pins

loud junco
#

like vps u all use

slate swan
loud junco
#

which one should i use

loud junco
#

digital ocean?

slate swan
visual island
supple thorn
#

Hello vco

vocal plover
#

Personally I'm a fan of Linode; digitalocean is quite expensive and glaxygate while cheap has some substantial drawbacks when you read the terms

slate swan
#

no ones gonna say hi to xcirno๐Ÿ˜”

vocal plover
#

that said I have my own server which I use so I dont have recent experience with any

slate swan
#

hi xcirno pithink

supple thorn
#

Hello okimii

slate swan
#

hi hi

#

tylerpithink

sage otter
supple thorn
slate swan
sage otter
#

German vps company. Sells "hi-powered" vps's for like 6 euro a month.
Specs include:
8 Gbs Ram
4 vCores
256 Gb Solid State Storage
And some other stuff

paper sluice
#

๐Ÿ‘€

slate swan
#

that's better than what aws gives, what are its major drawbacks?

sage otter
#

Personally I havenโ€™t had any problems with it except their slow and amateur support.

slate swan
#

fair

supple thorn
#

Like do they just send you to google when they don't know how to fix your problem

sage otter
#

Normally, across more notable platforms like digi or aws. Those type of specs are more of a luxury product. And would cost a significant amount of more money than 6 euro.

supple thorn
#

"Good support costs extra, troubleshoot yourself now bai bai."

sage otter
#

Idk but those specs for only 8 US dollars doesnโ€™t seem ethical without some type of catch

#

Even if itโ€™s behind the scenes.

regal pulsar
#

i sent it from my phone so probably a different unicode ch somewhere

#

just retype it

visual island
jade tartan
#

someone help me with this please

vale wing
#

Just build a server by yourself like I did ๐Ÿ˜‰

vale wing
jade tartan
vale wing
#

You pressed shift + tab

boreal ravine
vale wing
#

That code makes no sense

jade tartan
vale wing
#

Tab moves code -->, shift + tab moves code <--

jade tartan
#

Whats Coroutines?

vale wing
#

"async expressions"

jade tartan
vale wing
#

At least you fixed indents

#

All async expressions must be inside async functions

#

!d discord.TextChannel.purge

unkempt canyonBOT
#

await purge(*, limit=100, check=..., before=None, after=None, around=None, oldest_first=False, bulk=True, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Purges a list of messages that meet the criteria given by the predicate
`check`. If a `check` is not provided then all messages are deleted
without discrimination...
jade tartan
vale wing
#

Best practice would be subclass bot and put all your setup stuff into setup_hook method

slate swan
#

async with and await can only be inside an async def func

vale wing
#
class MyBot(commands.Bot):
    async def setup_hook(self):
        # do your stuff here

client = MyBot(...)```
#

Better to name variable bot as well but up to you

fresh tide
#

do any of u have any good tutorial for d.py that is recent

vale wing
#

They are working on one afaik

fresh tide
vale wing
#

You can figure it out from examples folder

vale wing
fresh tide
#

oh ok

vale wing
split merlin
#

hi, i am facing a problem with the permissions for my bot
it can't add a role

  • Bot's role higher than the role Check
  • Bot's role higher than the member's role Check
  • Bot has admin or manage role permissions Check
    Yet i still face this issue
  File "/home/container/.local/lib/python3.10/site-packages/discord/client.py", line 375, in _run_event
    await coro(*args, **kwargs)
  File "/home/container/griselda_blanco.py", line 153, in on_message
    await _function.voteFunction(int(userID))
  File "/home/container/griselda_blanco_cogs/functions.py", line 70, in voteFunction
    await member.add_roles(role)
  File "/home/container/.local/lib/python3.10/site-packages/discord/member.py", line 1012, in add_roles
    await req(guild_id, user_id, role.id, reason=reason)
  File "/home/container/.local/lib/python3.10/site-packages/discord/http.py", line 495, in request
    raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access```
brittle axle
#

or can you show the source code

brittle axle
#

he didnt even show the source code XD

split merlin
maiden fable
#

Eh, well yea... But those are the most common issues

maiden fable
split merlin
maiden fable
#

!d discord.Guild.get_role

unkempt canyonBOT
#

get_role(role_id, /)```
Returns a role with the given ID.

Changed in version 2.0: `role_id` parameter is now positional-only.
split merlin
jade tartan
#
Traceback (most recent call last):
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\thoma\OneDrive\Desktop\discord server bot\Bot2.py", line 28, in on_ready
    client.ticket_configs[int(data[0])] = [int(data[1]), int(data[2]), int(data[3])]
IndexError: list index out of range
maiden fable
jade tartan
#
async def on_ready():
    async with aiofiles.open("ticket_configs.txt", mode="a") as temp:
        pass

    async with aiofiles.open("ticket_configs.txt", mode="r") as file:
        lines = await file.readlines()
        for line in lines:
            data = line.split(" ")
            client.ticket_configs[int(data[0])] = [int(data[1]), int(data[2]), int(data[3])]
maiden fable
split merlin
slate swan
split merlin
#

just a normal vote role

slate swan
split merlin
# slate swan may i see your code?
async def voteFunction(self, memberID:int):
   guild = self.client.get_guild(int(guildID))
   member = guild.get_member(memberID)
   role_id = vote_assign_roles.get(voteCount)
        if role_id is not None:
            role = get(guild.roles, id=role_id)
            await member.add_roles(role)```
jade tartan
#

SO just delete the list 3?

jade tartan
supple thorn
slate swan
#

its Guild.get_role

supple thorn
#

Fuck yeah just realized

slate swan
#

but that should not be the Issue

unkempt canyonBOT
#

You are not allowed to use that command here. Please use the #bot-commands channel instead.

split merlin
#

alright i will use it lol but like why does it say Missing access

supple thorn
#

Bro i hate these small ass boxes

#

!d discord.Guild.get_role

unkempt canyonBOT
#

get_role(role_id, /)```
Returns a role with the given ID.

Changed in version 2.0: `role_id` parameter is now positional-only.
slate swan
split merlin
#

alright

supple thorn
slate swan
supple thorn
#

Since discord.utils.get is slower

split merlin
#

tho i did re-copied it to make sure before coming here

split merlin
supple thorn
split merlin
supple thorn
supple thorn
split merlin
split merlin
supple thorn
split merlin
#

the bot is higher

supple thorn
split merlin
#

yeah

supple thorn
split merlin
#

as long as it's lower than my highest role

#

the bot should be able to do the same