#discord-bots

1 messages Β· Page 805 of 1

fervent shoal
#

ok

neat tartan
#

@sick birch can i get some help with cogs now? ive got the file setup and loaded in but it doesnt seem to be recognizing commands

slate swan
#

Is it possible to use variable in different files but in same folder?

dry kelp
#
            if before.vanity_invite != after.vanity_invite:
                await after.ban(i.user, reason="Anti-Nuke: Changing Guild Vanity")
                try:
                    if str(i.guild.id) in config_channel:
                        log_channel = self.angel.get_channel(int(channel_id))
                        embed = discord.Embed(title="![security](https://cdn.discordapp.com/emojis/907074407808241746.webp?size=128 "security") Anti-Nuke ![security](https://cdn.discordapp.com/emojis/907074407808241746.webp?size=128 "security")", description=f"**GUILD LOGS**\n\n**__NON TRUSTED MEMBER__**\n\nMember: `{i.user}`\nID: `{i.user.id}`\nPing: {i.user.mention}\n\n**__ABOUT__**\n\nNon-Trusted member changed the guild name!\n\n**__BEFORE__**\n\nGuild Vanity: `{before.vanity_invite}`\nGuild ID: `{before.id}`\n\n**__AFTER__**\n\nGuild Vanity: `{after.vanity_invite}`\nGuild ID: `{before.id}`\n\n**__ACTIONS__**\n\n![boop](https://cdn.discordapp.com/emojis/929782990618378341.webp?size=128 "boop") Non-Trusted member has been banned out of the server!\n![boop](https://cdn.discordapp.com/emojis/929782990618378341.webp?size=128 "boop") Guild vanity has been restored", color=discord.Color.from_rgb(black1, black2, black3))
                        await log_channel.send(embed=embed)
                except:
                    pass
                await after.edit(name=before.vanity_invite)
#

why is the guild vanity not editing back to the before vanity invite ?

neat tartan
#

top is commands file, middle is bot.py file and bottom is the error message

weary gale
#

im trying to host my bot using railway

#

and i cant seem to find the procfile

#

does anybody know how to get it

gusty hatch
#

how to fix No module named 'discord_buttons_plugin'

slim ibex
#

is it installed?

torn sail
# neat tartan

Commands should be indented so they’re in the class

#

Also don’t name ur commands on_message

gusty hatch
#

and github

neat tartan
gusty hatch
#

how to fix No module named 'discord_buttons_plugin'

neat tartan
#

do you have it imported?

gusty hatch
gusty hatch
#

@neat tartan

dry kelp
#
    @commands.Cog.listener()
    async def on_guild_update(self, before, after):

        async for i in before.audit_logs(limit=1, after=datetime.datetime.now() - datetime.timedelta(minutes = 1), action=discord.AuditLogAction.guild_update):

            with open(channel_path, "r") as f:
                config_channel = json.load(f)

            try:
                channel_config = config_channel[str(i.guild.id)]
                channel_id = channel_config[0]
            except:
                pass

            with open(whitelist_path, "r") as f:
                whitelisted = json.load(f)

            if str(i.user.id) in whitelisted[str(i.guild.id)]:
                return

            if before.vanity_invite != after.vanity_invite:
                await after.ban(i.user, reason="Anti-Nuke: Changing Guild Vanity")
                try:
                    if str(i.guild.id) in config_channel:
                        log_channel = self.angel.get_channel(int(channel_id))
                        embed = discord.Embed(title="![security](https://cdn.discordapp.com/emojis/907074407808241746.webp?size=128 "security") Anti-Nuke ![security](https://cdn.discordapp.com/emojis/907074407808241746.webp?size=128 "security")", description=f"**GUILD LOGS**\n\n**__NON TRUSTED MEMBER__**\n\nMember: `{i.user}`\nID: `{i.user.id}`\nPing: {i.user.mention}\n\n**__ABOUT__**\n\nNon-Trusted member changed the guild name!\n\n**__BEFORE__**\n\nGuild Vanity: `{before.vanity_invite}`\nGuild ID: `{before.id}`\n\n**__AFTER__**\n\nGuild Vanity: `{after.vanity_invite}`\nGuild ID: `{before.id}`\n\n**__ACTIONS__**\n\n![boop](https://cdn.discordapp.com/emojis/929782990618378341.webp?size=128 "boop") Non-Trusted member has been banned out of the server!\n![boop](https://cdn.discordapp.com/emojis/929782990618378341.webp?size=128 "boop") Guild vanity has been restored", color=discord.Color.from_rgb(black1, black2, black3))
                        await log_channel.send(embed=embed)
                except:
                    pass
                await after.edit(vanity_code=before.vanity_invite)
#

why is the guild vanity invite not changing back to the before vanity invite?

#

atleast this is what the docs say

weary gale
#

how do i get my bots procfile??

#

please can somebody help

neat tartan
weary gale
#

@neat tartan do u know?

#

how to get it

neat tartan
weary gale
#

oh fr

#

how would i navigate to the procfile thru the portal

neat tartan
#

you just open it in the web browser and then go over to the application and down to your bot

weary gale
#

i must be blind

#

could u ss where it says procfile pls

neat tartan
#

wdym?

weary gale
#

where do i find the procfile

neat tartan
#

under bot, within the specific application

weary gale
neat tartan
#

!?!?!

weary gale
#

idk.

neat tartan
#

oh procfile. not profile

weary gale
#

lol

#

so do you know how to get it?

neat tartan
#

fuck me, i dont know what the procfile is. whats it used for or why do you need it?

weary gale
#

hosting my bot i think?

#

idk im just watching a tutorial

#

on hosting with railway

neat tartan
#

quick google search sounds like the procfile is a file you make with a specific command to tell railway what to run

weary gale
#

i dont know how to do that

#

or get that

neat tartan
#

does your video tutorial say anything about how to make/get it

#

guessing not if your asking here

weary gale
#

yes but it doesnt work

#

its supposed to take me to the file

#

or create the file or whatever

#

but it doesnt do anything

modest plover
#

Using Python-decouple to use settings.ini as a token file, I get this:

~/artemis-mk2 $ python3 main.py
Traceback (most recent call last):
  File "/storage/emulated/0/coding/python/artemis-mk2/main.py", line 6, in <module>
    token = config('token')
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/decouple.py", line 243, in __call__
    return self.config(*args, **kwargs)
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/decouple.py", line 105, in __call__
    return self.get(*args, **kwargs)
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/decouple.py", line 90, in get
    raise UndefinedValueError('{} not found. Declare it as envvar or define a default value.'.format(option))
decouple.UndefinedValueError: token not found. Declare it as envvar or define a default value.

What do I do?

#
import disnake
from disnake.ext import commands
import os
from decouple import config

token = config('token')

bot = commands.Bot()

@bot.event
async def on_ready():
  print(f"Logged in as {bot.user}.")
  
bot.run(token)

That's main.py

neat tartan
#

does it look for settings.ini or config.ini

weary gale
#

r u talking to me

modest plover
#

Should do

#

I have a file called settings.ini

neat tartan
modest plover
#
[Settings]

token = token
#

