#discord-bots

1 messages · Page 669 of 1

final iron
#

I suspected it when I first saw the error but I wanted to confirm

jovial plover
#

it's not self bot lol

#

idk how to do that even

sullen shoal
#

then you shouldnt get that shit

final iron
#

You shouldn't be getting that error

jovial plover
#

So the bot has Admin perms by default

sullen shoal
#

contact discord if you do so

jovial plover
#

Like when you create invite, i ticked admin

sullen shoal
#

contact discord

#

or try changing the token a bew one

#

new

#

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

mystic grotto
#
     for i in range(len(level)):
       if lvl == levelamt[1]:
         await message.author.add_roles(discord.utils.get(message.author.guild.roles, name=level[i]))
         embed = discord.Embed(description=f"{message.author.mention} you have gotten the role **{level[i]}**!!")
         embed.set_thumbnail(url=message.author.avatar_url)
         await message.channel.send(embed=embed)```
#

i have this code but it doesnt give me the role when i level up

#

anyone have an idea on what could be wrong

#

ive given my bot manage roles so there shouldn't be a problem with the perms

jovial plover
#

Is there a way to check channel's type?
Like community, text, voice?

upbeat otter
#

half the code isnt even there

mystic grotto
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).
upbeat otter
#

use the channel classes

maiden fable
#

Or

mystic grotto
boreal ravine
#

how do you do this? do you do it manually or is there a button for it

maiden fable
#

Lemme get it

mystic grotto
upbeat otter
sullen shoal
mystic grotto
boreal ravine
sullen shoal
#

when you copy link with highlights

boreal ravine
#

i mean the gh link

maiden fable
#

U can do channel.__class__

sullen shoal
boreal ravine
#

thanks

upbeat otter
maiden fable
#

O

#

Btw type() is also there

upbeat otter
maiden fable
#

With 85% discord scaling (zoom)

upbeat otter
maiden fable
upbeat otter
sullen shoal
#

you gonna need glasses soon ig

maiden fable
sullen shoal
#

oh yeah i remember keeping a font like that

upbeat otter
#

!ot

unkempt canyonBOT
sullen shoal
#

it was crap for coding

maiden fable
slate swan
#

Kinda ot but one of my cousins is trying to code games what languages do you guys recommend i recommended him c++ and java

visual island
#

for mobile/desktop?

slate swan
#

Probably desktop

#

Hes a beginner btw

visual island
#

for desktop any language is fine actually, based on their preferences

#

for mobile, Java is the easiest

frigid tulip
#

could i have the python for dummies pdf?

slate swan
visual island
#

depends, if you want to make 3D games most of the game engine uses c#

slate swan
#

Well i think hes dream is too become a high level dev for games like minecraft and others ik minecraft java uses ofc java and minecraft bedrock uses c++

weary gale
#

how can one host their bot for free

slate swan
weary gale
#

pslpslspls'

frigid tulip
#

do any of you have the python for dummies pdf?

slate swan
weary gale
#

alr thx

slate swan
#

But compared to vps is nothing good

upbeat otter
slate swan
boreal ravine
#

!ot

unkempt canyonBOT
visual island
upbeat otter
boreal ravine
upbeat otter
boreal ravine
upbeat otter
boreal ravine
#

nice

weary gale
#

like u can use it for like a month or something

boreal ravine
weary gale
#

bruh

boreal ravine
#

you can make another account though

weary gale
#

:/

boreal ravine
#

if you're up for it that is

visual island
weary gale
slate swan
#

Doesnt even know how to make a function correctly not being offensive lol

weary gale
#

without having to use replit or self hosting

boreal ravine
weary gale
#

is that time limited?

boreal ravine
#

i dont think so

#

its 100% free and if you want more stuff you can pay

weary gale
visual island
slate swan
visual island
#

if they really serious learning it then it might not took some time. But if they like, do it as a hobby then nah

#

But they could try eventually

slate swan
boreal ravine
#

why do you even wanna make a game if you dont have time lol

slate swan
#

He mostly admires me so hes kinda learning a bit from me but im not really orientated to game development

slate swan
boreal ravine
#

how old is he?

slate swan
boreal ravine
#

hm

slate swan
#

He is passionate about his stuff hes just very limited to things

weary gale
slate swan
#
import discord
from discord.ext import commands
from discord import Activity
from typing import Optional, Union

Token = ""

bot = commands.Bot(command_prefix=".", owner_id=521325126722125874)

@bot.command(name="ping")
async def pingme(ctx):
    # ws ping
    embed = discord.Embed(title=':ping_pong: Ping', color=discord.Colour.dark_gold(), timestamp=ctx.message.created_at)
    embed.add_field(name=":green_heart: WS Ping", value=f"```py\n{round(bot.latency * 1000)} ms```")

@bot.event
async def on_ready():
 print("Launch Successful!")

bot.run(Token)
#

no errors but .ping doesn't work

#

( doesn't send anything )

maiden fable
#

Uhhh

slate swan
maiden fable
#

Lmao

slate swan
#

🕴️

maiden fable
#

Bruh

ocean leaf
#

after adding self.client.preocess_commands, my bot is sending every commands 2 times

#

any help?

slate swan
#

dont use that in bot.listen() or Cog.listener()

weary gale
#

why does this come up three times

ocean leaf
weary gale
# ocean leaf code?
async def ban(ctx,member:discord.Member, *, reason=None):
    await member.ban(reason=reason)
    await ctx.send(f'{member.mention} was banned')```
ocean leaf
quasi axle
#

const Discord = require('discord.js');

const client = new Discord.Client({ intents: 32767 })

const prefix = '$';

client.once('ready', () => {
console.log('Twinnem is online!');
})

client.on('message', message =>{
if(!message.coontent.startsWitch(prefix)|| message.author.bot) return;

const args = message.content.slice(prefix.length).split(/ +/);
const command = args.shift().toLowerCase();

if(command === 'ping'){
message.channel.send('pong!');
}
});

