#discord-bots

1 messages · Page 975 of 1

regal pulsar
#

to get a %

slate swan
#

why not just use buttons?

minor totem
#

Then you need to store that!

regal pulsar
#

just wanted to try it with select menus

slate swan
#

ah

regal pulsar
#

i need to pass that into my callback

slate swan
#

^

minor totem
regal pulsar
#

wdym

slate swan
#

you use a view to add the menu and then you send the view no?

regal pulsar
#

yeah

slate swan
#

well then just make the class accept the argument total

regal pulsar
#

what

#

im not using a class

slate swan
#

what

minor totem
regal pulsar
#
@bot.command()
async def poll(ctx: commands.Context, *, options: str):

    dict = {}
    total = 0

    list_ch = options.split("/")
    question = list_ch[0]
    list_ch.remove(question)
    question = question.replace("-", " ")
    choices = list_ch[0].split(",")

    embed = disnake.Embed(title=question, color=ORANGE)

    for ch in choices:
        embed.add_field(name=f"{ch}: ", value=f"{0}%", inline=False)
        dict.update({ch: 0})

    option_list = []

    select = Select(
        placeholder="Choose An Option",
        options=option_list,
    )

    for op in choices:
        option_list.append(SelectOption(label=op, value=op))

    async def callback(interaction: disnake.Interaction, total):

        total += 1
        dict[select.values[0]] += 1

        dict_profile = dict[select.values[0]]

        embed = disnake.Embed(title=question, color=ORANGE)

        for ch in choices:
            embed.add_field(name=f"{ch}:    ", value=f"{(dict_profile * 100) // len(choices)}%", inline=False)

        await msg.edit(embed=embed)

    select.callback = callback
    view = View()
    view.add_item(select)
    msg = await ctx.channel.send(embed=embed, view=view)

slate swan
regal pulsar
#

this command is just for me to learn how select menus work ;)

minor totem
#

What you should do, is not add an argument to the callback, because you can't tell disnake to keep calling it with the same variable, rather you should define total inside of poll() then change it inside of callback().

regal pulsar
#

total is defined under poll()

#

im not sure why the undefined error shows up

slate swan
#

im not even sure how this would be done. since i havent even used dropdowns

minor totem
#

Ah, nice, yeah you need to add nonlocal total

regal pulsar
regal pulsar
minor totem
# regal pulsar whats that

It tells Python that when you modify total it isn't a new variable, rather it is the same as the total you define in poll()

regal pulsar
#

i see

#

ill try it

#

oh it works

#

thanks :)

frozen patio
#

Can someone help me with this error?

#

I am trying to make if the amount is greater of your balance you cannot deposit it.

jolly estuary
#

Can someone help me please? I want to code a discord bot where you can make bets for footballgames or something like that… and if its possible also with an oen custom money system

slate swan
frozen patio
slate swan
#

make amount an int

spring flax
#