Is the settings.ini file

modest plover
#

By default it's meant to look for that

neat tartan
neat tartan
dry kelp
#

can i get some help with my event pls?

modest plover
#

I doubt it

#

Given its essentially a variable

neat tartan
dry kelp
#

i lost my brain doing that lol

neat tartan
dry kelp
#

i am trying to get back the guild vanity url

modest plover
#

It was .htmltry because kryptonik fucked the link up accidentally

neat tartan
#

no idea how that happened but yup

modest plover
neat tartan
#

ah

dry kelp
#

ok so lemme tell u what it should do

neat tartan
dry kelp
#

so in this code everything works right except 1 thing the vanity url is not getting edited back to the before vanity url

#

the only thing that is happening in the code is that the member gets banned

#

and if logs are enabled logs will send too

neat tartan
weary gale
#

does this still work if im not using heroku?

#

im using railway

neat tartan
dry kelp
#

but not the bot is changing it

#

a "non trusted" member

#

people that are not whitelisted in the guild

weary gale
#

do i do this in the repo or vsc

#

repo im guessing

neat tartan
dry kelp
#

ong my brain

weary gale
#

both?

neat tartan
# dry kelp but not the bot is changing it

i dont think there is a way to pull a previous one. the best it could do is just grab the current vanity and hold onto it. if it is then changed the bot can compare them and reassign the presaved vanity

neat tartan
# weary gale both?

if you add it in vsc and then upload it to something like github the file would go with it and end up in both locations

sick birch
weary gale
#

ive never done this before

dry kelp
#

<bound method Guild.vanity_invite of <Guild id=924065171448692778 name='rares' shard_id=0 chunked=False member_count=340>>

#

oh there's a name atr

neat tartan
dry kelp
#

doesn't make sense

weary gale
neat tartan
neat tartan
dry kelp
#

so

#

ong im lost

dry kelp
#

wait name is the guild name

weary gale
#

might just use repl.it and uptime robot

neat tartan
weary gale
#

why not

sick birch
#

replit is pretty bad

weary gale
#

how else could i run my bot 24/7, without using my own computer

#

thats also free

dry kelp
#

@sick birch

dry kelp
#

so how can i get the before vanity code and the after vanity code?

sick birch
#

discord natively won't allow you to i don't think

weary gale
sick birch
#

course

dry kelp
#

i need help wtf

sick birch
#

750 free hours per month on t3.micro instance

dry kelp
#

im getting confused

neat tartan
dry kelp
#

huh?

weary gale
dry kelp
#

dude it's for my antinuke

#

or wym

#

damage what πŸ˜‚

neat tartan
sick birch
#

perhaps before has vanity before and after the vanity after?

#

wait that's guild role

gusty hatch
#

he still need help?

dry kelp
#

how can i make this work?

gusty hatch
#

β˜ οΈβ˜ οΈβ˜ οΈπŸ˜€

sick birch
#

though i'm not sure how you can test since you'd need to change the vanity

gusty hatch
#

Spooky I would help u cus i been did an anti-vanity like 9 months ago but na zzDREAMLMAOOO

#

you too sensitive

dry kelp
#

na bro

#

vanity is crazy

neat tartan
#

if the vanity url has been changed BEFORE your bot is on the server you CANNOT grab the before vanity url. if your bot is on the server before the nuking and is supposed to prevent it the best thing it can do is grab the current vanity url to act as the before

dry kelp
#

brain fucking

gusty hatch
#

its not that hard

dry kelp
#

depends how u tryna do it

dry kelp
#

πŸ˜‚

gusty hatch
#

its not hard

#

😭

neat tartan
dry kelp
#

so i just found out that

dry kelp
#

before.vanity_invite this is totally not the code

sick birch
dry kelp
#

of the vanity

gusty hatch
dry kelp
#

that's not lol

weary gale
#

@sick birch

gusty hatch
weary gale
#

I dont want to add mine?

gusty hatch
dry kelp
#

dude r u dumb?

#

ion believe u that u got a anti url now

#

that's not the name lol

#

that checks if the change was made for the url

#

it won't get the code

gusty hatch
#

$15 for my code

dry kelp
#

<bound method Guild.vanity_invite of <Guild id=924065171448692778 name='rares' shard_id=0 chunked=False member_count=340>>

gusty hatch
dry kelp
#

never

#

i will get to it soon dw

gusty hatch
#

sure

dry kelp
#

u seen that skids

#

that tried to bypass my shit

#

got 2 bans

gusty hatch
#

No

#

oh yh nvm

dry kelp
#

πŸ˜‚

sick birch
gusty hatch
dry kelp
#

exactky\

#

bro i laughed so bad

sick birch
#

alright guys let's keep it on topic

weary gale
gusty hatch
#

It just depends on the nuker ur ping and response time to guild audits

dry kelp
gusty hatch
dry kelp
#

LMFAO

weary gale
#

im trying to sign up and its making me use one @sick birch

dry kelp
weary gale
#

or do i not have to sign up

sick birch
dry kelp
#

@sick birch

#

does discord got a api for that?

weary gale
#

how is it possible to reach over 750 hours a month

dry kelp
#

that stores the codes?

#

like

neat tartan
sick birch
gusty hatch
weary gale
reef trail
#

Hey im getting this error for my command:

  File "/home/ubuntu/.local/lib/python3.9/site-packages/discord/ext/commands/bot.py", line 994, in invoke
    await ctx.command.invoke(ctx)
  File "/home/ubuntu/.local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 894, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/home/ubuntu/.local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 176, in wrapped
    raise CommandInvokeError(exc) from exc
CommandInvokeError: Command raised an exception: AttributeError: 'str' object has no attribute 'read'

    @commands.command(usage="`tp!se emote`", aliases=["stealemote", "se", "steale"])
    @commands.guild_only()
    @commands.cooldown(rate=1, per=4.5, type=commands.BucketType.user)
    @permissions.has_permissions(manage_emojis=True, manage_guild=True)
    @commands.bot_has_permissions(embed_links=True, manage_emojis=True)
    async def steal_emote(self, ctx, emote: discord.PartialEmoji):
        """Clones any emote to the current server"""
        await ctx.guild.create_custom_emoji(
            name=emote.name,
            image=await emote.url.read(),
            reason=f"{ctx.author} used steal_emote",
        )
        await ctx.send(f"I successfully cloned {emote.name} to {ctx.guild.name}!")```
this was working just fine like a few weeks ago and suddenly this is the error i get, i dont understand.
im using dpy 2.0
weary gale
#

it's impossible?

sick birch
#

yeah you should consider purchasing one anyway since i would say AWS is one of the best hosts, it's used by a lot of major companies

gusty hatch
#

Send support server @dry kelp

sick birch
# weary gale

you can run multiple instances, and it's cumulative

gusty hatch
#

dude u dont have to store the vanity

#

discord auto saves the before

dry kelp
dry kelp
#

i am having issues getting the name

#

does it have a atr or smth?

#

if before.vanity_invite != after.vanity_invite: this part is already checking if a change was made to the url

#

which runs right after

#

the member will get banned

#

it stops before changing it back

#

cuz idk how to get the code

#

so does it have a certain atr?

#

like

#

after.vanity_invite.url

#

after.vanity_invite.code

reef trail
#

please finish your sentence before you press enter lmao

dry kelp
#

no

reef trail
#

ok

dry kelp
#

thanks for understanding

#

my fingers wont let me

reef trail
#

you'll grow out of it

#

anyway what are you trying to do

dry kelp
#

replace back the vanity url once it gets changed

reef trail
#

Okay and what have you done to try to accomplish this?

#

Are you storing the invite and then waiting for it to change?

sick birch
#

Yes, if the vanity URL before != vanity URL after, ban user, change vanity back

reef trail
#

or change vanity back and then ban

dry kelp
reef trail
#

I would take priority over the vanity

dry kelp
#

that's my issue

reef trail
#

Well

#

I guess you could append the invite then use a on_guild_update and go from there?

dry kelp
#

this is a coroutine

#

what the fuck

#

i think im looking at smth else

reef trail
#

right so append the invite to store it and then wait for it to change, or save it in some json file then wait for it to change

dry kelp
#

why would i need to do that

#

pretty sure i can make it without storing the url code

reef trail
#

So you can store the invite

#

Im pretty sure you cant

#

since its not explicitly stated that you can in the way you're trying

neat tartan
reef trail
#

has it been proven that you can?

neat tartan
#

you didnt. federal did

reef trail
#
@commands.Cog.listener(name="on_guild_update")
async def check_vanity(self, before, after):
code lol```
sick birch
dry kelp
#