client.login('token'); did i do some wrong to make the command not work?

ocean leaf
#

i'll remove it?

quasi axle
#

yeah this is js?

slate swan
slate swan
ocean leaf
ocean leaf
quasi axle
#

ty

slate swan
weary gale
#

what

slate swan
slate swan
ocean leaf
#

yes it worked thanks

slate swan
# weary gale what

you clicked on run , but didnt click on stop before running the bot again

slate swan
weary gale
#

oh

slate swan
slate swan
# weary gale oh

you can control it from here , the square to stop it , the round one to rerun the bot ....

slate swan
slate swan
#

i mean this

ocean leaf
slate swan
ocean leaf
#
class levelsys(commands.Cog):
    def __init__(self, client):
        self.client = client

    async def on_message(self, ctx):
        await self.client.process_commands(ctx)
        mongo_url = "mongodb+srv://mongo url"
        cluster = MongoClient(mongo_url)
        db = cluster["discord"]
        collection = db["levelling"]
        author_id = ctx.author.id
        author = ctx.author

        user_id = {"_id": author_id}

        if ctx.author == self.client.user:
            return
        if ctx.author.bot:
            return
        if not ctx.channel.id in talk_channels:
            return

        if(collection.count_documents({}) == 0):
            user_info = {"_id": author_id, "level": 1, "xp": 0}
            collection.insert_one(user_info)

        if(collection.count_documents(user_id) == 0):
            user_info = {"_id": author_id, "level": 1, "xp": 0}
            collection.insert_one(user_info)

        exp = collection.find(user_id)
        for xp in exp:
            cur_xp = xp["xp"]

            new_xp = cur_xp + 1
        collection.update_one({"_id": author_id}, {"$set": {"xp": new_xp}}, upsert = True)

        lvl = collection.find(user_id)
        for levl in lvl:
            lvl_start = levl["level"]
            new_level = lvl_start + 1
        if cur_xp >= round(5 * (lvl_start ** 4 / 5)):
            collection.update_one({"_id": author_id}, {"$set": {"level": new_level}}, upsert = True)
            level_updates_channel = self.client.get_channel(884386906064965662)
            await level_updates_channel.send(f"{author.mention} just levelled up to **level {new_level}**")
slate swan
ocean leaf
slate swan
# ocean leaf here it is
        if ctx.author == self.client.user:
            return
        if ctx.author.bot:
            return
        if not ctx.channel.id in talk_channels:
            return``` any of these conditions are true mb
#

Oh its indian english my bad🕴️

ocean leaf
slate swan
#

its a british word

slate swan
ocean leaf
slate swan
#

add it back , remove process_commands only

slate swan
ocean leaf
#

thank you

slate swan
slate swan
slate swan
#

is there like a website or doc that has a list of color?

sick talon
#

how can i make a command disabled for a user for a specific user??
the command which i want to disable have cooldown, so if the user uses that disabled command then he would get the cooldown after the command gets enabled
how to fix this issue ?

slate swan
slate swan
shadow wraith
#

discord.Colour.<>() is only just a preset

visual island
#

you dont need the #

sick talon
shadow wraith
weary gale
#

whats the command to make multiple aliases for a command?

slate swan
#

The color name has the color hex inside but really cant get a specific color

shadow wraith
weary gale
shadow wraith
#

oh yeah and i use lists to make multiple prefixes 💀

slate swan
#

You making multiple aliases there?

shadow wraith
#

theme is one monokai

slate swan
#

Im not going to say a word

shadow wraith
#

a word

#

thank me later

shadow wraith
slate swan
shadow wraith
#

i think i should ditch f strings and use .format()

shadow wraith
#

wait how did i see that

slate swan
shadow wraith
#

🤔

slate swan
#

Format still is usable but f strings are better syntax wise

shadow wraith
#

ill prob ditch f strings once i realize how to use sql in discord.py

slate swan
shadow wraith
slate swan
boreal ravine
shadow wraith
slate swan
#

please teach me

shadow wraith
#

i bet this is another spoonfeed trick

slate swan
#

And no need for int+str its called a complex

boreal ravine
#

they are bad

slate swan
#

A complex= a mix of integers and strings

slate swan
#

nvm im just gonna go for .color stuff

slate swan
boreal ravine
slate swan
#

Not really hard

boreal ravine
#

!d discord.Colour <=

unkempt canyonBOT
#

class discord.Colour(value)```
Represents a Discord role colour. This class is similar to a (red, green, blue) [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)").

There is an alias for this called Color...
shadow wraith
#

i only use classes to make discord buttons smh

boreal ravine
#

you dont use cogs?

slate swan
untold token
#

For SQL statements

shadow wraith
untold token
#

That's an exception

slate swan
#

Got my new pc and now my os cant find any files for some reason

untold token
#

f string SQL statements are dangerous as they can be used for SQL injection

#

But there are ways to avoid that too

maiden fable
#

Imagine using SQL

untold token
#

Postgres uses SQL btw

slate swan
#

Used os and aiofiles and cogs but seems like it never finds the file even with its path or name

untold token
#

and SQL is good

boreal ravine
#

Imagine not using a nosql database

shadow wraith
#

wanna see some "good" classes of discord buttons:

import discord as shoe
from discord.ext import commands

class fdjsidsjfo(shoe.ui.View):
  @discord.ui.button(style=shoe.ButtonStyle.yellow, label='💀')
  async def bru(self, button: discord.Button, interaction: discord.Interaction):
    await interaction.response.send_message("")
untold token
#

They suck

#

Jk

boreal ravine
#

yello doesnt exist though

shadow wraith
#

🥚sactly

boreal ravine
#

what are you on about

shadow wraith
slate swan
boreal ravine
#

there are only 4-5 button styles in discord's api

shadow wraith
slate swan
untold token
slate swan
#