can anyone explain why I get this error Ignoring exception in command help: Traceback (most recent call last): File "C:\Users\tenuk\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\core.py", line 169, in wrapped ret = await coro(*args, **kwargs) File "C:\Users\tenuk\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\help.py", line 848, in command_callback return await self.send_error_message(string) File "C:\Users\tenuk\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\help.py", line 637, in send_error_message await destination.send(error) File "C:\Users\tenuk\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\abc.py", line 1504, in send data = await state.http.send_message( File "C:\Users\tenuk\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\http.py", line 420, in request raise HTTPException(response, data) disnake.errors.HTTPException: 400 Bad Request (error code: 50006): Cannot send an empty message

#

from ```py

class MyHelp(commands.HelpCommand):

async def send_bot_help(self, mapping):
    await self.context.send("This is main help")

!help <command>

async def send_command_help(self, command):
    await self.context.send("This is help command")

!help <group>

async def send_group_help(self, group):
    await self.context.send("This is help group")

!help <cog>

async def send_cog_help(self, cog):
    await self.context.send("This is help cog")

async def command_not_found(self, command):
    await self.context.send(f'Unable to find command named {command}')
frozen patio
spring flax
#

It's the command_not_found that seems to be raising the error

jolly estuary
#

Or can you explain me this

frozen patio
#

@slate swan Where would I convert to an int?

dull terrace
#

Not really. You just need to learn to code in python and learn discords API...

spring flax
unkempt canyonBOT
#

@spring flax :white_check_mark: Your eval job has completed with return code 0.

5
jolly estuary
#

Or whats the keyword for this?

frozen patio
dull terrace
frozen patio
#

Also

#

My amount is an int...

spring flax
frozen patio
spring flax
#

i just showed you that I made x an int when it was a string

slate swan
#

😳

spring flax
#

it's saying bal[0] is a string.

unkempt canyonBOT
#

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

<class 'float'>
slate swan
#

😳

spring flax
slate swan
frozen patio
#

Nvm I fixed it

#

Just indented 1 line too far 😶

slate swan
#

How do i get a code thats with letters AND numbers? Ive got this so far:

numbergen = ''.join(random.choice([chr(i) for i in range(ord('a'),ord('z'))]) for _ in range```
slate swan
#

well, when i run the code ive sent a get a randomly generated code, like wjsvf and i want to get a code with letter aswell as numbers

slate swan
slate swan
#

yes

heady sluice
slate swan
#

yes.

heady sluice
#

ok then

slate swan
unkempt canyonBOT
#

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

46_XDCobs4SJ
heady sluice
#

feel free to ask this here

#

🙂

slate swan
#

l is the length of the string

#

that works, thanks

#

💜

exotic maple
#

Hi

#

I need help, with slash commands. How do i make it so that only the author can view the bot response?

slate swan
#

send an ephemeral message

thick basin
#

Its not exactly related to dpy but ig you all use ec2 windows t2micro for hosting

exotic maple
slate swan
#

yw

slate swan
exotic maple
slate swan
thick basin
#

ye

slate swan
slate swan
#

yw

slate swan
#

!d secrets.token_urlsafe @slate swan

vale wing
#

Idk at what terms but yes

unkempt canyonBOT
#

secrets.token_urlsafe([nbytes=None])```
Return a random URL-safe text string, containing *nbytes* random bytes. The text is Base64 encoded, so on average each byte results in approximately 1.3 characters. If *nbytes* is `None` or not supplied, a reasonable default is used.

```py
>>> token_urlsafe(16)  
'Drmhze6EPcv0fN_81Bj-nA'
exotic maple
slate swan
vale wing
#

You can't send an ephemeral message through non interaction

slate swan
exotic maple
#

I dont even know

#

let me check

thick basin
vale wing
#

We can't remotely access the desktop

#

We only have SSH

thick basin
#

alr so someone told me wrong

#

ty i will try ubuntu then

vale wing
#

Ok gl with it

thick basin
#

and also is commands.is_owner() giving you all some error?

vale wing
#

Yes

#

!d discord.ext.commands.NotOwner

unkempt canyonBOT
#

exception discord.ext.commands.NotOwner(message=None, *args)```
Exception raised when the message author is not the owner of the bot.

This inherits from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")
exotic maple
slate swan
#

yes it would raise the error given above

thick basin
#

i am using dpy

slate swan
#

doesnt matter

#

still samething

#

just annotations are different

thick basin
#

ahh ty

pliant gulch
#

Should've been typehinted using ParamSpec since this is a decorator

slate swan
#

is there a way to send a timestamp that each user sees as there time on their discord account?

slate swan
slate swan
#

like the class what is it used for

slate swan
#

thats pretty useful ngl

exotic maple
#

How do i fix?

TypeError: InteractionContext.send() got an unexpected keyword argument 'ephemeral'

exotic maple
#

await ctx.send("I have sent your confession", ephemeral=True)

#

When i add the epheremeral=True, that's the only time it bugs

cloud dawn
#

What library?

exotic maple
#

What? I have discord-slash for my modules?

#

import discord
from discord import guild
import datetime
from googletrans import Translator
from discord_slash import SlashCommand

#

@cloud dawn

tidal hawk
#

send a code of whole command block

slate swan
#

should i use json or sql as db

#

im thinking sql right

tidal hawk
#

sql

slate swan
#

it better?

cloud dawn
slate swan
tidal hawk
slate swan
#

he said just use json

tidal hawk
#

Me dumbass used json as db first time

#

Biggest head ache of my life

cloud dawn
#

json is meant to be a fixed set of data not meant to write to.

slate swan
#

no

cloud dawn
# slate swan

Well he obviously has never coded a Discord bot 😂

#

I think they are called hidden and not ephemeral.

#

Not sure tough, if that won't work idk since this lib is undocumented.

slate swan
exotic maple
cloud dawn
tidal hawk
#

🤓

exotic maple
#

@cloud dawn it works, thanks

slate swan
cloud dawn
slate swan
#

what

cloud dawn
#

I once coded a website inside sql

slate swan
cloud dawn
#

That anything is possible.

slate swan
#

ok?

cloud dawn
#

Anyhow, how should i go about remaking cogs but for Client hmm

mortal dove
#

How do I make slash commands with a discord.py 2.0.0a bot?

exotic maple
#

So it could be

#

Hello my name is "word" yea

#

Not only the word

pliant gulch
# cloud dawn Anyhow, how should i go about remaking cogs but for Client hmm

Cogs are just attachable classes that implement teardown & setup methods. You can just imagine, load_extensions to import the class, then when calling setup globally it will iterate through all the methods using a metaclass, then attaching the commands & events to the client specified. You can do this pretty easily if that helps explaining it at all

mortal dove
#

@exotic maple I don't want to be annoying but you seem to have figured out slash commands, would you mind guiding me to some resources about how to set that up?

pliant gulch
slate swan
#

so you dont need to use that awful lib

exotic maple
mortal dove
#

Sure :)

mortal dove
slate swan
pliant gulch
unkempt canyonBOT
#

@pliant gulch :white_check_mark: Your eval job has completed with return code 0.

001 | __module__ __main__
002 | __qualname__ Foo
003 | my_command <function Foo.my_command at 0x7f0e04228ca0>
pliant gulch
#

Here you can see how the metaclass would work

#

All you need to do now is make a decorator which wraps the method into a "marker" for your metaclass to check for

#

Then inject that data to your client which is simply as hell

slate swan
#

thats pretty cool

pliant gulch
#

It's a somewhat niche thing overal in python though

#

You'd rarely need something like this

exotic maple
#

How do i make it,

If a specific word is spotted in a users argument of a slash command

slate swan
slate swan
#

👍

exotic maple
#

Because "is in" isnt an operator

slate swan
old crescent
#

so im following the discord.py walkthrough that's the first pinned, and when i use the test bot script that is shown in the link i'll attach, i get a
"line 6, in <module> intents.message_content = True
attributeError: 'Intents' object has no attribute 'message_content'" error

the import is fine but that is causing an error, any idea why?
https://discordpy.readthedocs.io/en/latest/quickstart.html#a*minimal*bot

slate swan
exotic maple
unkempt canyonBOT
#
in

6.10.2. Membership test operations

The operators in and not in test for membership. x in s evaluates to True if x is a member of s, and False otherwise. x not in s returns the negation of x in s. All built-in sequences and set types support this as well as dictionary, for which in tests whether the dictionary has a given key. For container types such as list, tuple, set, frozenset, dict, or collections.deque, the expression x in y is equivalent to any(x is e or x == e for e in y).

For the string and bytes types, x in y is True if and only if x is a substring of y. An equivalent test is y.find(x) != -1. Empty strings are always considered to be a substring of any other string, so "" in "abc" will return True.

old crescent
slate swan
#

pip install git+https://github.com/Rapptz/discord.py

old crescent
slate swan
#

just use the command given, you need git btw

old crescent
#

ill have to install git, do i just install all of git or is there something specific i need

old crescent
#

thanks a ton

exotic maple
#

Idk how to fix

#

And if i do == instead of in im back at square one

slate swan
unkempt canyonBOT
#

@slate swan :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | TypeError: 'in <string>' requires string as left operand, not tuple
exotic maple
#

How to fix?

#

Do I put it as str?

slate swan
#

bro the error says it all

#

youre saying if tuple in a string

#

it must be if string in tuple

exotic maple
#

But i want it to detect if theres one of the multiple words in the string

slate swan
#

!e

if 1 in (1, 2):
    print(3)

is what im saying?

unkempt canyonBOT
#

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

3
exotic maple
#

Yea..

#

But

#

With the "if 1"

#

I have a this.

`libary = ("word_1", "word_2")

async def confess(ctx, *,confession=None):

if libary in confession:`

#

Thats just some chunks of the code btw

slate swan
#

bro

pliant gulch
exotic maple
#

You are saying "if 1"

I dont want just ONE value

I have a list of values

slate swan
#

bro

#

!d if

unkempt canyonBOT
#
if

8.1. The if statement

The if statement is used for conditional execution:


if_stmt ::=  "if" assignment_expression ":" suite
             ("elif" assignment_expression ":" suite)*
             ["else" ":" suite]
``` It selects exactly one of the suites by evaluating the expressions one by one until one is found to be true (see section [Boolean operations](https://docs.python.org/3/reference/expressions.html#booleans) for the definition of true and false); then that suite is executed (and no other part of the [`if`](https://docs.python.org/3/reference/compound_stmts.html#if) statement is executed or evaluated). If all expressions are false, the suite of the [`else`](https://docs.python.org/3/reference/compound_stmts.html#else) clause, if present, is executed.
slate swan
#

!d in

unkempt canyonBOT
#
in

6.10.2. Membership test operations

The operators in and not in test for membership. x in s evaluates to True if x is a member of s, and False otherwise. x not in s returns the negation of x in s. All built-in sequences and set types support this as well as dictionary, for which in tests whether the dictionary has a given key. For container types such as list, tuple, set, frozenset, dict, or collections.deque, the expression x in y is equivalent to any(x is e or x == e for e in y).

For the string and bytes types, x in y is True if and only if x is a substring of y. An equivalent test is y.find(x) != -1. Empty strings are always considered to be a substring of any other string, so "" in "abc" will return True.

pliant gulch
#

Let me timeit as well to show

slate swan
pliant gulch
#

In [4]: a = tuple(range(1000))

In [5]: b = set(range(1000))

In [6]: def foo() -> None:
   ...:     if 999 in a:
   ...:         ...
   ...: 

In [7]: def bar() -> None:
   ...:     if 999 in b:
   ...:         ...
   ...: 

In [8]: %timeit foo()
3.8 µs ± 334 ns per loop (mean ± std. dev. of 7 runs, 100,000 loops each)

In [9]: %timeit bar()
65.5 ns ± 2.96 ns per loop (mean ± std. dev. of 7 runs, 10,000,000 loops each)
slate swan
#

hmmm nice

exotic maple
#

youre not answering my question tho

slate swan
#

bro

old crescent
exotic maple
#

`libary = ("word_one", "word_two", "word_three")

@slash.slash()
async def confess(ctx, *,confession=None):
if ctx.author.name in blacklist:
await ctx.reply("You are blacklisted from using commands due to inappropriate usage", hidden=True)
await ctx.author.send("You are blacklisted from using commands due to inappropriate usage")
return
if libary in confession:
await ctx.reply("Don't use this bot for inappropriate use. Next time you do this, it will be logged", hidden=True)
await ctx.author.send("You are at risk of being blacklisted from confession commands, warning one")`

IF ONE OF THE WORDS IN THE__LIBARY__ VARIABLE is in the argument CONFESSION, it replys that message and returns @slate swan

slate swan
#

bro i already answered you.

exotic maple
#

bro u didnt

cloud dawn
exotic maple
#

If a user enters one of the words in the libary variable, it will do what i programmed

slate swan
#

read my messages in the top because i will not repeat myself or my points. you already have been answered.

exotic maple
#

No.. dude you never answered me in a way that it can help

pliant gulch
#

Read my above explainations as well for more insight

slate swan
pliant gulch
#

hash lookup this

slate swan
slate swan
#

thanks!

exotic maple
#

I sent you my code and im asking you if theres something wrong with it?

jovial pilot
#

how do i detect if a user has been banned

cloud dawn
#

That's my idea thinking about it now.

pliant gulch
#

That's basically what I said to do

cloud dawn
#

Something like a custom iterator ```py
def walk_extensions() -> Iterator[str]:
...

pliant gulch
#

And that's literally what discord.py does with load_extension

slate swan
pliant gulch
#

Except inspect would overall make this uglier code

#

Metaclass is by far the easiest here

cloud dawn
cloud dawn
exotic maple
#

My issue is, if I do /confess "hey there word_one" it wont detect, it onlt detects if i do /confess "word_one"

cloud dawn
pliant gulch
#

All good, I'd def recommend the metaclass

#

As it gives you the name, and the bound method itself

#

So you'd just need to do, E.g self.add_command(callback)

#

Where self is your bot, of course switch this for slash commands*

slate swan
#

btw andy why do meta classes need to be a subclass of type and not object?

cloud dawn
cloud dawn
pliant gulch
slate swan
#

mhm alr

old crescent
#

so i'm still following the tutorial from earlier, i put the starter discord bot into my program, got git working with the right files to fix my earlier isses, and now i've got a large traceback list with the error:
discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal.
however, I have the bot enabled as an administrator, with bot and applications.commands checked

cloud dawn
exotic maple
#

Thanks man

#

Also, i appreciate you trying to help @slate swan sorry i wasnt much use in acting on it

pliant gulch
#

Is there really a need for any?

slate swan
#

not really lol

pliant gulch
#

The issue was they had the tokens swapped around

slate swan
#

hes just checking if a string is in a tuple

cloud dawn
pliant gulch
#

library in confession -> confession in library

slate swan
south jetty
#
    @commands.command()
    @commands.has_permissions(administrator=True)
    async def unban(self, ctx, *, member):
        banned_users = await ctx.guild.bans()
        member_name, member_discriminator = member.split('#')

        for ban_entry in banned_users:
            user = ban_entry.user

        if (user.name, user.discriminator) == (member_name, member_discriminator):
            await ctx.guild.unban(user)
      
        embed = discord.Embed(...)

        embed1 = discord.Embed(...)

        channel = self.client.get_channel(944591583796400138)

        await ctx.send(embed=embed)

        await channel.send(embed=embed1)```
How can I make the bot unban the user with their ID
pliant gulch
#

The key point you should take away is making a decorator that marks your method as a command

slate swan
pliant gulch
#

Otherwise you'd need to do some hacky stuff

slate swan
cloud dawn
slate swan
#

just use an id to fetch the member

old crescent
#

in the commmand
client.run('token')
the token of my bot must be in the quotes right?

south jetty
old crescent
#

gotcha

slate swan
unkempt canyonBOT
#

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

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

Note

This method is an API call. If you have [`discord.Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") and member cache enabled, consider [`get_user()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.get_user "discord.ext.commands.Bot.get_user") instead.

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

!d discord.Guild.unban

unkempt canyonBOT
#

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

Unbans a user from the guild.

The user must meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.

You must have the [`ban_members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.ban_members "discord.Permissions.ban_members") permission to do this.
slate swan
#
await guild_instance.unban((await bot.fetch_user(id)), reason = "no reason")

is one way of doing it

south jetty
# slate swan !d discord.ext.commands.Bot.fetch_user
    async def unban(self, ctx, *, member):
        banned_users = await ctx.guild.bans()
        member_name, member_discriminator = member.split('#')

        for ban_entry in banned_users:
            user = await ctx.fetch_user(ban_entry.user)

        if (user.name, user.discriminator) == (member_name, member_discriminator):
            await ctx.guild.unban(user)```
pliant gulch
# pliant gulch The key point you should take away is making a decorator that marks your method ...

!e ```py
from future import annotations
from typing import Callable, Coroutine, Any

class FooMeta(type):

def __new__(cls: type["FooMeta"], name: str, bases: tuple[type[Any], ...], attrs: dict[Any, Any]) -> FooMeta:
    callbacks: list[Coroutine] = []

    for name, value in attrs.items():
        if hasattr(value, "marked"):
            callbacks.append(value)

    attrs["__callbacks__"] = callbacks
    return super().__new__(cls, name, bases, attrs)

@staticmethod
def marker(name: str) -> Callable[..., Coroutine]:
    def inner(func: Coroutine) -> Coroutine:
        setattr(func, "marked", True)
        return func

    return inner

class Foo(metaclass=FooMeta):
callbacks: list[Callable[..., Coroutine]]

@marker("Something")
async def my_command(self) -> None:
    ...
cloud dawn
slate swan
south jetty
pliant gulch
#

😔

slate swan
#

😭

torn sail
old crescent
pliant gulch
pliant gulch
#

Now you just need to attach them inside of your __init__ to the client

old crescent
old crescent
slate swan
#

!d discord.Intents.message_content

unkempt canyonBOT
#

Whether message content, attachments, embeds and components will be available in messages which do not meet the following criteria:

• The message was sent by the client

• The message was sent in direct messages

• The message mentions the client

This applies to the following events...

cloud dawn
pliant gulch
#

I use metaclasses more than I should

slate swan
#

and attrs

pliant gulch
#

Most of the stuff could be done without it, but I like how clean it is

#

But it's also kind of like black magic if you don't understand metaclasses

#

Double sided sword ig

cloud dawn
old crescent
old crescent
#

will do

slate swan
#

because it should still import

pliant gulch
#

It's not very hard either

cloud dawn
old crescent
slate swan
#

wait what

#

the git files?

old crescent
slate swan
#

you mean the repo?

old crescent
#

yeah im new to git and stuff so i wasnt sure what the terms are

cloud dawn
pliant gulch
#

But procedural coding is so good

#

It's one and done, scalabitlity is high

old crescent
#

wack its still throwing the same error

cloud dawn
pliant gulch
#

Imagine using the one metaclass and writing 50 cogs for it then doing it again without it with also 50 cogs

#

😔

jovial pilot
#

here it says ctx has no attribute guild, what should i replace ctx with?

cloud dawn
cloud dawn
pliant gulch
#
import mymodule

if setup := getattr(mymodule, "setup"):
    setup(bot)
cloud dawn
#
for module in pkgutil.walk_packages(exts.__path__, f"{exts.__name__}.", onerror=on_error)
pliant gulch
#

Ah your checking if it's a functio with inspect

cloud dawn
cloud dawn
#

@pliant gulch Are you new in the server? Never seen you around here before, and I'm quite active :3

slate swan
#

thats andy

pliant gulch
#

👁️

slate swan
#

😳

cloud dawn
cloud dawn
slate swan
#

ye

jovial pilot
#

yes it is on_message

#

oh i forgot to separate it from that

cloud dawn
#

I was like where did this meta dude come from 😂

slate swan
#

😭

#

meta man😳

pliant gulch
#

Well my actual username has never been "andy" exactly

#

That was just my sever nickname

sick birch
#

i liked andy better

cloud dawn
#

Discord advanced discussions textchannel when

sick birch
slate swan
cloud dawn
tame raft
#

can anyone help me

cloud dawn
pliant gulch
#

Adanced discord discussion lmao, what would that even entail

slate swan
sick birch
#

Not sure if I'm supposed to talk about it

pliant gulch
#

I'm assuming how to make your own wrappers, etc

#

Gateway directly and hidden stuff like hidden ratelimits

cloud dawn
slate swan
pliant gulch
#

Maybe I'll bring back rin 😳 and do code vlog in advanced-discord

slate swan
#

maybe a thread and not a channel

cloud dawn
slate swan
#

would be better

pliant gulch
slate swan
cloud dawn
#

So this is my intents kwarg now intents=Intents()

pliant gulch
slate swan
pliant gulch
#

What have you read so far

cloud dawn
sick birch
#

But when a decision is made all the regulars including you guys will know about it

slate swan
pliant gulch
#

please don't look at the modals

slate swan
#

too bad

pliant gulch
#

Matter of fact I should delete main branch and only keep the "rewrite" one

cloud dawn
sick birch
#

"Nasty stuff"?

slate swan
cloud dawn
sick birch
slate swan
slate swan
cloud dawn
#

Honestly I don't know what to expect we had a pretty big discussion in #community-meta. But every solutions had it's ups and downs.

sick birch
sick birch
cloud dawn
old crescent
#

is the pycharm terminal command to run a file
"py -3 'python file name'"

cloud dawn
#

I have seen a lot less hate towards starters ever since the discussion started @sick birch
Also more mods have come by.

cloud dawn
oblique adder
#

I just need 1 more text box but the max is only 5 is there any work around ? like 2 pages ?

old crescent
cloud dawn
old crescent
#

is there a default configuration? i have to make a new one for each file everytime i make a program

#

also running a the program with the basic tutorial bot script that way causes a whole slew of errors compared to the single error im getting for using "py -3 main.py"

slate swan
old crescent
#

so like when i start up pycharm, make a program, and then create a .py file i want to run, i have to click on the configurations setting and set the path to that file and such

dull terrace
#
async def cooldown_check(interaction):
    try:
        if player_cooldown[interaction.author.id][1] % 30 == 0:
            player_cooldown[interaction.author.id] = [0, time_stamp]
        elif player_cooldown[interaction.author.id][0] > 40:
            return True
        elif player_cooldown[interaction.author.id][0] == 40:
            message = f"You're mashing the buttons too fast {interaction.author.name}!\nPlease wait 10 seconds for your cooldown to expire."
            await interaction.send(message, delete_after=10)
            prints(guild_id, message)
        player_cooldown[interaction.author.id][0] += 1
    except:
        player_cooldown[interaction.author.id] = [0, time_stamp]
    return False

How is this for a cooldown function, checks if there have been more than 40 interactions in less than 30 seconds for a user and if await cooldown_check(interaction): return when they try to interact froggy_chill deletes their id on player_cooldown if their cache auto deletes

boreal osprey
#

it is showing as if i didn't install utils. does anyone know how to help

slate swan
boreal osprey
#

and i just restarted it now and it is still doing it

slate swan
#

right?

boreal osprey
#

no, i did pip3 install utils (im on mac)

slate swan
#

try python-utils

#

also, i think its not Util with a uppercase U

#

try from util import ..

boreal osprey
slate swan
#

try from util import util

frozen patio
#

How do I define bot in an event in cogs?

boreal osprey
slate swan
# boreal osprey

also, wait you probally have python3 and python2 installed try pip install utils

#

not pip3

boreal osprey
#

i was using pip3

dull terrace
slate swan
#

Okay remove the import util part, and import sys and print(sys.version) and send me a SS

slate swan
boreal osprey
slate swan
#

Okay thats why.

boreal ravine
#

yes

slate swan
#

You're using python2, but you're installing the packages to python3.

#

do pip install utils

frozen patio
#

What is this error?

boreal ravine
sick birch
#

It's commands.cog.listener()

frozen patio
frozen patio
boreal ravine
sick birch
#

When you decorate a function without (), it calls the decorator and gives the function object to it, which is why the error happens:

def my_decorator(func): # func is a function object
  # do something
  return something
#

When it's like that, you don't have to () the decorator

#

If it's like this, you do have to () the decorator:

def my_decorator(*args, **kwargs):
  def wrapper(func):
    # do something
  return wrapper
slate swan
#

it depends if the decorator takes other arguments that arent the function that is being decorated.

frozen patio
#

I just need to make the cog listener to work

#

It is for a basic log system 😄

sick birch
#

Yeah, you need to refer to the documentation for that

#

Usually though, if a decorator doesn't take any arguments, you can leave out the () as python calls the decorator for you

blissful sparrow
cloud dawn
#

@pliant gulch That could happen but if there are people that work with slash commands daily they most likely will be up to date.

#

@slate swan Way too late for that

slate swan
frozen patio
boreal ravine
blissful sparrow
#

yeh that lol

frozen patio
#

Also commit the db

blissful sparrow
#

i have, just not shown it

cloud dawn
frozen patio
#

I couldn't know that xD

pliant gulch
#

Name restriction is also documented with a REGEX so

#

It might not be the easiest to understand

cloud dawn
pliant gulch
#

I'm just thinking that there is really no need for an extra thread towards interactions & components

#

That would fall under the API aspect discussed earlier wouldn't it?

frozen patio
pliant gulch
#

A specific topical thread for a still immature feature is kind of stretching it

frozen patio
#

Why did my bot go out on process exit 0

cloud dawn
sick birch
pliant gulch
frozen patio
#

There is nothing to make it go out on Exit 0

pliant gulch
#

They don't need to DIRECTLY use the API

#

Thats seperating frontend vs the API

sick birch
#

No, definetely not. JSON payloads for components are messy

pliant gulch
cloud dawn
sick birch
#

Also things that don't really fall into either category, we were going to do one on VPS hosting since that one comes up a lot

cloud dawn
pliant gulch
#

Either way, if you look at the current channel topic it references python libraries, so specifically this channel is meant to be topical for library abstraction

sick birch
#

Definetely, yeah

dull terrace
#

can you put min_length on a modal?

boreal ravine
#

yes

sick birch
dull terrace
sick birch
#

I think you can do it on both the short and long types

boreal ravine
#

yes

dull terrace
#

gonna use modals to create a captcha system

sick birch
#

You can do it on the paragraph types, that's for sure. Don't know about short ones though

cloud dawn
unkempt canyonBOT
slate swan
sick birch
dull terrace
#

just gonna use a button to make the modal pop up

boreal ravine
frozen patio
#

Why is my bot turn off after I start it 😐

pliant gulch
#

Maybe I'll write a tutorial on how to make a discord API wrapper or something kek

slate swan
pliant gulch
#

I've made like 3 now so I'd be expirenced enough too

cloud dawn
slate swan
frozen patio
pliant gulch
#

All of them unfinished because I hate making models though!

dull terrace
#

10 second cooldown where no buttons or anything will interact > button appears and captcha as image file > button opens modal to enter captcha

boreal ravine
pliant gulch
#

Models are my bane

cloud dawn
boreal ravine
#

No

slate swan
sick birch
# pliant gulch Models are my bane

How exactly are models done? Do you just loop through the incoming payload and use like __setattr__ to dynamically set the attributes for all fields in the payload?

frozen patio
slate swan
boreal ravine
frozen patio
#

Let my PC cool down

sick birch
slate swan
boreal ravine
cloud dawn
#

Setting default values as well and returning partial.

pliant gulch
sick birch
#

That's unfortunate

pliant gulch
#

Just imgine classes as a wrapper class for a JSON object

#

That's why I hate doing them so much

frozen patio
boreal ravine
frozen patio
#

Yea I will thank you

sick birch
frozen patio
#

What about 1 for python?

sick birch
#

Also maybe why they're called "objects"

#

Since they're excellent for data abstraction

#

You can represent almost anything using them, and they can also include functions

#
const animal = {
  name: "name",
  type: "dog",
  age: 2,
  bark: () => {
    console.log("Woof!");
  },
}
#

I wonder if you can do

x = {
  "someFunction": def y: print("Hello, world")
}
boreal ravine
#

not possible

sick birch
#

That's unfortunate. I bet you could pass it in as a first-class function though

#

!e

def sayHello():
  print("Hello, world!")
x = {
  "hello": sayHello
}
x["hello"]()
unkempt canyonBOT
#

@sick birch :white_check_mark: Your eval job has completed with return code 0.

Hello, world!
boreal ravine
#

or just a simple lambda

sick birch
#

Yeah, but say it was a long function

cloud dawn
#

😂

boreal ravine
sick birch
#

But if they do, you have to access them like you would in python:

console.log(human['name']);

as opposed to

console.log(human.name);
pliant gulch
sick birch
#

Yeah that's to be expected when you have a very expressive data structure like dicts

pliant gulch
mellow mountain
#

So i try to grab some informations from a websites API and i have two different sites.. one is with a public profile and the other one has a closed profile with less informations.. i can easily open them in my browser, both of them and see all the datas i need.. i can even get all datas from the public profile.

I just checked and it just gives me a 404 error on the closed profile, not so with the public one..

So.. im a bloody beginner. im using the requests.get function.

#

Why is it possible to view both sites in my browser without any problems, but inside my code it wont work?

cloud dawn
sick birch
# mellow mountain So i try to grab some informations from a websites API and i have two different ...

Right. First, I'm assuming you're working in an asynchronous environment, as you're asking in #discord-bots. If so, requests.get is blocking and you should use aiohttp. The real problem is with authentication. When you use your browser, the site uses your cookies to figure out if you can access a certain protected page or not. With regular requests, however, you can't do that since there's no way for the site to tell if you're supposed to be getting that information. Usually, the website's API will give you some sort of token or key and documentation on how to use it as authorization so you can access that closed profile

#

Take the discord API for example. To view certain information, like a user's guilds, you need to pass in this header:

{
  "Authorization": "Bearer <TOKEN>"
}

When you use your browser to visit that website, it automatically fills in that header for you. When you send a request, however, you have to manually include that in the headers:

requests.get("https://discord.com/api/v8/protected-endpoint", headers = {
  "Authorization": "Bearer " + token
})
pliant gulch
#

You would specifically get that token by making a user accept a Oauth2 request

#

Provided with the specific scopes, E,g guild.join or whatever it was

sick birch
#

Right. Discord saves that as a cookie most likely, however, so you don't have to log in every single time you want to visit discord

#

With requests there's no way to save that information (server side of course) so you have to pass it in every request

mellow mountain
#
        url = "https://www.habbo.de/api/public/users?name={habbo}" # the url from the website
        hdr = {'User-Agent': 'Mozilla/5.0'} 
        get_infos = requests.get(url, headers=hdr) 

        with get_infos: 
            print(get_infos.status_code)   # gives a 404 when its a closed profile
            online = get_infos.json()['online'] 
            habboname = get_infos.json()['name']
            motto = get_infos.json()['motto']
            profileVisible = get_infos.json()['profileVisible']
            lidsince = get_infos.json()['memberSince']
            lastLogin = get_infos.json()['lastAccessTime']
            id = get_infos.json()['uniqueId']

Hope i did it right so far - thats my solution currently. I will look into your answers now. 😄

So basically compare both of this sites as example
https://www.habbo.de/api/public/users?name=marius-k (public profile)
https://www.habbo.de/api/public/users?name=electro-freak93 (closed profile)

I can easily access both sites with Google Chrome - i checked the status code with print(get_infos.status_code) and it gives me a 404 in the second link, and a 200 in the first one.

sick birch
#

Does that site have API documentation?

mellow mountain
#

Not sure, didnt found one yet.

sick birch
#

Ah that's a problem

#

First make sure if they have an API or not, if not, make sure if they allow scraping. If they do (or don't mention NOT scraping) look into a library like BS4 to parse the information

#
if hasApi:
  use_api()
else:
  if allowsScraping:
    scrape()
  else:
    sad()
mellow mountain
#

I just found out that they store these datas with this link and saw they had all the datas i would like to use. Seems like there isnt an official documentation.

silent ridge
#

Hey, I want to implent 'game' status in my discord bot. What should I add? I have this right no

sick birch
silent ridge
#
@client.event
async def on_ready():
    print("[Connected]")
    activity = discord.Game(name="protecting gako's server", type=3)
  
    await client.change_presence(status=discord.Status.online, activity=activity)

@client.event
async def on_ready():
    print(f'{client.user} has connected to Discord!')
    verificationChannel = client.get_channel(verificationChannelID)

    messages = await verificationChannel.history(limit=200).flatten()
    for message in messages:
        print(message.author)
        if str(message.author) == botName:
            await message.delete()```
#

is this good?

mellow mountain
proven ore
#

or with args

proven ore
#

just make one with code of both

dull terrace
#
@client.event()
async def on_modal_submit(interaction):```
`TypeError: event() missing 1 required positional argument: 'coro'`
dull terrace
slate swan
cloud dawn
#

What is different?

dull terrace
#

shit

#

i got it

frozen patio
#

@boreal ravine I got it to work after I reinstalled nextcord, but then when I needed to rerun it it just stopped at exit code 0

pliant gulch
#

What should I go over in my discord API wrapper tutorial? Specifics please, such as what exactly intents are for

frozen patio
#

What is this-

pliant gulch
#

Bytecode

frozen patio
#

Well I just coded a log system for role message edited, deleted, and then this file popped up 👀

stone beacon
#

It makes ur python code faster

frozen patio
#

Well the bot will not turn on.

stone beacon
#

Well that's not the reason why it isn't turning on. You got any error msgs?

frozen patio
#

No errors, just doesn't run 😐

stone beacon
#

Uhh

#

You gotta run ur main bot file m8 not the cog

frozen patio
#

That would make all the sense

#

It ran so ye

#

Thank you guys alot.

slate swan
stone beacon
#

Much interested in #3

slate swan
#

same

cloud dawn
frozen patio
slate swan
pliant gulch
#

I don't even like writing models in my own wrappers

#

what makes you think I would make a tutorial on them

slate swan
pliant gulch
#

that's library abstraction that I will be avoiding

slate swan
#

smh

pliant gulch
#

buckets will be explained, so will ratelimits

slate swan
pliant gulch
#

codebase eh, I will be using poetry

pliant gulch
#

What does exts even mean here?

slate swan
#

like cogs in a sense

pliant gulch
#

No

slate swan
#

but better!

slate swan
#

ill dislike your video then😡

pliant gulch
#

It's not a video it's a markdown file

slate swan
#

NO MAKE A VIDEO

#

😡

#

that would be better for explanations

pliant gulch
#

A gist would be better for me, and I've gotten some of it written already

#

Yes I know there is a typo

slate swan
#

pretty cool

pliant gulch
#

no

sick birch
#

😢

pliant gulch
#

Do I make a tutorial repo for this

slate swan
#

Yea that would be great

#

so people can commit to it

#

and so they can make suggestions!

pliant gulch
#

Annddd another repo in my github related to discord API

sick birch
#

lol same here

slate swan
pliant gulch
#

That's asking for a lot

slate swan
#

You started the idea/project so finish it

pliant gulch
#

I wouldn't be andy if I don't procrastinate

slate swan
dull terrace
#

guys

#

captchas are so pointless

#

there's literally an extention for chrome that solves the hardest ones froggy_chill

gilded zephyr
#

How do I loop over all servers my bot is in?

#

Like for server in bot.servers: or something

dull terrace
#

disnake.errors.InteractionResponded: This interaction has already been responded to before why am i getting this when i'm returning

#
async def on_button_click(interaction):
    data = await interaction_common(interaction)
    if not data:
        return```
#

it's like it keeps retrying

gilded zephyr
marsh depot
#

Hello, good, I'm trying to recreate the say command so that if you reply to someone's message, the bot replicates what you replicate to the other user and thus ensure that the one that really replicates is the bot to another user

Anyone know where is the issue or can help me a little bit?

@bot.command()
async def say(ctx, *, message=None): # COMANDO SAY
    if message is None:
        await ctx.reply(":deny: Stuff")
    else:
        if ctx.message.reference:
            original = await ctx.fetch_message(id=ctx.message.reference.message_id)
            await ctx.message.delete()
            await ctx.reply(original)
        else:
            message = message
            await ctx.message.delete()
            await ctx.send(message)
left crater
#

can you show the error?

marsh depot
#

In the terminal don't send any error, just dont work correctly

left crater
#

is that the only command that doesn't work?

marsh depot
#

yes, for example i want to replace the ksay Hi for the bot reply my message saying the text i put after k!say , you understand?

#

Okay i have it

marsh depot
# marsh depot Hello, good, I'm trying to recreate the `say` command so that if you reply to so...
@bot.command()
async def say(ctx, *, message=None): # COMANDO SAY
    if message is None:
        await ctx.reply(":deny: Inserte la frase que desee que el bot diga")
    else:
        if ctx.message.reference:
            original = await ctx.fetch_message(id=ctx.message.reference.message_id)
            message = message
            await ctx.message.delete()
            await original.reply(message)
        else:
            message = message
            await ctx.message.delete()
            await ctx.send(message)
#

change ctx.reply(original) for replying the original message and sending the message

split merlin
#

Hi, so I want to make something like donate bot for my bot, where a member can buy subscription or something
the payment will be done via paypal but i am struggling to find where should i start or what should i do, any tips or guides will be appreciated, Thanks in advance

civic fractal
#

these are two fundamentally different systems

split merlin
slate swan
#

Like premium bot stuff?

split merlin
#

yeah

slate swan
#

sry idk

civic fractal
#
  1. discord
  2. paypal
#

start with discord, then try to add paypal

split merlin
civic fractal
#

so make a simple discord bot that can reply to commands and such

#

then ask about paypal

split merlin
#

yeah i do know how to make bots

#

so ig i need to ask about paypal then?

civic fractal
#

okay so your bot is finished and everything?

split merlin
civic fractal
#

do you have a paypal developer account?

split merlin
civic fractal
#

big yellow button

slate swan
#

Ig making a website and then login with ur discord and they pay on ur website then it gets permium account like dyno mee6 and all

split merlin
#

ooh

slate swan
#

Maybe*

#

I really dont know*

split merlin
slate swan
#

Hm

#
async def on_member_update(before, after):
    if before.status != after.status:
       return

    if str(before.status) == "online":
      if str(after.status == "offline"):
        return

    if str(before.status) == "offline":
      if str(after.status == "online"):
        return
        
    if before.activity != after.activity:
        req_act = "vanity url here"
        my_server = bot.get_guild(channel id)
        role_id = role id here
        role = my_server.get_role(role_id)
        if act := [activ.name for activ in after.activities if activ.type == ActivityType.custom and req_act in activ.name]:
            
            channel = bot.get_channel(channel id here)
            emb = discord.Embed(color=0xffffff)
            emb.description = f"""
thanks for the vanity wowow
          """
            emb.set_footer(text="vanity")
            if role in after.roles: 
              return
            else:
              await channel.send(f"<@{after.id}>", embed=emb)
              await after.add_roles(role)

        else:
              await after.remove_roles(role) ```
#

pretty sure i got this wrong as i dont have the bot token in a config

#

but i wanna set it to where the vanity status role giver will work in multiple servers and not just one server so basically i want my bot to give users the designated role when they put a servers vanity in their status

#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

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

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

slate swan
#
async def on_member_update(before, after):
    if before.status != after.status:
       return

    if str(before.status) == "online":
      if str(after.status == "offline"):
        return

    if str(before.status) == "offline":
      if str(after.status == "online"):
        return
        
    if before.activity != after.activity:
        req_act = "vanity url here"
        my_server = bot.get_guild(channel id)
        role_id = role id here
        role = my_server.get_role(role_id)
        if act := [activ.name for activ in after.activities if activ.type == ActivityType.custom and req_act in activ.name]:
            
            channel = bot.get_channel(channel id here)
            emb = discord.Embed(color=0xffffff)
            emb.description = f"""
thanks for the vanity wowow
          """
            emb.set_footer(text="vanity")
            if role in after.roles: 
              return
            else:
              await channel.send(f"<@{after.id}>", embed=emb)
              await after.add_roles(role)

        else:
              await after.remove_roles(role) 
slate swan
final iron
#

!d isinstance

unkempt canyonBOT
#

isinstance(object, classinfo)```
Return `True` if the *object* argument is an instance of the *classinfo* argument, or of a (direct, indirect, or [virtual](https://docs.python.org/3/glossary.html#term-abstract-base-class)) subclass thereof. If *object* is not an object of the given type, the function always returns `False`. If *classinfo* is a tuple of type objects (or recursively, other such tuples) or a [Union Type](https://docs.python.org/3/library/stdtypes.html#types-union) of multiple types, return `True` if *object* is an instance of any of the types. If *classinfo* is not a type or tuple of types and such tuples, a [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "TypeError") exception is raised.

Changed in version 3.10: *classinfo* can be a [Union Type](https://docs.python.org/3/library/stdtypes.html#types-union).
slate swan
#

ok

final iron
#

iirc object would be your member status object

#

classinfo would be the object you're comparing it to

slate swan
#

👍

#

That is so.

final iron
#

!e

my_var = "aaaa"
if isinstance(my_var, str):
    print(f"{my_var=}")
unkempt canyonBOT
#

@final iron :white_check_mark: Your eval job has completed with return code 0.

my_var='aaaa'
slate swan
#

!e

if isinstance((a:=1), int):
    print(a)
final iron
#

That's annoying

unkempt canyonBOT
#

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

1
slate swan
final iron
#

You can only do your_var= in f-strings

slate swan
#

i wonder why discord doesnt highlight isinstance

eternal cairn
final iron
#

It does

#

It's red

slate swan
final iron
#

Discord's weird

slate swan
#

Yes

civic fractal
#

your discord bot can just directly send the paypal link

slate swan
#

lol

#

..

slate swan
#

i dont even have a ping it triggers my ocd if i do

slate swan
slate swan
civic fractal
# civic fractal your discord bot can just directly send the paypal link
  1. someone uses a !donate command
  2. your bot reaches out to the paypal api and generates a donation link for them
  3. your bot DMs them the link
  4. they click the link and give the money
  5. PayPal reaches out to your api (a webhook)
  6. you save their premium status in a database
  7. your bot gives them the special role
slate swan
#

uh

#

bro

#

Now fine

#

Nvmd ot

supple thorn
split merlin
slate swan
supple thorn
#

It just looks like a basic block

slate swan
#

Yes

#

See this

supple thorn
#

Kek

slate swan
supple thorn
sick birch
slate swan
supple thorn
#

Used to be about 25k+

#

Left a few servers

slate swan
supple thorn
#

Cause i was at limit

slate swan
sick birch
#

it's hard to tell when i get a friend req

slate swan
supple thorn
sick birch
#

feel privileged

slate swan
supple thorn
#

I do

sick birch
#

aye 31

slate swan
#

@sick birch 👋

#

i have bluenix as a friend💜

#

Another one

sick birch
#

yay! (probably not gonna accept but still)

slate swan
sick birch
slate swan
#

Join a server then ill give u almost 15k + pings lemon_imp lemon_imp 😈 😈

#

😈

sick birch
#

lmao

slate swan
sick birch
#

anyway i'll brb have to log out and in just changed my default shell :D

high nexus
#

yo nothing for checking if a member exists is working

slate swan
#

!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.

hazy oxide
#

How to create slash command group (nextcord)?

boreal ravine
#
@bot.slash_command()
async def slash(interaction):
    ...
``` `slash` is already a sort of a group already so you can just do the below to make a subcommandd```py
@slash.subcommand()
async def subcommand(interaction)
hazy oxide
#

oh okay thanks

boreal ravine
#

👍

wanton veldt
#

hi how do i add this

 await bot.add_roles(member, role)```
to this
```    @commands.Cog.listener()
 async def on_member_join(self, member):
     with open('guilds.json', 'r', encoding='utf-8') as f:
         guilds_dict = json.load(f)

     channel_id = guilds_dict[str(member.guild.id)]
     embed=discord.Embed(title="Welcome!",description=f"{member.mention} a intrat pe server!", color=discord.Colour.random())
     embed=embed.set_thumbnail(url="https://media.discordapp.net/attachments/612746705406001213/612990390907305990/avatar.png")
     await self.bot.get_channel(int(channel_id)).send(embed=embed)

 @commands.Cog.listener()
 async def on_member_remove(self, member):
     with open('guilds.json', 'r', encoding='utf-8') as f:
         guilds_dict = json.load(f)

     channel_id = guilds_dict[str(member.guild.id)]
     embed=discord.Embed(title="Bye!",description=f"{member.mention} a parasit serverul!", color=discord.Colour.random())
     embed=embed.set_thumbnail(url="https://media.discordapp.net/attachments/612746705406001213/612990390907305990/avatar.png")
     await self.bot.get_channel(int(channel_id)).send(embed=embed)```
#

I want a command .setwelcomerole @ornate flax

#

if you got anything please ping me

high nexus
#

how I check if member exist in a discord server

#

bc what I was given before

#

isn't working

spring flax
high nexus
elfin flame
#

anyone able to help with discord js?

elfin flame
#

tysm

supple thorn
#

Just a simplified version of it

high nexus
#

Yeah so I need member

sick birch
#

So someone can be both a member and a user

high nexus
#

Yeah I need member

sick birch
#

You probably want to check if a user is in a server

#

Because if you're checking if a member exists in a server you already know that they do

high nexus
#

For what I need

sick birch
#

If you have their ID you can use get_member() with their ID

#

should be faster than looping because hash maps are O(1)

mortal dove
#

How do I implement slash commands in discord.py?

civic fractal
#

Discord doesn't provide an API for that

#

so it isn't possible without breaking their tos

dull terrace
mortal dove
#

bruh

dull terrace
#

what isn't possible suspicious

#

wait so discord doesnt let you stream video as a bot?

slate swan
civic fractal
mortal dove
#

haha I saw, dw 😅

supple thorn
dull terrace
#

it would be pretty dope if you could stream video as a bot, you could actually make an animated game

#

choose your own adventure story would be cool too

civic fractal
dull terrace
#

sucks

slate swan
#

..

dull terrace
#

i imagine its mostly due to the fact that it would take up so much bandwidth for discord though

civic fractal
#

unlikely

#

humans can stream video no problem

dull terrace
#

their api is literally limited to 50 per second for bots

supple thorn
#

Or discord are just racist to bots

slate swan
#

wait lol

dull terrace
#

they really wouldn't be able to handle a bot on every server streaming video

civic fractal
mortal dove
slate swan
#

ye ik

mortal dove
#

Genius

civic fractal
#

doesn't have anything to deal with bandwidth

dull terrace
#

you really think discord servers could handle that

civic fractal
#

you can still stream hd audio

#

absolutely they can

slate swan
supple thorn
#

Hello okimi

civic fractal
#

50 messages per guild per second

#

5 messages per channel per second

dull terrace
#

discord does not have youtubes infastructure

civic fractal
#

yes they do

#

its easy to expand, too

#

discord is already one of the most visited sites in the world

dull terrace
civic fractal
#

they have plenty of infrastructure

civic fractal
#

employees are expensive

#

web infrastructure isnt

dull terrace
#

i seriously doubt you're correct, i wish i could get some stats on it

slate swan
sick birch
#

It's because users aren't meant to be botted. Bots are meant to be botted, so the resources required would be much much higher for bots to stream

slate swan
#

thats why most currency bot's have cooldowns

#

ig

civic fractal
dull terrace
civic fractal
#

that might be per shard

slate swan
dull terrace
#

if you had streaming bots you'd have an average of 1 on every server

slate swan
#

seems like a good point of your argument

dull terrace
#

some would have 3 with various things going

civic fractal
dull terrace
#

and thinking discord is set up to handle that is dumb, they mainly handle text and voice which is barely any work in comparison

civic fractal
#

I also don't think you understand what it means to be a top 100 visited website

slate swan
#

..

dull terrace
#

they would have to massively expand

civic fractal
#

??

dull terrace
#

expensive af

civic fractal
#

like I said, its extremely cheap relative to their employment cost

slate swan
#

pardon?

sick birch
#

Cheap does not equal no cost

#

No cost is better than cheap

#

Therefore no cost path should be followed

slate swan
#

what is this convo even about im so confused on the point here

sick birch
slate swan
civic fractal
#

its crazy to think they wouldn't allow that due to bandwidth

#

not worth discussing

dull terrace
slate swan
#

isnt that too much bandwith? especially for bots running multiple videos at a time?

dull terrace
#

it's not just bandwidth

slate swan
sick birch
#

discords video sucks to be honest

civic fractal
sick birch
#

I don't think i've come across a good platform with good video as of yet

civic fractal
#

what kind of point is that

pliant gulch
slate swan
#

yep

sick birch
pliant gulch
sick birch
#

It's not going to hurt them to continue avoiding it

slate swan
#

they lock stream quality to 720 for no nitro users same with files guilds etc

dull terrace
#

they just doing all that for fun though slump_bear

slate swan
#

its discord after all!

final iron
#

What is even going on

sick birch
#

Well they're making money which is more than I've ever done so I have to respect that

dull terrace
#

someone said it would be ez for discord to let bots stream video @final iron

sick birch
#

nitro or no

final iron
#

Oh that's dumb

dull terrace
#

millions of servers constantly streaming video from bots slump_bear

final iron
#

That would be so resource intensive

slate swan
#

discord can but they wont🗿

sick birch
#

They can but it takes up a lot of resources

slate swan
#

hence the reason why they wont

final iron
sick birch
#

Right so we shouldn't make it seem like they're baddies for not doing it

dull terrace
#

the only way that happens is if they decide to start putting ads before entering every server

slate swan
dull terrace
#

or on every video stream

slate swan
slate swan
#

olie you gave discord an idea bro

mental oar
sick birch
dull terrace
#

imagine having to watch a 2 min pre roll ad before you video chat with a friend

slate swan
#

want a break of the ads?

pliant gulch
#

Read a discord data mine like a while ago and it seemed like they were gonna add some premium subscription guild role or something

#

We love money

slate swan
#

Money!

sick birch
#

Course we do

mental oar
#

Imagine targeted ads in text chat… shudder

pliant gulch
#

“Wait 5 seconds and watch this short ad to continue sending messages”

sick birch
#

What, feeding text messages into some neural network to pump out targed ads based on our messages?

slate swan