idk how he even got in the discussion

#
    @commands.Cog.listener()
    async def on_guild_update(self, before, after):

        async for i in before.audit_logs(limit=1, after=datetime.datetime.now() - datetime.timedelta(minutes = 1), action=discord.AuditLogAction.guild_update):

            with open(channel_path, "r") as f:
                config_channel = json.load(f)

            try:
                channel_config = config_channel[str(i.guild.id)]
                channel_id = channel_config[0]
            except:
                pass

            with open(whitelist_path, "r") as f:
                whitelisted = json.load(f)

            if str(i.user.id) in whitelisted[str(i.guild.id)]:
                return

            if before.vanity_invite != after.vanity_invite:
                await after.ban(i.user, reason="Anti-Nuke: Changing Guild Vanity")
                try:
                    if str(i.guild.id) in config_channel:
                        log_channel = self.angel.get_channel(int(channel_id))
                        embed = discord.Embed(title="![security](https://cdn.discordapp.com/emojis/907074407808241746.webp?size=128 "security") Anti-Nuke ![security](https://cdn.discordapp.com/emojis/907074407808241746.webp?size=128 "security")", description=f"**GUILD LOGS**\n\n**__NON TRUSTED MEMBER__**\n\nMember: `{i.user}`\nID: `{i.user.id}`\nPing: {i.user.mention}\n\n**__ABOUT__**\n\nNon-Trusted member changed the guild name!\n\n**__BEFORE__**\n\nGuild Vanity: `{before.vanity_code}`\nGuild ID: `{before.id}`\n\n**__AFTER__**\n\nGuild Vanity: `{after.vanity_code}`\nGuild ID: `{before.id}`\n\n**__ACTIONS__**\n\n![boop](https://cdn.discordapp.com/emojis/929782990618378341.webp?size=128 "boop") Non-Trusted member has been banned out of the server!\n![boop](https://cdn.discordapp.com/emojis/929782990618378341.webp?size=128 "boop") Guild vanity has been restored", color=discord.Color.from_rgb(black1, black2, black3))
                        await log_channel.send(embed=embed)
                except:
                    pass
                await after.edit(vanity_code=before.vanity_invite)
#

current code i got

#

ik this is wrong

#

i was testing

reef trail
#

await after.vanity_invite

#

idfk

sick birch
#

It's a coroutine

#

await before.vanity_invite()

reef trail
#

yes that thanks

dry kelp
#

so don't i have to edit the guild?

#

huh

#

the docs are confusing then

sick birch
#

If the vanity changes you will have to change it back using the before vanity

dry kelp
reef trail
#

can i get some help with my issue btw

sick birch
#

which you want to do yes?

#

if it changes by another user

dry kelp
#

yes

#

correctly

sick birch
#

yeah so you need to edit the vanity using the before vanity_url

#

by that i mean pass it into guild.edit()

dry kelp
#

passing the coroutine inside the edit?

#

like

reef trail
#

await guild.edit()

dry kelp
#

the problem is inside

gusty hatch
#

how do i do buttons in python

dry kelp
#

after is the guild

dry kelp
gusty hatch
dry kelp
#

yep

gusty hatch
#

that actually work

dry kelp
#

yessir

#

go to my support server rq

gusty hatch
#

k..

dry kelp
#

before_url = await before.vanity_invite() @sick birch

#

is this what u talking about?

sick birch
#

yep

dry kelp
#

do i pass it inside the edit?

#

vanity_code=before_url

#

@sick birch

#

that will get the entire url

#

but it won't change

#

that makes no sense tho

#

it gets in what the url changed

#

not the before one

sick birch
#

are both before and after the same vanity URL?

dry kelp
#

looks like it

sick birch
#

I suppose that makes sense

#

It's a coroutine, so I'm assuming it's not a cached property

dry kelp
#

mhm

quasi stag
#

how do ig et the last 10 messages of a channel

dry kelp
#

u gotta save them into a database

quasi stag
#

..

dry kelp
#

what?

#

and then u just display them

quasi stag
#

how do i do that WITHOUT a database?

dry kelp
#

i assume that u can't

quasi stag
#

why not

dry kelp
#

pretty sure the bot cannot read the last 10 messages

quasi stag
#

how?

dry kelp
#

wym how

#

it just can't

quasi stag
#

why not dude

dry kelp
#

why don't u just create a json?

quasi stag
#

and?

dry kelp
#

to save the messages

#

and then u just display them

quasi stag
#

I dont want to do it without json

#

i just wanna get the messages instantly

dry kelp
#

u can't that's what im sayin

quasi stag
#

ugh, this isnt helping

#

bye

dry kelp
#

u won't be able to read the last 10 messages without a database

sick birch
unkempt canyonBOT
#