Think its just them

shadow wraith
untold token
#

imo

boreal ravine
untold token
shadow wraith
boreal ravine
#

yes

shadow wraith
#

its just better

untold token
#

It's a document based storage system and it's based as key values

untold token
slate swan
#

🕴️

untold token
#

Try storing relational data in mongoDB

shadow wraith
#

true

untold token
#

or maybe some complicated data

boreal ravine
untold token
#

Because they are good

#

¯\_(ツ)_/¯

boreal ravine
#

eh mongodb is good too

visual island
maiden fable
#

😐

untold token
#

Lmao

slate swan
#

Me learning about dbs like: grumpchib 🚶

visual island
#

SQL is like the easiest language that ever exists

untold token
#

Only NoSQL db that I like is redis

boreal ravine
maiden fable
#

Best DB Ever: || JSON ||

#

:D

boreal ravine
slate swan
visual island
boreal ravine
#

jconc > regular json

untold token
#

tables rows columns, cells, datatypes

maiden fable
visual island
slate swan
untold token
slate swan
#

.txt > .json

#

🕴️

untold token
#

Anyways

visual island
#

I used that once, a while ago lol

untold token
#

This is getting off topic

visual island
#

yeah true

slate swan
#

Ik this is ot but how can i learn about sqlite3 🕴️

visual island
#

tutorials on google

slate swan
boreal ravine
visual island
slate swan
slate swan
slate swan
#

never thought that would even be a thing

maiden fable
slate swan
maiden fable
slate swan
#

what did you use

maiden fable
#

The repo is on my GitHub

#

discdb

slate swan
#

oh shit

#
@bot.command(name="ping")
async def pingme(ctx):
    # ws ping
    embed = discord.Embed(title=":green_heart: WS Ping", value=f"```py\n{round(bot.latency * 1000)} ms```",color=discord.Colour.red())
    await ctx.send(embed=embed)
#

was sypposed to send

#

do you still use it

#

sended:

slate swan
maiden fable
slate swan
#

yes

boreal ravine
quick gust
slate swan
#

this is somewhat interesting to me

slate swan
#
    embed = discord.Embed(title="title kwarg",description="description kwarg",color=discord.Colour.red())
    await ctx.send(embed=embed)
boreal ravine
#

!d discord.Embed @slate swan

unkempt canyonBOT
#

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

len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.

bool(b) Returns whether the embed has any data set.

New in version 2.0.

Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty").

For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") for you.
boreal ravine
#

it has no value kwarg, instead use the description kwarg to put something in the embeds description

weary gale
#
async def mute(ctx, member : discord.Member, *, reason=None):
    if (not ctx.author.guild_permissions.manage_messages):
        await ctx.send('u need permission dumbass')
        return
    guild = ctx.guild
    muteRole = discord.utils.get(guild.roles, name="muted")

    if not muteRole:
        await ctx.send('no mute role was found, creating muterole')
        muteRole = await guild.create_role(name="muted")

        for channel in guild.channels:
            await channel.set_permissions(muteRole, speak=False, send_messages=False, read_message_history=True, read_messages=True)
        await member.add_roles(muteRole, reason=reason)
        await ctx.send('user is muted')
        await member.send(f"you've been muted from **{guild.name}** | reason: **{reason}**")

@client.command()
async def unmute(ctx, member : discord.Member, *, reason=None):
    if (not ctx.author.guild_permissions.manage_messages):
        await ctx.send('u need permission dumbass')
        return
    guild = ctx.guild
    muteRole = discord.utils.get(guild.roles, name="muted")

    if not muteRole:
        await ctx.send("the muted role was not found")
        return

    await member.remove_roles(muteRole, reason=reason)
    await ctx.send('user is unmuted')
    await member.send(f"you've been muted from **{guild.name}** | reason: **{reason}**")```
why dont these work
boreal ravine
#
  1. Because it's copied obviously
  2. Doesn't work isn't in my vocabulary, give me the error
prisma spoke
prisma spoke
prisma spoke
#

u saw somewherre ths code?

boreal ravine
outer basalt
#

jsk py ```py
abc = [{'footer': {'text': 'Updated'}, 'thumbnail': {'url': 'https://cdn.discordapp.com/avatars/711043296025378856/243d61cb7bff98fd1844b465a88f46cf.png?size=1024'}, 'author': {'name': 'ggashish#6132', 'icon_url': 'https://cdn.discordapp.com/avatars/711043296025378856/243d61cb7bff98fd1844b465a88f46cf.png?size=1024'}, 'fields': [{'inline': False, 'name': ':unmute: Self un-mute', 'value': '@outer basalt un-muted themself'}], 'color': 3066993, 'timestamp': '2021-12-11T07:02:14.556425+00:00', 'type': 'rich', 'url': 'https://discord.com/users/711043296025378856', 'title': 'Member voice state updated'},

{'footer': {'text': 'Updated'}, 'thumbnail': {'url': 'https://cdn.discordapp.com/avatars/711043296025378856/243d61cb7bff98fd1844b465a88f46cf.png?size=1024'}, 'author': {'name': 'ggashish#6132', 'icon_url': 'https://cdn.discordapp.com/avatars/711043296025378856/243d61cb7bff98fd1844b465a88f46cf.png?size=1024'}, 'fields': [{'inline': False, 'name': ':mute: Self mute', 'value': '@outer basalt muted themself'}], 'color': 3066993, 'timestamp': '2021-12-11T07:02:15.078014+00:00', 'type': 'rich', 'url': 'https://discord.com/users/711043296025378856', 'title': 'Member voice state updated'}]

embeds = [discord.Embed.from_dict(i) for i in abc]
await ctx.send(embeds=embeds)

#

this is not sending the first embed

boreal ravine
#

whats the error besides it not sending the embeds

outer basalt
#

no error

#

it just sends the second one

visual island
#

seems you're using an eval to do that. How about doing it without eval?