async for ... in history(*, limit=100, before=None, after=None, around=None, oldest_first=None)```
Returns an [`AsyncIterator`](https://discordpy.readthedocs.io/en/master/api.html#discord.AsyncIterator "discord.AsyncIterator") that enables receiving the destination’s message history.

You must have [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permissions to use this.

Examples

Usage...
dry kelp
#

database >

#

way better

#

history is even more brain painful

sick birch
#

There's no point

quasi stag
dry kelp
sick birch
#

You want to get the first 10 messages?

quasi stag
#

last

#

not first

sick birch
#

So the most recent ones?

dry kelp
#

i recommend using a database

quasi stag
dry kelp
#

much easire

sick birch
#

Yeah, just use history

dry kelp
#

easier*

sick birch
#

It'll go from most recent -> least recent

quasi stag
dry kelp
#

@sick birch

#

set a limit then

sick birch
quasi stag
#

limit=10

sick birch
#

How many messages were in the channel?

dry kelp
pliant gulch
#

Using a databases with messages? I thought discord.py models were only semi-serialisable at best

quasi stag
#

20ish

pliant gulch
#

And your messages would have a high chance of being outdated

#

Database is not a right choice if you want to get the recent 10 messages

sick birch
#

There's no point in storing the last 10 messages in a database when you can just use a built in method for it

quasi stag
#

thats what im saying

dry kelp
#

i prefer using database

sick birch
#

All very good points

dry kelp
#

robin

#

what about my url 😭

sick birch
#

@quasi stag can we see your code? Something's off if it's giving you the first 10 messages

sick birch
dry kelp
#

wym

#

how could i do it?

sick birch
#

Off the top of my head, maybe a loop that runs every minute or so and checks if the vanity changes

quasi stag
dry kelp
#

i assume that there's a way to do it without doing that

quasi stag
#

also, i want the bot to read from bottom to top

pliant gulch
#

You should be able to just create a listener for the guild_update event

quasi stag
#

so like, recent -> old

sick birch
#

Yeah, history should do that by default

pliant gulch
#

Yes

sick birch
pliant gulch
#

I'm pretty sure you'd know what your vanity url is anyways, you can hardcode that

sick birch
#

Hmm yeah I suppose you could do that

pliant gulch
#

Otherwise fetch it

dry kelp
#
    @commands.Cog.listener()
    async def on_guild_update(self, before, after):

        async for i in before.audit_logs(limit=1, after=datetime.datetime.now() - datetime.timedelta(minutes = 1), action=discord.AuditLogAction.guild_update):

            with open(channel_path, "r") as f:
                config_channel = json.load(f)

            try:
                channel_config = config_channel[str(i.guild.id)]
                channel_id = channel_config[0]
            except:
                pass

            with open(whitelist_path, "r") as f:
                whitelisted = json.load(f)

            if str(i.user.id) in whitelisted[str(i.guild.id)]:
                return

            before_url = await before.vanity_invite()   
            if before.vanity_invite != after.vanity_invite:
                await after.ban(i.user, reason="Anti-Nuke: Changing Guild Vanity")
                try:
                    if str(i.guild.id) in config_channel:
                        log_channel = self.angel.get_channel(int(channel_id))
                        embed = discord.Embed(title="![security](https://cdn.discordapp.com/emojis/907074407808241746.webp?size=128 "security") Anti-Nuke ![security](https://cdn.discordapp.com/emojis/907074407808241746.webp?size=128 "security")", description=f"**GUILD LOGS**\n\n**__NON TRUSTED MEMBER__**\n\nMember: `{i.user}`\nID: `{i.user.id}`\nPing: {i.user.mention}\n\n**__ABOUT__**\n\nNon-Trusted member changed the guild name!\n\n**__BEFORE__**\n\nGuild Vanity: `{before_url}`\nGuild ID: `{before.id}`\n\n**__AFTER__**\n\nGuild Vanity: `{before_url}`\nGuild ID: `{before.id}`\n\n**__ACTIONS__**\n\n![boop](https://cdn.discordapp.com/emojis/929782990618378341.webp?size=128 "boop") Non-Trusted member has been banned out of the server!\n![boop](https://cdn.discordapp.com/emojis/929782990618378341.webp?size=128 "boop") Guild vanity has been restored", color=discord.Color.from_rgb(black1, black2, black3))
                        await log_channel.send(embed=embed)
                except:
                    pass
                await after.edit(vanity_code=before_url)
#

current code

pliant gulch
#

yikes

sick birch
#

Yep....

pliant gulch
#

that is a lot

dry kelp
#

yikes what

#

lemme make a myst

sick birch
#

Yeah try andy's idea, store your vanity as a bot var on startup

dry kelp
#

in a variable huh?

pliant gulch
#

Is there any reason you look through the audit logs?

sick birch
#

yeah

pliant gulch
#

The only thing you seem to be checking is for a vanity url change

pliant gulch
#

There is no point in a API call here

dry kelp
#

that's the right thing

pliant gulch
#

You can just check the vanity of after and before

dry kelp
#

huh

sick birch
dry kelp
#

are u talking about this?

sick birch
#

the only way to get the vanity through discord.Guild is through a await before.vanity_invite()

#

which makes an API call and seems to return the current vanity rather than before/after

dry kelp
#

this is needed because on_guild_update can trigger multiple things

pliant gulch
normal bolt
#

How can I get the ID of a member I mentioned in the chat?
ex: in chat I write "get member id @", and the bot gets and prints his ID?

sick birch
#

^ yeah use a bot var and store or hardcode your vanity. if it changes, revert it back & ban the user

pliant gulch
#

Otherwise if it doesn't do nothing

#

No need for a pointless audit log call to check for something you already know can be happening without a API call

sick birch
dry kelp
sick birch
#

Oh they want to find out who changed the vanity

dry kelp
#

the user that made the change

pliant gulch
#

Ah that makes more sense now

sick birch
#

Yeah that's a bit more tricky

pliant gulch
#

Ok, so to get back on topic just store the vanity url to the guild id beforehand

#

Simple key-value pair in your database, boom bop done

dry kelp
#

jesus christ

sick birch
#

Still feels like data harvesting doesn't it

dry kelp
#

it's made for the antinuke

#

so idk πŸ€·β€β™‚οΈ

sick birch
#

yeah but storing the vanities of all guilds in a database

dry kelp
#

it's made for a good purpose

sick birch
#

πŸ€”

#

I suppose go for it but make sure your users know that you are storing their vanities

dry kelp
#

what about if the guild doesn't have a tier 3 ?

#

should i check that too?

sick birch
#

well there's no point in protecting a vanity if they don't have a vanity

dry kelp
#

exactly

#

so imma add a return

#

if before.premium_tier != 3:

#

this should work

pliant gulch
#

But I'm no lawyer so

dry kelp
#

i will once i find out how to fix this shit

#

i still have no idea tbh

#
with open(path, 'wb') as f:
    f.write(...)
#

so ur telling me to do this?

#

@pliant gulch

sick birch
#

why a regular file

#

use something like postgresql with a 2 column table, guild ID and URL

dry kelp
#

sqlite3?

sick birch
#

sure if you must

#

though something more robust would be preferred

pliant gulch
#

Could be a legal issue as well, some cases and depends where you are, you are legally required to securely store your data from users

sick birch
#

yeah storing in a text file is quite the opposite of security

dry kelp
#
@angel.event
async def on_ready():
    db = sqlite3.connect('database.sqlite3')
    cursor = db.cursor()

    cursor.execute('''
        CREATE TABLE IF NOT EXISTS welcome(
            "guild_id"    INTEGER,
            "channel_id"    INTEGER,
            "msg"    TEXT DEFAULT 'Hey $user_mention',
            "title"    TEXT DEFAULT 'Welcome to $server',
            "color"    TEXT DEFAULT '#000000',
            "footer"    TEXT DEFAULT 'Spooky Welcomer',
            "embed"    INTEGER DEFAULT 0,
            "ping"    INTEGER DEFAULT 0,
            "autodel"  INTEGER DEFAULT 0,
            PRIMARY KEY("guild_id")
          )
          ''')

    db2 = sqlite3.connect('anti_vanity.sqlite3')
    cursor2 = db2.cursor()

    cursor2.execute('''
        CREATE TABLE IF NOT EXISTS vanity(
            "guild_id"    INTEGER,
          )
          ''')
#

don't mind the 1st part

#

is another database

sick birch
#

sqlite3 is blocking

dry kelp
#

i mean imma use it anyway

#

lemme change welcome

sick birch
#

use either asqlite or aiosqlite

dry kelp
#

idk how to use them

#

never used them

sick birch
#

it's the same exact thing, just a thin wrapper

#

and asqlite has better defaults

dry kelp
#

imma just use this πŸ˜‚

sick birch
#

it's blocking though

dry kelp
#

fuck it

sick birch
#

if you say so

dry kelp
#

alr

#

what do i store next?

sick birch
#

well i never write sql these days so you're kind of on your own for the sql statements

#

raw sql queries are overrated

dry kelp
#

idk how to use it at all tbh

#

weird af

sick birch
#

alright just make sure the table has 2 columns, guild ID and vanity url

#

right now it only seems like it has a guild ID

pliant gulch
#

prisma orm πŸ™

dry kelp
#

yep

sick birch
#

prisma is awesome

#

probably my favourite orm

dry kelp
#
    cursor2.execute('''
        CREATE TABLE IF NOT EXISTS welcome(
            "guild_id"    INTEGER,
            "vanity_url"    INTEGER
          )
          ''')

sick birch
#

there you are

dry kelp
#
    cursor2.execute('''
        CREATE TABLE IF NOT EXISTS vanity(
            "guild_id"    INTEGER,
            "vanity_url"    INTEGER
          )
          ''')
sick birch
#

now you should be able to just put stuff into those tables (don't ask me how)

dry kelp
#

"hOwWw"

#

nah jk

#

all ik ```py
with sqlite3.connect('.anti_vanity.sqlite3') as db:
db.row_factory = sqlite3.Row
cursor = db.cursor()

#

@sick birch

sick birch
#

yeah should work

dry kelp
#

yeah it should

#

and now how do i store it?

#

like

#

how do i get the before url doing this

#

still reached the same issue thumbsup

#

@sick birch

#
            query = "SELECT * FROM  vanity WHERE guild_id = ?"
            val = (before.id)

            with sqlite3.connect('.anti_vanity.sqlite3') as db:
                db.row_factory = sqlite3.Row
                cursor = db.cursor()
                cursor.execute(query, val)
sick birch
dry kelp
#

idk if it does

sick birch
#

probably a loop with wait_until_ready

dry kelp
#

this will store only when it get changed

#
    @commands.Cog.listener()
    async def on_guild_update(self, before, after):

        async for i in before.audit_logs(limit=1, after=datetime.datetime.now() - datetime.timedelta(minutes = 1), action=discord.AuditLogAction.guild_update):

            with open(channel_path, "r") as f:
                config_channel = json.load(f)

            try:
                channel_config = config_channel[str(i.guild.id)]
                channel_id = channel_config[0]
            except:
                pass

            with open(whitelist_path, "r") as f:
                whitelisted = json.load(f)

            if str(i.user.id) in whitelisted[str(i.guild.id)]:
                return

            query = "SELECT * FROM  vanity WHERE guild_id = ?"
            val = (before.id)

            with sqlite3.connect('.anti_vanity.sqlite3') as db:
                db.row_factory = sqlite3.Row
                cursor = db.cursor()
                cursor.execute(query, val)

            before_url = await before.vanity_invite()   
            if before.vanity_invite != after.vanity_invite:
                await after.ban(i.user, reason="Anti-Nuke: Changing Guild Vanity")
                try:
                    if str(i.guild.id) in config_channel:
                        log_channel = self.angel.get_channel(int(channel_id))
                        embed = discord.Embed(title="![security](https://cdn.discordapp.com/emojis/907074407808241746.webp?size=128 "security") Anti-Nuke ![security](https://cdn.discordapp.com/emojis/907074407808241746.webp?size=128 "security")", description=f"**GUILD LOGS**\n\n**__NON TRUSTED MEMBER__**\n\nMember: `{i.user}`\nID: `{i.user.id}`\nPing: {i.user.mention}\n\n**__ABOUT__**\n\nNon-Trusted member changed the guild name!\n\n**__BEFORE__**\n\nGuild Vanity: `{before_url}`\nGuild ID: `{before.id}`\n\n**__AFTER__**\n\nGuild Vanity: `{before_url}`\nGuild ID: `{before.id}`\n\n**__ACTIONS__**\n\n![boop](https://cdn.discordapp.com/emojis/929782990618378341.webp?size=128 "boop") Non-Trusted member has been banned out of the server!\n![boop](https://cdn.discordapp.com/emojis/929782990618378341.webp?size=128 "boop") Guild vanity has been restored", color=discord.Color.from_rgb(black1, black2, black3))
                        await log_channel.send(embed=embed)
                except:
                    pass
                await after.edit(vanity_code=before_url)
#

oh so ur saying

#

to fetch all the guild ids

#

in that on_ready event?

#

@sick birch

sick birch
#

not in on_ready

#

doing anything on_ready is a bad idea

dry kelp
#

then it should do the job

sick birch
#

no it won't, it's bad practice and will only get your bot disconnected from the websocket

dry kelp
#

maybe it's a bad idea using this database

#

what should i use?

sick birch
#

using a database is never a bad idea

dry kelp
#

i meant sqlite3

sick birch
#

postgres is a robust database and one of the most popular

dry kelp
#

just sayin that idk how to use those so i will just fuck ur brain

sick birch
#

i don't either in python, the only way i've done it is have an Express.js server running prisma that interacts with the postgresql database, and I can send API calls to that server using aiohttp and interact with the database

dry kelp
#

ok

#

i got a better idea

sick birch
#

That way you don't have to deal with the python database connectors and writing the nasty sql queries

dry kelp
#

so

#

back to my main question

#

since the beginning

#

how can i get the before url without using database

#

i am pretty sure that i don't have to sort all of this

sick birch
#

well you could store all the vanities in a text file or whatever but it's incredibly insecure and difficult to work with

dry kelp
#

that would be better because nobody can access my root or anything

sick birch
#

still a pretty bad idea when you consider how you would have to work with it in python

dry kelp
#

makes sense but let's try this

sick birch
#

it's gonna turn into spaghetti code really fast and we won't be able to tell what's what

dry kelp
#

πŸ˜‚

#

makes sense

#

another question

#

does discord have a api?

#

with all the urls/guild ids

sick birch
dry kelp
#

so there is

sick birch
#

of course

dry kelp
#

aii look

#

"https://discord.com/api/v9/guilds/{after.id}/vanity-url/{before_vanity}"

sick birch
#

let me take a look

dry kelp
sick birch
#

that only gets the vanity currently

#

exactly what await guild.vanity_url() does

dry kelp
#

so that gets the before one

#

right?

#

before it gets changed

sick birch
#