weary gale
#

discord.ext.commands.errors.CommandRegistrationError: The command help is already an existing command or alias.

#

i dont have another help command?

#

how do i fix this

prisma spoke
weary gale
# prisma spoke code please
async def help(ctx):
  embed = discord.Embed(title="help", description="`$utility`,`$moderation`", colour=000000)
  await ctx.send(embed=embed)```
visual island
#

put help_command = None in your bot's constructor

weary gale
#

uh

prisma spoke
weary gale
#

wheres that

prisma spoke
weary gale
#

what

prisma spoke
#

yes

weary gale
#

wtf

weary gale
prisma spoke
prisma spoke
#

what do u not understand in this?

weary gale
#

client = commands.Bot(command_prefix = '$')

#

so like in the brackets

prisma spoke
weary gale
#

idfk

prisma spoke
weary gale
#

no

prisma spoke
weary gale
#

trying to learn

prisma spoke
weary gale
#

calm tf down

visual island
#

stop being rude

weary gale
#

can u atleast tell me where to put it pls

prisma spoke
visual island
#

<@&831776746206265384>

weary gale
#

fr

visual island
#

okay

weary gale
#

this guy is too mad

prisma spoke
prisma spoke
prisma spoke
#

if it is i shud have called mods long time ago

#

when it happened to me

west escarp
#

Alright

#

everyone take a deep breath please

weary gale
#

lmao

prisma spoke
west escarp
#

While a discord bot is not the most advised first project to learn python, it is a valid one

#

And we try not to discourage people from doing that, as a lot of people get into python from making one

prisma spoke
west escarp
#

Nobody is required to help, so if you're having trouble there's no problem with you backing off

#

I mean, yes, but also no. A lot of things are red plug red outlet, and that's enough to get by with the basics

west escarp
weary gale
#

im confused

#

so how do i remove the default help command

#

that i didnt even addx

west escarp
#

pass help_command=None to the commands.Bot() call

#

It's an unfortunately common stumbling block because you have to remove it a specific way

weary gale
#

client = commands.Bot(help_command=None, command_prefix = '$')

west escarp
#

yep

weary gale
#

thanks

#

u made that so easy lol

west escarp
#

Yeah, well, one step at a time :P

#

Old man voice: "when I was your age discord.py didn't have async"

shadow wraith
#

guys what happened here

shadow wraith
# weary gale thanks

a recommendation, if you're making a custom help command there won't be any form of handling so make sure to add a @help.error error handler if you know about those

#

if you don't you could always read documentation, i'm on the not-spoonfeeder side

boreal ravine
#

use the default one, its already good

shadow wraith
#

he's removing help command though

#

i use minimalhelpcommand 😎

boreal ravine
#

This help command subclasses/edits the default help command. Overall it looks pretty nice.

maiden fable
#

Did u just... color out the dpy server invite?

boreal ravine
maiden fable
#

There's a different server?

boreal ravine
#

yes, rdanny, dpy, danny

maiden fable
#

O

weary gale
#
Traceback (most recent call last):
  File "C:\Users\the rore\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke        
    await ctx.command.invoke(ctx)
  File "C:\Users\the rore\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 855, in invoke       
    await self.prepare(ctx)
  File "C:\Users\the rore\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 789, in prepare      
    await self._parse_arguments(ctx)
  File "C:\Users\the rore\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 697, in _parse_arguments
    transformed = await self.transform(ctx, param)
  File "C:\Users\the rore\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 542, in transform    
    raise MissingRequiredArgument(param)
discord.ext.commands.errors.MissingRequiredArgument: member is a required argument that is missing.```
error the comes up
#
async def userinfo(ctx, member = member or ctx.author, member: discord.Member):

    roles = [role for role in member.roles]

    embed = discord.Embed(colour=member.color, timestamp=ctx.message.created_at)

    embed.set_author(name=f"user info - {member}")
    embed.set_thumbnail(url=member.avatar_url)

    embed.add_field(inline = False, name="ID:", value=member.id)
    embed.add_field(inline = False, name="guild name:", value=member.display_name)

    embed.add_field(name="created at:", value=member.created_at.strftime("`%a, %#d %B %Y, %I:%M %p UTC`"))
    embed.add_field(inline = False, name="joined at:", value=member.joined_at.strftime("`%a, %#d %B %Y, %I:%M %p UTC`"))

    await ctx.send(embed=embed)```
with this command
weary gale
#

oh

#

im smart

#

wait how can i make it so it automatically uses me

#

instead of having to mention myself

lament mesa
#

ctx.author

boreal ravine
#

use an or statement, set the member param to None```py
member = member or ctx.author

velvet tinsel
#

or member: discord.Member

boreal ravine
velvet tinsel
#

I never really read it kk

boreal ravine
#

lol

boreal ravine
#

inside the function

#

before u use the member param

weary gale
#

what is a param

boreal ravine
#
def b(member): #member is a param
weary gale
#

onh

weary gale
# boreal ravine ```py def b(member): #member is a param ```
async def userinfo(ctx, member = member or ctx.author, member: discord.Member):

    roles = [role for role in member.roles]

    embed = discord.Embed(colour=member.color, timestamp=ctx.message.created_at)

    embed.set_author(name=f"user info - {member}")
    embed.set_thumbnail(url=member.avatar_url)

    embed.add_field(inline = False, name="ID:", value=member.id)
    embed.add_field(inline = False, name="guild name:", value=member.display_name)

    embed.add_field(name="created at:", value=member.created_at.strftime("`%a, %#d %B %Y, %I:%M %p UTC`"))
    embed.add_field(inline = False, name="joined at:", value=member.joined_at.strftime("`%a, %#d %B %Y, %I:%M %p UTC`"))

    await ctx.send(embed=embed)```
like this?
boreal ravine
#

no

weary gale
#

uh

boreal ravine
#

in the function, not where u define the function

weary gale
#

what

weary gale
#

i dont understand how

boreal ravine
#
def b(member): #where u define the funtion
    member = member or ctx.author

    ...
``` ^
weary gale
#