no, it get the vanity at the time of sending the request

dry kelp
#

if i put it otuside the loop

#

ah

wary zenith
#
@client.event
async def on_command_error(ctx, error):
  if isinstance(error, commands.CommandNotFound):
    await ctx.send(str(error))
  else: 
    with open("runtime_errors.txt", "a") as f:
        # Error on this line: SyntaxError: invalid syntax
      f.write(f"{t.strftime("%m/%d/%Y, %I:%M")} || {str(error)}\n")```
sick birch
#

make sure it's indented properly, the command and the succeeding line don't seem to be on the same indent level

dry kelp
#

so

#

look tell me how could i get the code

#

that's what im having issues with

wary zenith
#

this is it

sick birch
#

Yes, you'd need to store the vanities of each guild on startup

sick birch
# wary zenith this is it

make sure they're on the same line, python doesn't like that when you split a line halfway like that

dry kelp
#

yeah but i have to store the code of it

#

right?

sick birch
#

the vanity url code?

dry kelp
#

YE

sick birch
#

yes

dry kelp
#

ye*

sick birch
#

you would have to store it

dry kelp
#

and how do i get it

sick birch
#

on startup, go through every guild the bot is in and await guild.vanity_url(), then store that

dry kelp
#

wym by on "startup"

wary zenith
dry kelp
#

on_ready?

sick birch
#

from the docs:

from discord.ext import tasks, commands

class MyCog(commands.Cog):
    def __init__(self, bot):
        self.index = 0
        self.bot = bot
        self.printer.start()

    def cog_unload(self):
        self.printer.cancel()

    @tasks.loop(seconds=5.0)
    async def printer(self):
        print(self.index)
        self.index += 1

    @printer.before_loop
    async def before_printer(self):
        print('waiting...')
        await self.bot.wait_until_ready()
wary zenith
dry kelp
#

didn't u say that is not alr doing things on_ready event?

sick birch
dry kelp
#

and then why am i doing it?

sick birch
#

you shouldn't do anything except maybe printing in on_ready()

wary zenith
dry kelp
#

should i use it in the same file?

wary zenith
#

i rlly dont know why

sick birch
#

doesn't matter

wary zenith
#

is not working

sick birch
dry kelp
sick birch
#

yes

wary zenith
sick birch
#

Yes, and replace the double quotes around the strftime format to single quotes

dry kelp
#
import discord
from discord.ext import commands
import json
import datetime
import pathlib
import sqlite3
from discord.ext import tasks, commands

whitelist_path = pathlib.Path(__file__).parent / "whitelisted.json"
prefix_path = pathlib.Path(__file__).parent.parent / "prefix" / "prefixes.json"
channel_path = pathlib.Path(__file__).parent / "Logs.json"

black1 = 0
black2 = 0
black3 = 0

class MyCog(commands.Cog):
    def __init__(self, bot):
        self.index = 0
        self.bot = bot
        self.printer.start()

    def cog_unload(self):
        self.printer.cancel()

    @tasks.loop(seconds=5.0)
    async def printer(self):
        print(self.index)
        self.index += 1

    @printer.before_loop
    async def before_printer(self):
        print('waiting...')
        await self.bot.wait_until_ready()

class AntiVanity(commands.Cog):
    def __init__(self, angel):
        self.angel = angel
    
    @commands.Cog.listener()
    async def on_guild_update(self, before, after):

        async for i in before.audit_logs(limit=1, after=datetime.datetime.now() - datetime.timedelta(minutes = 1), action=discord.AuditLogAction.guild_update):

            with open(channel_path, "r") as f:
                config_channel = json.load(f)

            try:
                channel_config = config_channel[str(i.guild.id)]
                channel_id = channel_config[0]
            except:
                pass

            with open(whitelist_path, "r") as f:
                whitelisted = json.load(f)

            if str(i.user.id) in whitelisted[str(i.guild.id)]:
                return

            before_url = await before.vanity_invite()   
            if before.vanity_invite != after.vanity_invite:
                await after.ban(i.user, reason="Anti-Nuke: Changing Guild Vanity")
                try:
                    if str(i.guild.id) in config_channel:
                        log_channel = self.angel.get_channel(int(channel_id))
                        embed = discord.Embed(title="![security](https://cdn.discordapp.com/emojis/907074407808241746.webp?size=128 "security") Anti-Nuke ![security](https://cdn.discordapp.com/emojis/907074407808241746.webp?size=128 "security")", description=f"**GUILD LOGS**\n\n**__NON TRUSTED MEMBER__**\n\nMember: `{i.user}`\nID: `{i.user.id}`\nPing: {i.user.mention}\n\n**__ABOUT__**\n\nNon-Trusted member changed the guild name!\n\n**__BEFORE__**\n\nGuild Vanity: `{before_url}`\nGuild ID: `{before.id}`\n\n**__AFTER__**\n\nGuild Vanity: `{before_url}`\nGuild ID: `{before.id}`\n\n**__ACTIONS__**\n\n![boop](https://cdn.discordapp.com/emojis/929782990618378341.webp?size=128 "boop") Non-Trusted member has been banned out of the server!\n![boop](https://cdn.discordapp.com/emojis/929782990618378341.webp?size=128 "boop") Guild vanity has been restored", color=discord.Color.from_rgb(black1, black2, black3))
                        await log_channel.send(embed=embed)
                except:
                    pass
                await after.edit(vanity_code=before_url)

def setup(angel):
    angel.add_cog(AntiVanity(angel))
#

lemme make a myst

sick birch
#

Can you post the text here? hard to see it

wary zenith
#
 with open("runtime_errors.txt", "a") as f:
      f.write(f"{t.strftime('%m/%d/%Y, %I:%M')} || {str(error)}\n")```
sick birch
#

there should be a closing quote after the }

#

but you don't even need an f string

dry kelp
fervent shoal
#

hello from rasberry pi, i have taken my code and put it in the same app on rasberry pi, but it says that discord is not accsesed when i do import discord, so do i need to separetly sudo install discord.py?

dry kelp
sick birch
#
f.write(t.strftime('%m/%d/%Y, %I:%M'))
#

no f strings needed

wary zenith
wary zenith
sick birch
#

yes that part is fine, which is why i left it out

fervent shoal
#

from where do i import discord, is there a separate thing i need to install?

gusty hatch
#

AttributeError: 'list' object has no attribute 'user' any help?

fervent shoal
#

this is rasberry pi os

dry kelp
#

simple

fervent shoal
#

isnt pip for win or am i tripping

sick birch
#

pip is for python

gusty hatch
fervent shoal
#

ohh

dry kelp
wary zenith
fervent shoal
#

thank you robin

sick birch
gusty hatch
# dry kelp send code

no u gone steal and run off X_lmfao im on mobile so i cant rlly look at da code but ik smth wrong , and that is definitely a lie

dry kelp
#

wtf

#

how am i supposed to know ur issue

sick birch
#

We need the code to be able to diagnose the issue

#

Unfortunately

dry kelp
#

try pulling the elements from list (idk the code) but maybe should be it

#

for x in y:

wary zenith
#

i tried this and it didnt work python with open("runtime_errors.txt", "a") as f: f.write(t.strftime('%m/%d/%Y, %I:%M') + " || " + str(error))

sick birch
#

that works

dry kelp
#

@sick birch

#

so federal sent me a code for the anti vanity

#

but is like

#

kinda fucked up

#

pretty sure we can debug it

#
@commands.Cog.listener()
    async def on_guild_update(self, before, after):
        reason = "Anti-Nuke | Updating Vanity URL"
        i = await before.audit_logs(limit=1, after=datetime.datetime.now() - datetime.timedelta(minutes = 2), action=discord.AuditLogAction.guild_update).flatten()
        whitelisted = db.find_one({ "guild_id": after.id })['whitelisted-users']
        if i.user.id in whitelisted:
            return
        rolelisted = db.find_one({ "guild_id": after.id })['whitelisted-roles']
        if i.user.id in rolelisted:
            return
        if self.bot.user.id == i.user.id:
            return
wary zenith
dry kelp
#

like i said that's very fucked up πŸ˜‚

wary zenith
dry kelp
#

about what

sick birch
#

that does strftime return? a string?

dry kelp
#

@sick birch also what do i do after i used that?

wary zenith
dry kelp
#

do i store the guild id?

sick birch
#

looks like weird code not gonna lie

wary zenith
#

repl was just going stupid

sick birch
dry kelp
#

i don't understand that cog

#

what is that supposed to do?

#

oh nvm i got it

wary zenith
dry kelp
#

imma use a json

#

created as a list

wary zenith
dry kelp
#

@sick birch i can't dawg

#

is fucking my brain

fervent shoal
#

what does this mean

dry kelp
#

@sick birch

fervent shoal
#

yes but why is it happening

#

and how do i fix it

slate swan
#

Hello πŸ‘‹

**How do I make a discord bot check connections a user has? **Such as reddit or xbox. I know it has something to do with oauth2 and i have to authenticate smth, but I dont quite get what Im supossed to do.

fervent shoal
#

wait

#

oh shit delete that rq

#

it has bots token

#

ok we are good

#

BRO I WILL but how do i fix the prblem

#

it worked fine on windows

#

this rasberry pi stuff is sorta new for me

#

it shouldnt be on desktop

#

do i change the file code to somewhere else?

timid wagon
fervent shoal
#

[Errno 2] No such file or directory

fervent shoal
#

can't open file '/home/pi/Desktop/TOKEN =

#

token has been regenned

dry kelp
wary zenith
#

yea

#

its the same process

timid wagon
# dry kelp

before and after in on_member_update are discord.Member objects

#

Uh

slate swan
#

Guys how do i use the connections scope with my python script?

timid wagon
#

on_member_update and on_guild_update are both giving errors? thonk

fervent shoal
#

Traceback (most recent call last):
File "/home/pi/Downloads/riot bot 5, no way this works.py", line 13, in <module>
from asyncio.windows_events import INFINITE
File "/usr/lib/python3.7/asyncio/windows_events.py", line 3, in <module>
import _overlapped
ModuleNotFoundError: No module named '_overlapped'

#

from contextvars import Context
from multiprocessing import context
from tokenize import Token
from types import MemberDescriptorType
from chardet import detect
import discord
import random
import sys
from discord import Embed
intents = discord.Intents.all()
client = discord.Client(intents=intents)
from asyncio.windows_events import INFINITE
from cProfile import run
from discord.ext import commands
from urllib import response
from asyncore import loop
from timeit import repeat
import asyncio
from discord import Member

#

line 2-20

#

i think it overlaps?

#

either that or i have the same thing twice

timid wagon
fervent shoal
#

no I have not good sir

final iron
#

Give it a read

#

!pep8

unkempt canyonBOT
#

PEP 8 is the official style guide for Python. It includes comprehensive guidelines for code formatting, variable naming, and making your code easy to read. Professional Python developers are usually required to follow the guidelines, and will often use code-linters like flake8 to verify that the code they're writing complies with the style guide.

More information:
β€’ PEP 8 document
β€’ Our PEP 8 song! :notes:

dry kelp
#

so pass that

#

i am trying to make a anti url

#

but my brain ain't workin

fervent shoal
#

Ok so ya know the code I tried to make earlier today with the sending of. Gif if a phrase was said? It does not work on phone, is that a code problem or discord problem

timid wagon
fervent shoal
timid wagon
#

It shouldn't affect things, if you've just used an on_message event

fervent shoal
#

it just doesnt work on mobile

timid wagon
fervent shoal
#

copy paste error

#

its there in code, i double checked

#

Is it a discord issue or code issue is what om@tryna know

timid wagon
#

What do you mean by "not working" though? The bot is not sending the link?

fervent shoal
#

Yea

fervent shoal
#

If I were to say the phase lf4m which is one of the trigger words, it won’t send the link, but on pc it does

slate swan
#

also idk why but it does this when i try to accept connection scope alone

timid wagon
slate swan
#

oh

neat tartan
#

@sick birch how would you pull a users message history? either through the search bar or just being able to straight pull it

timid wagon
neat tartan
#

in a guild

#

or a channel. either or

slate swan
#

is @me a placeholder? /users/@me/connections @timid wagon

timid wagon
#

So all the channels of the guild then

slate swan
#

like for @me do i put userid

pliant gulch
#

E.g the user of the token

neat tartan
pliant gulch
#

It is not a placeholder

timid wagon
fervent shoal
#

The mobile version of discord is just stupid

#

It works now

slate swan
#

or do i use the access tokens?

timid wagon
pliant gulch
#

I'm not sure how it works with Oauth2

slate swan
pliant gulch
#

But with the regular restful API I can for sure say @me is for the current in-use token

slate swan
pliant gulch
#

I assume requesting the endpoint using the access token will work though?

slate swan
#

im sure there is ye?

timid wagon
slate swan
pliant gulch
#

Try it out perhaps

#

Not sure what other token you'd use for Oauth2 other than the access token given

slate swan
slate swan
#

thank you very much,

#

@timid wagon ahh i found some more info on what u were talking about

timid wagon
#

Yep

slate swan
#

thanks mate

timid wagon
#

Sure. Try using Postman or Insomnia to test out those requests with your own headers - might help you while implementing them in code.

maiden fable
#

!pypi pypresence use this

unkempt canyonBOT
slate swan
#

I got a sense for how to do it using oauth2

#

Just gotta do some testing and get it right

#

@maiden fable what does pyprescense do?

neat tartan
sick birch
#

!d discord.TextChannel.history

unkempt canyonBOT
#