oh

#

ok now i know where the function is

boreal ravine
#

yes

weary gale
# boreal ravine yes

discord.ext.commands.errors.MissingRequiredArgument: member is a required argument that is missing.

#

this comes up?

slate swan
#

member : discord.Member = None

#

In your def parameters.

boreal ravine
#

or do what winrar said

slate swan
#

Well this is needed, otherwise it will always be a required argument.

weary gale
# boreal ravine show code
async def userinfo(ctx, member: discord.Member):

    member = member or ctx.author
    roles = [role for role in member.roles]

    embed = discord.Embed(colour=member.color, timestamp=ctx.message.created_at)

    embed.set_author(name=f"user info - {member}")
    embed.set_thumbnail(url=member.avatar_url)

    embed.add_field(inline = False, name="ID:", value=member.id)
    embed.add_field(inline = False, name="guild name:", value=member.display_name)

    embed.add_field(name="created at:", value=member.created_at.strftime("`%a, %#d %B %Y, %I:%M %p`"))
    embed.add_field(inline = False, name="joined at:", value=member.joined_at.strftime("`%a, %#d %B %Y, %I:%M %p`"))

    await ctx.send(embed=embed)```
slate swan
#

Adding a default value to None makes it optional

boreal ravine
slate swan
weary gale
#

where

slate swan
weary gale
#
async def userinfo(ctx, member: discord.Member, member : discord.Member = None):

    member = member or ctx.author
    roles = [role for role in member.roles]

    embed = discord.Embed(colour=member.color, timestamp=ctx.message.created_at)

    embed.set_author(name=f"user info - {member}")
    embed.set_thumbnail(url=member.avatar_url)

    embed.add_field(inline = False, name="ID:", value=member.id)
    embed.add_field(inline = False, name="guild name:", value=member.display_name)

    embed.add_field(name="created at:", value=member.created_at.strftime("`%a, %#d %B %Y, %I:%M %p`"))
    embed.add_field(inline = False, name="joined at:", value=member.joined_at.strftime("`%a, %#d %B %Y, %I:%M %p`"))

    await ctx.send(embed=embed)```
#

like that?

slate swan
#

No.

weary gale
#

what

slate swan
#

Don't add a new parameter.

weary gale
#
async def userinfo(ctx, member : discord.Member = None):

    member = member or ctx.author
    roles = [role for role in member.roles]

    embed = discord.Embed(colour=member.color, timestamp=ctx.message.created_at)

    embed.set_author(name=f"user info - {member}")
    embed.set_thumbnail(url=member.avatar_url)

    embed.add_field(inline = False, name="ID:", value=member.id)
    embed.add_field(inline = False, name="guild name:", value=member.display_name)

    embed.add_field(name="created at:", value=member.created_at.strftime("`%a, %#d %B %Y, %I:%M %p`"))
    embed.add_field(inline = False, name="joined at:", value=member.joined_at.strftime("`%a, %#d %B %Y, %I:%M %p`"))

    await ctx.send(embed=embed)```
like this?
slate swan
#

Yes.

weary gale
#

thanks

#

so is railway better than heroku for hosting?

#

@boreal ravine

boreal ravine
#

no idea lol

west escarp
#

Yes

weary gale
#

cool

west escarp
#

heroku wipes their dynos and more because they're intended for stateless web applications

#

railway has an example on hosting a discord bot in their docs so

weary gale
#

oh cool

west escarp
#

See this actually

tiny ibex
#

Train?

west escarp
#
Railway

Railway is an infrastructure platform where you can provision infrastructure, develop with that infrastructure locally, and then deploy to the cloud.

tiny ibex
west escarp
#

I deploy on my rasberri pi and other old computers I have laying around as servers

tiny ibex
#

?

#

Or free

west escarp
#

There's a free tier

tiny ibex
#

??

tiny ibex
west escarp
#
Railway

Railway is an infrastructure platform where you can provision infrastructure, develop with that infrastructure locally, and then deploy to the cloud.

tiny ibex
west escarp
#

512mb ram, 1gb disk

#

infinite, it appears

#

although I don't think they're very powerful hours

tiny ibex
#

WoW that's amazing

boreal ravine
west escarp
#

Significantly more than I need as well

tiny ibex
twin moon
#
try: 
  client.run(TOKEN)
except:
  Default_TOKEN = info["Default TOKEN"]
  client.run(Default_TOKEN)``` Lol this still gives me an error
twin moon
#

event loop is closed

west escarp
#

Mines 300 mb and it's got a lot of libraries too

boreal ravine
boreal ravine
twin moon
# boreal ravine nicee
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/nextcord/http.py", line 380, in static_login
    data = await self.request(Route('GET', '/users/@me'))
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/nextcord/http.py", line 335, in request
    raise HTTPException(response, data)