async for ... in history(*, limit=100, before=None, after=None, around=None, oldest_first=None)```
Returns an [`AsyncIterator`](https://discordpy.readthedocs.io/en/master/api.html#discord.AsyncIterator "discord.AsyncIterator") that enables receiving the destination’s message history.

You must have [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permissions to use this.

Examples

Usage...
neat tartan
#

Textchannel

fml, thanks

timid wagon
maiden fable
timid wagon
#

How is that related though thonk

maiden fable
#

U can add scopes to get access to those in terms of user information

pliant gulch
#

oh man pypresences source code

#

πŸ˜” what a doozy

maiden fable
#

I was editing it once...

pliant gulch
#

And I thought RPC was deprecated

maiden fable
#

If type checking was done at runtime, it was have been nothing but errors

pliant gulch
#

I guess I can add RPC support to rin

maiden fable
pliant gulch
#

Well the RPC docs says it's deprecated or something

maiden fable
pliant gulch
#

Oh, in private beta

maiden fable
#

Yea

pliant gulch
#

Does this mean I can still use the API or...

#

Cause I'm sure if pypresence is there regular people can set custom RPC as well

maiden fable
pliant gulch
#

discord app as in the client?

maiden fable
#

Yea

pliant gulch
#

I guess rin will get RPC support after all

maiden fable
#

The installed version

timid wagon
#

I still don't get how an RPC client will be able to get the user's connected accounts. It's not even documented

maiden fable
timid wagon
#

And I cba to look through the source code

maiden fable
#

Its a whole API wrapper

pliant gulch
#

this they have an authorise method that allows for scopes

#

Which then generate a access token I pressume?

maiden fable
#

Its just written as a RPC client, since that's what most of the people use it as, but it can also be used for authenticating

timid wagon
timid wagon
#

huh

pliant gulch
pliant gulch
#

Look at this image he sent

maiden fable
timid wagon
#

thonk well they need to update their docs

pliant gulch
#

How

pliant gulch
#

Makes sense to me, the wrapper is meant for RPC but they have a helper method for scopes

timid wagon
maiden fable
#

"if you need other scopes, add them"

#

Haha

pliant gulch
#

lmaoo

maiden fable
#

Its commented out, and yea. Comment colors suck on discord

pliant gulch
pliant gulch
#

Why is RPC even in private beta !?!?!?!?

maiden fable
#

Fuck knows. Been like that since months

#

Most probably cz discord want to implement Message Intent first 🀣

pliant gulch
#

When I was adding the intents builder to rin they haven't even added the intent flag

#

So I just had a random gap in falgs

#

πŸ˜” ocd killing me

maiden fable
#

Rip

final iron
#

andy thanks for getting the docs for akeno working

#

They're all setup and amazing

unkempt canyonBOT
#

rin/models/builders/intents.py lines 141 to 143

DIRECT_MESSAGE_TYPING = 1 << 14

GUILD_SCHEDULED_EVENTS = 1 << 16```
final iron
final iron
#

What is <<

pliant gulch
#

It's a bit shift operator

final iron
#

uhhhh

pliant gulch
#
x << y
``` == shift x left by y bits
final iron
#

I still don't understand

tender lily
#

Hello

#

Can you send me. Discord py server

pliant gulch
#

If you want to understand it I suggest searching up bit shifting and bits, etc

slate swan
pliant gulch
#

πŸ˜” that's a whole thing that I cba to say here

tender lily
#

Can you tell me. What features can I add in my bot and it wont lag if I have 1gb storage and 512 mb ram

final iron
#

You cannot estimate that

tender lily
#

WDYM

#

Can you tell me. What features can I add in my bot and it wont lag if I have 1gb storage and 512 mb ram

final iron
#

I just told you.

#

You cannot estimate something like that

timid wagon
#

There's a lot of things other than your server's hardware, that you factor in for the bot's performance

#

The number of guilds its in, the amount of events its accessing, how you implement logging, and so on.

pliant gulch
#

With discord bot's its mostly gonna be memory usage

#

And that's linear with amount of users/models it can see

#

As all of those get cached in-memory

#

Last I check, you could perhaps expect 100 users to be around 70mb??? I'm not sure it's been a while but I remember seeing some metrics

#

That depends on the member data although keep in mind, and this def changes with presence data

tender lily
#

Can anyone tell me how much ram does a full working commands discord bot need if it is in 1k server

final iron
#

1k users is pretty specific

valid galleon
#

how can i get the channel id of the one mentioned?

#

so if i do !getchannel #discord-bots, that should give me the id of the channel

final iron
unkempt canyonBOT
quick gust
#

u can just typehint the arg to discord.TextChannel, and then use this ^

boreal ravine
valid galleon
#

oh ok

boreal ravine
unkempt canyonBOT
#

class discord.abc.GuildChannel```
An ABC that details the common operations on a Discord guild channel.

The following implement this ABC...
maiden fable
#

Messages and Members intent on

#

117 Guilds

echo wasp
#

I want to send a message to a channel that is different then the one it is getting sent to rn and keep it sending to the one it is getting send to rn how would i do that? like a log for each person who used the command?

pliant gulch
pliant gulch
boreal ravine
#

oh

#

get the channel object then send a message

maiden fable
#

The default one. Lemme verify

boreal ravine
#

you can make the cache bigger

echo wasp
pliant gulch
#

Memory-usage is actually pretty low I guess, I wasn't expecting it to be that low for 80k members

boreal ravine
#

@slate swan tf happened to the old wrapper

boreal ravine
#

πŸ‘

echo wasp
#

prob a self added to the client

boreal ravine
#

yep

pliant gulch
#

seeeeshh

tender lily
#

Hey is it ok if I make economy bot?

boreal ravine
tender lily
#

Is 1gb and 512mb enough if bot is in 1k servers and it won't lag?

boreal ravine
slate swan
#

there are no errors it simply doesn't work

slate swan
#

yes

#

!intents

unkempt canyonBOT
#

Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.

To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.

Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

intents = Intents.default()
intents.members = True

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

For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.

slate swan
#

like this?

#

not only that

brazen raft
slate swan
#

yeah i removed that

slate swan
#

i have that on too

maiden fable
slate swan
#

and do you have it in the constructor?

#

idk whats that...

slate swan
#

!d discord.ext.commands.Bot

unkempt canyonBOT
#

class discord.ext.commands.Bot(command_prefix, help_command=<default-help-command>, description=None, **options)```
Represents a discord bot.

This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") you can do with this bot.

This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.
slate swan
#

try to print the member

#

if nothing prints its your intents

#

if it does its what roie said

#

no intents lol

#

nope

slate swan
#

@slate swan set intents

maiden fable
brazen raft
maiden fable
#

Add this in the bot init

slate swan
#

intents=intents

#

do py commands.Bot(intents=intents, ...)

#

ohh it's working now

#

lol

#

i missed that lol

#

Should I continue discord.py (v1) or start disnake?

#

disnake

#

disnake

#

Ouch thanks

#

Does dsnake have buttons and dropdown?

#

yes

#

yeah it does

#

Ouch nice

#

yes

slate swan
#

just change the name space from discord to disnake for old features

#

so yes

#

with new ones its a bit different

maiden fable
#

πŸ‘€

slate swan
#

Does it have py bot=False?pithink

maiden fable
#

Yea...

maiden fable
unkempt canyonBOT
slate swan
#

rin is coming nicely

maiden fable
#

A sane wrapper

slate swan
#

Ou never heard of it

slate swan
maiden fable
#

Not on PyPi the last time I checked πŸ‘€

slate swan
#

Mmm for now I guess I will do disnake

maiden fable
#

And yea, Andy would be proud of u too