nextcord.errors.HTTPException: 401 Unauthorized (error code: 0): 401: Unauthorized

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "main.py", line 106, in <module>
    client.run(TOKEN)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/nextcord/client.py", line 666, in run
    return future.result()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/nextcord/client.py", line 645, in runner
    await self.start(*args, **kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/nextcord/client.py", line 608, in start
    await self.login(token)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/nextcord/client.py", line 476, in login
    data = await self.http.static_login(token.strip())
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/nextcord/http.py", line 384, in static_login
    raise LoginFailure('Improper token has been passed.') from exc
nextcord.errors.LoginFailure: Improper token has been passed.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "main.py", line 109, in <module>
    client.run(Default_TOKEN)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/nextcord/client.py", line 638, in run
    loop.add_signal_handler(signal.SIGINT, lambda: loop.stop())
  File "/usr/lib/python3.8/asyncio/unix_events.py", line 89, in add_signal_handler
    self._check_closed()
  File "/usr/lib/python3.8/asyncio/base_events.py", line 508, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed```
tiny ibex
west escarp
#

yep

untold token
twin moon
# tiny ibex Improper token
try: 
  client.run(TOKEN)
except:
  Default_TOKEN = info["Default TOKEN"]
  client.run(Default_TOKEN)
  print("Using Default Token")```
untold token
#

U have heard about it

weary gale
#

f

tiny ibex
untold token
#

Yeah

west escarp
#

yes

untold token
#

That's how you install dependencies lol

untold token
#

requirements.txt

tiny ibex
twin moon
untold token
#

No it doesn't

tiny ibex
untold token
#

The default one too

weary gale
#

@west escarp so how do i use railway lol

untold token
#

and you only get a single token for a bot

untold token
#

You don't get multiple tokens for a single bot account

tiny ibex
#

Yeah

untold token
#

So that try except won't work as you intented

boreal ravine
#

maybe he has another bot account, who knows lol

twin moon
west escarp
#

If you want to run multiple, use bot.start and a different starting method

#

.run is intended for only one bot

tiny ibex
#

Use ```py
try:
client.run(TOKEN)
except:
Default_TOKEN = info["Default TOKEN"]
client.run(Default_TOKEN)
print("Using Default Token") 
else:
print("Invalid Token!")

weary gale
#

@west escarp how to use railway?

west escarp
#

the example has instructions

#

I've never done it honestyl

untold token
#

You would need to create your asyncio main event loop and then start your bot

tiny ibex
untold token
#

.run() is a blocking IO

weary gale
#

yeah pls

untold token
#

Ohh

#

It's similar to how you use heroku

#

Procfile

weary gale
#

i dont understand any of that

twin moon
untold token
#

Its containerized then

boreal ravine
untold token
#

It's so easy lol

tiny ibex
untold token
#

You need to download the deps

#

from requirements.txt

weary gale
#

wait so do i need a github acc over a month old

untold token
#

and then run your worker

west escarp
#

yes

untold token
#

which runs the bot

#

Its simple to understand

tiny ibex
west escarp
untold token
west escarp
#

I dont know

tiny ibex
untold token
#

Aye

maiden fable
tiny ibex
untold token
boreal ravine
#

@west escarp is this necessary?

west escarp
untold token
#

That's the file

weary gale
#

can somebody pls run me thru on how to host using railway

#

im stuck asf

tiny ibex
untold token
#

where you need to add your files/ directories

west escarp
untold token
tiny ibex
untold token
#

You need to add the files/dir that you want to ignore

#

So for example

west escarp
west escarp
#

after the "webserver" that would normally run

boreal ravine
twin moon
tiny ibex
untold token
#
/some_fir
Some_file.py
some_image.jpg
#

These files in the .gitignore file will be ignored

tiny ibex
untold token
#

it ignores those files, aka any changes / anything in em

tiny ibex
#

What is the meaning of "ignored"

twin moon
tiny ibex
boreal ravine
twin moon
#

is blocking it

boreal ravine
west escarp
untold token
west escarp
#

^

untold token
#

if you a .gitignore file, git will ignore those files when you push

boreal ravine
untold token
#

Useless files too

tiny ibex
#

What then?

untold token
#

Then don't

#

don't create a .gitignore file then

tiny ibex
#

That's what I am asking from last 5 mins

untold token
boreal ravine
unkempt canyonBOT
untold token
tiny ibex
untold token
#

it's useful but not very important

boreal ravine
tiny ibex
#

Poof

maiden fable
untold token
#

Well I will try it now

#

railway

tiny ibex
#

BTW what is the average latency?

#

Of railway?

untold token
#

Dunno

west escarp
#

probably varies

untold token
#

You have to try it and see

tiny ibex
west escarp
#

I mean

tiny ibex
#

Like around 25?

west escarp
#

Considering it's free hosting

#

probably anywhere between 100 and 600

untold token
#

Not 25 not

#

Probs over 100

boreal ravine
#

hm

west escarp
#

I barely get 25 to google so

#

def not that low

untold token
#

Yeah as mistle said

tiny ibex
untold token
#

No

west escarp
#

that's be impressive if they did

#

I doubt they do though

untold token
#

Yeah

#

Heroku's latency on average is 125 to 200

boreal ravine
tiny ibex
#

So let's host it and then I'll see myself

untold token
#

But it spikes up to 600 or more

tiny ibex
untold token
#

Not bad

west escarp
#

Mine:
Websocket: 94ms
HTTP: 263ms

#

http being the total time between posting a message and getting it returned

tiny ibex
#

So I am still not going to choose railway over heroku

boreal ravine
#

sure

west escarp
#

I mean, choose what you like, but heroku is not designed for constantly running applications

#

their free tier will turn off your bot at times because it has limited hours

west escarp
#

if you're ok with that then there's no reason to bother

untold token
#

Okay what

west escarp
#

Well, that's against their TOS and not something we'll help with or advise

tiny ibex
#

But yeah still an issue

untold token
#

How the hell heroku has that low latency

tiny ibex
west escarp
#

They might be using GCP, and discord also uses GCP, so they could have some datacenters next to each other to make it nice

#

My stuff has comcast in between

untold token
#

Hmm

#

Although seriously how do I have such low latencies

west escarp
#

As I said

untold token
#

My heroku dynos are free tier

untold token
#

Okay railway is similar to docker containers

#

That's cool

weary gale
#

how can i do something like this

#

with an embed

#
async def userinfo(ctx, member : discord.Member = None):

    member = member or ctx.author
    roles = [role for role in member.roles]

    embed = discord.Embed(colour=member.color, timestamp=ctx.message.created_at)

    embed.set_author(name=f"user info - {member}")
    embed.set_thumbnail(url=member.avatar_url)

    embed.add_field(inline = False, name="ID:", value=member.id)
    embed.add_field(inline = False, name="guild name:", value=member.display_name)

    embed.add_field(name="created at:", value=member.created_at.strftime("`%a, %#d %B %Y, %I:%M %p`"))
    embed.add_field(inline = False, name="joined at:", value=member.joined_at.strftime("`%a, %#d %B %Y, %I:%M %p`"))

    await ctx.send(embed=embed)

in here

untold token
#

emoji

#

You need to check if there status is in dnd

#

if it is, just show the emoji

weary gale
#

what

untold token
#

!d discord.Status

unkempt canyonBOT
#

class discord.Status```
Specifies a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") ‘s status.
weary gale
#

where do i add that

untold token
#

Its simple

weary gale
#

manually change it

boreal ravine
#

juan do you enough python? for me it seems like you lack python knowledge to use dpy and python

weary gale
#

:I

slate swan
#

like
check=?

#

C:\Users\ADMIN\PycharmProjects\Fluxo>python main.py
Traceback (most recent call last):
File "C:\Users\ADMIN\PycharmProjects\Fluxo\main.py", line 10, in <module>
x = round(bot.latency * 1000)
ValueError: cannot convert float NaN to integer

manic wing
boreal ravine
boreal ravine
slate swan
boreal ravine
boreal ravine
shadow wraith
#

hey guys

wary ice
#
@bot.command()
async def invite(ctx):
    embed = discord.Embed(title=f"Invite {client.user.name}", color=0xff0000, description=f"Wanna invite {client.user.name}, then [click here](https://discord.com/api/oauth2/authorize?client_id={client.user.id}&permissions=8&scope=bot)")
    await buttons.send(
        content = None,
        embed = embed,
        channel = ctx.channel.id,
        components = [
            ActionRow([
                Button(
                    style = ButtonType().Link,
                    label = "Invite",
                    url = f"https://discord.com/api/oauth2/authorize?client_id={client.user.id}&permissions=8&scope=bot"
                )
            ])
        ]
    )``` I want to button with a link and I have problems why
shadow wraith
shadow wraith
boreal ravine
slate swan
#

@boreal ravine

C:\Users\ADMIN\PycharmProjects\Fluxo>python main.py
Traceback (most recent call last):
File "C:\Users\ADMIN\PycharmProjects\Fluxo\main.py", line 10, in <module>
ping = round(int(bot.latency * 1000))
ValueError: cannot convert float NaN to integer

#

ping = round(int(bot.latency * 1000))

shadow wraith
wary ice
shadow wraith
#

then round(int(ping * 1000))

#

🤔

#

actually don't

slate swan
#

isn't that literally the same thing?

maiden fable
#

Me who does huneval return bot.latency 😐

boreal ravine
wary ice
#

@boreal ravine look

boreal ravine
wary ice
boreal ravine
#

now?

slate swan
#

Yes now.

slate swan
boreal ravine
#

!nan

slate swan
#

!nan

tough lance
slate swan
#

!NaN

#

fff i forgot what a float converts into

#

str?

boreal ravine
maiden fable
boreal ravine
#

!e print(int(2282.22))

unkempt canyonBOT
#

@boreal ravine :white_check_mark: Your eval job has completed with return code 0.

2282
shadow wraith
#

isn't float just decimal'd int

slate swan
#

Why do you round()

boreal ravine
shadow wraith
#

!e print(float(2822.22))

slate swan
#

You don't need that anyways.

unkempt canyonBOT
#

@shadow wraith :white_check_mark: Your eval job has completed with return code 0.

2822.22
west escarp
#

Or it's disconnected

tough lance
#

Just do round(bot.latency*1000)

boreal ravine
#

!e print(type(1.0)) # @shadow wraith

unkempt canyonBOT
#

@boreal ravine :white_check_mark: Your eval job has completed with return code 0.

<class 'float'>
west escarp
#

You can also use if bot.latency to detect this and output something helpful when it happens

slate swan
west escarp
#

!e ```py
if float("nan"):
print(1)

unkempt canyonBOT
#

@west escarp :white_check_mark: Your eval job has completed with return code 0.

1
west escarp
#

argh

#

stupid

#

ok

slate swan
#

?

west escarp
#

eew it's in math

slate swan
west escarp
#

!e ```py
from math import isnan
if isnan(float("nan")):
print(1)

unkempt canyonBOT
#

@west escarp :white_check_mark: Your eval job has completed with return code 0.

1
shadow wraith
west escarp
shadow wraith
#

all your bot's code should be above it

tough lance
#

Are you doing this in on_ready?

slate swan
shadow wraith
west escarp
#
code here runs before bot starts


bot.run()

code here runs after bot exits
maiden fable
#

It's been ages since a Mod is here, without the ping to mute/kick anyone toxic ngl

west escarp
#

do the math in the command then?

#

Presumably you're doing ctx.send() somewhere right? put it with that

slate swan
#

import math?

tough lance
#

!e

print(int(12.29))
unkempt canyonBOT
#

@tough lance :white_check_mark: Your eval job has completed with return code 0.

12
shadow wraith
# slate swan yes..

wait a second, you're trying to get the bot's ping and "multiply" the bot's ping by a 1000?

maiden fable
#

Yea

#

Cz that's what returns the true ping

#

In MS

upbeat otter
maiden fable
#

The bot's actual ping is 122 MS

#

Not 0.1 MS haha

shadow wraith
#

💀

#

the message above the latency

slate swan
#

what to do? SyntaxError: Non-UTF-8 code starting with '\xd0' in file C:\Users\User\Desktop\2 bot discord server console\bot.py on line 193, but no encoding declared; see https://python.org/dev/peps/pep-0263/ for details

maiden fable
#

ofc ignore the other message, czzz, uhhh, it's dpy server

maiden fable
slate swan
#

yeah

shadow wraith
slate swan
#

mines 500

upbeat otter
shadow wraith
maiden fable
maiden fable
shadow wraith
west escarp
upbeat otter
maiden fable
slate swan
#

🥄

#

anyone wanna use the spoon for me

maiden fable
slate swan
west escarp
#
# -*- coding: utf-8 -*-
#

to the top fo your file

maiden fable
#

Ah

slate swan
maiden fable
#

That way I can also use emojis as variables? 🥺

west escarp
#

Maybe, I don't recall the details

maiden fable
#

O

west escarp
#

I do however recall you can use a custom coding to really do cursed stuff

maiden fable
#

Gonna try that out

craggy cloak
#

r!tag buttons

maiden fable
#
class 😭:
    pass
cry = 😭() 
weary gale
#

how can i make the id and guild name, embedded like the other two?

#

embed/cb

upbeat otter
#

nvm mine shows 81 now

west escarp
#

That's discord code syntax

maiden fable
#

Welp ;-;

west escarp
#

` asdf `

#

asdf

#

I wrote a thing, uh

maiden fable
#

asdf?

west escarp
#

here.

#

rgh

tough lance
#

Jkl

west escarp
#

here

tough lance
#

Bro

#

Put it between ``

#

@weary gale

weary gale
#

lmao ik but i cant put it there lol

upbeat otter
weary gale
#

lmao how am i supposed to do that

maiden fable
tough lance
upbeat otter
upbeat otter
maiden fable
slate swan
maiden fable
maiden fable
#

¯_(ツ)_/¯

upbeat otter
tough lance
#

Aight I'ma head out

slate swan
maiden fable
#

Anyone got any discord bot ideas

maiden fable
tough lance
west escarp
#

...word search

#

and no, mass dm will get you banned from the platform

tough lance
#

Jk

tough lance
maiden fable
#

Also mine is a Chatbot and all it has to do is.... send messages. So it's gonna get ratelimited as soon as I start it up

maiden fable
upbeat otter
#

@maiden fable make among us discord bot

tough lance
#

What about akinator? It ai right?

maiden fable
west escarp
#

Make a word search generator

maiden fable
upbeat otter
slate swan
tough lance
#

Minesweeper

slate swan
maiden fable
west escarp
#

urgh discord

#

why do you have to be a pita

maiden fable
#

Hahaha

tough lance
#

Uno

visual island
maiden fable
upbeat otter
#

@maiden fable create an fps bot

slate swan
#

make a bot that works like grammar shrug

west escarp
#

🇦🇧🇨🇩🇪🇫🇬🇭🇮🇯🇰🇱🇲🇳🇴🇵🇶🇷🇸🇹🇺🇻🇼🇽🇾🇿

maiden fable
west escarp
#

!raw 919167241478619156

upbeat otter
unkempt canyonBOT
#
== Raw message ==

🇦🇧🇨🇩🇪🇫🇬🇭🇮🇯🇰🇱🇲🇳🇴🇵🇶🇷🇸🇹🇺🇻🇼🇽🇾🇿
tough lance
#

Lmao

maiden fable
upbeat otter
#

nvm

maiden fable
#

Yea dude

west escarp
#

on todays instance of discord being a pain in the butt

maiden fable
#

Haha discord is always weird

slate swan
#

and we still use it shrug

maiden fable
west escarp
#

ffs

maiden fable
#

🤣

west escarp
#

I had to write like an extra chunk of code so my bot didn't do that

#

it sucked

upbeat otter
slate swan
#

why does it render as an emoji tho

upbeat otter
maiden fable
#

What u tryna do tho, Bast?

west escarp
#

anyway

#

you can use 🇦

#

in a grid

maiden fable
#

Mhm

west escarp
#

to make a word search

maiden fable
#

O

upbeat otter
#

indexing the column and the row, the user will experience difficulties

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied mute to @slate swan until <t:1639217723:f> (9 minutes and 59 seconds) (reason: discord_emojis rule: sent 21 emojis in 10s).

maiden fable
#

Yea that's what I was gonna say

visual island
maiden fable
#

No way to index the rows and columns of each alphabet

west escarp
#

!unmute 730644317894344734

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: pardoned infraction mute for @slate swan.

shadow wraith
#

sorry to randomly bump in the conversation but here's a good bot event to use, hunter recommended me it and i am totally using it:

@bot.event
async def on_message(message):
  await message.delete()
maiden fable
#

Lmao

slate swan
#

sorry i was trying to make the thing work lmao

upbeat otter
#

lol

west escarp
#

send a screenshot

craggy cloak
#

how can i add 2 buttons to one message?

shadow wraith
maiden fable
#

(Not to mention I was sleep drunk last night)

shadow wraith
#

message above is 💀

maiden fable
unkempt canyonBOT
shadow wraith
slate swan
#

view = View()
view.add_item(button)

tough lance
#

Make solitaire

maiden fable
slate swan
shadow wraith
maiden fable
shadow wraith
#

i only use decators for simplification

#

so i can actually understand wtf im doing

maiden fable
#

Same

slate swan
#

not subclassing view - > CH_PepeSadCry

maiden fable
#

I prefer decos rather than writing code

upbeat otter
#

@maiden fable Make a || || bot

tough lance
#

I prefer result

upbeat otter
maiden fable
#

Empty bot

slate swan
#

lmao

upbeat otter
maiden fable
#

More of invisible bot

upbeat otter
#

invisible message bot lmao

shadow wraith
#

when the

west escarp
#

_ _

maiden fable
#

Anything else?

upbeat otter
west escarp
maiden fable
#

😐

upbeat otter
slate swan
#

huh how could a bot get that badge i thought it was only for users

slate swan
shadow wraith
#

is probably a bot made by discord itself

maiden fable
#

Iirc that's the bot used in Bug reporting server

upbeat otter
#

wrong reply ,-,

shadow wraith
maiden fable
#

Hunter lemon_enraged

upbeat otter
upbeat otter