#discord-bots

1 messages ยท Page 812 of 1

slate swan
#

channel = bot.get_channel(CHANNEL_ID)

#

and then do channel.send(message)

hollow quest
#

ive already done the image part, the message part just isnt working

slate swan
#

so show me what you did already

#

in sending message code

hollow quest
#

then everything i put after just threw errors

slate swan
#

after this line?

hollow quest
#

none of the message code worked

#

i did await ctx.send(message)

#

and some others but nothing worked

slate swan
#

can you send me errror/code

hollow quest
#

there is no error for that one, it just doesnt send the message at all

slate swan
#

wdym at all

hollow quest
#

but its just sending 'color' and not the variable values

slate swan
#

can you show me code

hollow quest
#

which part

#

all of it?

slate swan
#

seding message

hollow quest
#

await ctx.send(file=discord.File('palette.png'))
await ctx.send(color)

slate swan
#

you wanna send full list?

#

if its not in "" it should send list

hollow quest
hollow quest
slate swan
#

try this ```py
await ctx.send("\n".join(color))

hollow quest
#

what does the join do?

slate swan
#

joins elements of list to the "\n"

hollow quest
#

ahhh

slate swan
#

so every element will be separated with enter

#

you can just put " " if you want it in one line

hollow quest
#

TypeError: can only join an iterable

final iron
#

What's color?

slate swan
#

show me what color equals

#

color = ?

hollow quest
slate swan
#

there

hollow quest
#

ill use the correct variable and see what happens

#

but yes thats what color_palette =

final iron
#

color is not color_palette

hollow quest
slate swan
#

๐Ÿ‘

honest vessel
#

you ment like ?

colors = [(72, 83, 90), (237, 146, 86), (35, 232, 191), (152, 143, 139), (93, 119, 211)]



print('\n'.join(map(str, colors)))
final iron
#

What does map even do

#

!d map

unkempt canyonBOT
#
map

map(function, iterable, ...)```
Return an iterator that applies *function* to every item of *iterable*, yielding the results. If additional *iterable* arguments are passed, *function* must take that many arguments and is applied to the items from all iterables in parallel. With multiple iterables, the iterator stops when the shortest iterable is exhausted. For cases where the function inputs are already arranged into argument tuples, see [`itertools.starmap()`](https://docs.python.org/3/library/itertools.html#itertools.starmap "itertools.starmap").
final iron
#

On

honest vessel
#

its so u can join em cause thay are not strings but tuples

hollow quest
final iron
#

Oh I could use map instead of list comps

honest vessel
#

why i posted that map-thing

final iron
#

So if I had a tuple of ints and I wanted them to be strings could I use map() to change them?

honest vessel
#

!e

ints = (72, 83, 90)
print('\n'.join(map(str, ints)))
unkempt canyonBOT
#

@honest vessel :white_check_mark: Your eval job has completed with return code 0.

001 | 72
002 | 83
003 | 90
honest vessel
#

@final iron^

final iron
#

I was using list comps for that

#

Ill change them to map

#

!e

print(map(str, (123, 1, 4567)))
unkempt canyonBOT
#

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

<map object at 0x7f8325ed9570>
final iron
#

What did I do wrong

sage otter
#

you have to join it.

honest vessel
#

yeah

final iron
#

I do want to still have a tuple/list though

sage otter
#

Cast it.

final iron
#

Example?

sage otter
#

list(map(str, [123, 456]))

final iron
#

Ah

serene mantle
#

Does anyone know if disnake would work with a user token

#

Rather than a bot token

slim ibex
#

?

sage otter
#

Self bottling

#

Botting*

honest vessel
#

print(list(map(str, ints)))

serene mantle
#

Yep Iโ€™m just curious

#

Would it work?

honest vessel
#

oh already answered

slim ibex
#

We donโ€™t help with self bots here

serene mantle
#

Iโ€™m not asking for help lol

slim ibex
#

Especially if they are a discord self bot

serene mantle
#

It was just a theoretical question

final iron
#

Which should I use:

list(map(str, [123, 456]))

Or

[str(i) for i in my_list]
serene mantle
#

Chill out dude

final iron
#

Writing code on phone is pain

dry junco
#

Does yagpdb custom Command use python?

slim ibex
slim ibex
#

actually I think it does use Go

dry junco
final iron
#

!rule 5

unkempt canyonBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.

serene mantle
#

Iโ€™m not doing anything my god ๐Ÿ˜‚

dry junco
serene mantle
#

It was simply a question

honest vessel
slim ibex
#

Just because a successful discord bot was made with Go doesnโ€™t mean you should just jump to that language

slim ibex
#

learn languages that will help you in what you want to do

hollow quest
#

so my bot prints this to console fine:

#

for color in color_palette:
print(webcolors.rgb_to_hex(color), end=",")

#

but when i try send it as a message without the print, it gives an error

final iron
#

So which one of those should I be using

hollow quest
honest vessel
#

end is for print only

hollow quest
#

but if i leave it it goes on new lines

#

so would i format it instead?

#

as i want it all to be on 1 line

#

for color in color_palette:
hexVal = (webcolors.rgb_to_hex(color))

#

so then i just join hexVal at the end?

scarlet aurora
#
@bot.event
async def on_message(message):
    if message.guild.get_member(569280782753988608) in message.mentions:
        await message.channel.send('freshman895')
    await bot.process_commands(message)```
#

why doesn't this work?

#

it want it so that if i use bot command and then ping a specific person, it replys with a specific messaage

light violet
#

pithink pls I need a help can somebody come front

final iron
#

!d discord.Message.mentions

unkempt canyonBOT
#

A list of Member that were mentioned. If the message is in a private message then the list will be of User instead. For messages that are not of type MessageType.default, this array can be used to aid in system messages. For more information, see system_content.

Warning

The order of the mentions list is not in any particular order so you should not rely on it. This is a Discord limitation, not one with the library.

scarlet aurora
#

so what do i change in the code?

scarlet aurora
#

idk how

#

the id is right

final iron
#

I mean check the id against the elements in the list ids

#

You could use a normal for loop or a list comp

regal pulsar
#
@bot.command()
async def hug(message, user: discord.Member):
    hug_scenario = f"{message.author.mention} gives {user.mention} a warm hug!"
    if user.mention == message.author.mention:
        await message.channel.send("Aw, don't have any friends to hug? Here's one from me :people_hugging:")
    try:
        if user.mention != message.author.mention:
            await message.channel.send(hug_scenario)
    except discord.ext.commands.errors.MemberNotFound:
        await message.channel.send("Mention someone to hug smh...")  
#

why wont it catch an error if i do ?hug myself

honest vessel
regal pulsar
#

if the person i hug isnt a user i want to send

final iron
#

We'll see what happens when you try to hug someone that isn't a user

#

What error gets thrown

light violet
#

I neeeeed hellpppo

regal pulsar
#

i already set up a try/except to catch it

#

didnt work

honest vessel
#
@bot.command()
async def hug(message, user: discord.Member):
    if user is None:
        await message.channel.send("Mention someone to hug smh...")
        return
    # Rest of code
regal pulsar
#

hmm ill try that

light violet
#

Does anybody know to put requests with aiosonic

final iron
#

!pypi aiosonic

unkempt canyonBOT
light violet
#

I saw it

final iron
#

Why not use aiohttp?

light violet
#

iosonic is ster

#

Aiosonic is faster

honest vessel
#

lol aiohttp slow???

light violet
#

Yes slower than aiosonic

final iron
#

It's a very little amount of time

light violet
#

@final iron actualy i was working on antinuke bot which bans nuker fast when i use aiohttp nuker bypass it with 50bans with threads btw i need to minimize this amount so need something to make faster request

slim ibex
#

their docs say its 102% faster than aiohttp

scarlet aurora
#

the id is the user id of the guy i want to mention

light violet
#

Use it

final iron
#

Can their numbers even be trusted?

slim ibex
#

^

light violet
#

What

regal pulsar
#

is it because of async def hug(message, user: discord.Member)

slim ibex
#

faster isn't always better

regal pulsar
#

because i cant catch the error inside the func

light violet
final iron
#

You could create an error handler for the command

regal pulsar
#

how would i do that

slim ibex
#

bro it really all comes down to the discord api, no? if the api is down or slow it will take longer?

final iron
maiden fable
light violet
hollow quest
#

for color in color_palette:
(webcolors.rgb_to_hex(color))

this creates every value spereratley and i want it on the same line so that when i print it, i dint have to use 'end' any help would be appreciated

final iron
light violet
maiden fable
pliant gulch
#

Tell people not to give untrusted members permissions to ban people

#

Wonโ€™t need an anti Nuke if you do that

regal pulsar
#

lol

light violet
slim ibex
#

what

regal pulsar
#

you mean like giving people perms?

slim ibex
#

bro its not like a random noob is gonna get mod if its not given to them,

regal pulsar
#

i think i can control who i give permissions to pretty well

honest vessel
#

@regal pulsarmy bad you will need to use error handler - as you tried

light violet
#

.

light violet
#

@slim ibex some epeople in server cheats there server like admins maybe he wants to nuke mine

regal pulsar
#

but the error comes from here

#

in the function

honest vessel
#

can u show error?

regal pulsar
#

raise MemberNotFound(argument) discord.ext.commands.errors.MemberNotFound: Member "myself" not found.

light violet
pliant gulch
slim ibex
light violet
regal pulsar
#

yeah

regal pulsar
# leaden hollow can you share the code?
@bot.command()
async def hug(message, user: discord.Member):
    hug_scenario = f"{message.author.mention} gives {user.mention} a warm hug!"
    if user.mention == message.author.mention:
        await message.channel.send("Aw, don't have any friends to hug? Here's one from me :people_hugging:")

        await message.channel.send("Mention someone to hug smh...")

    elif user.mention != message.author.mention:
        await message.channel.send(hug_scenario)
pliant gulch
regal pulsar
#

message

leaden hollow
#

so "myself" needs to be a user name/nick to work atleast

regal pulsar
#

if no one is mentioned

leaden hollow
#
user: discord.Member = None```
#

change this

#

the add,

 if user == None:
  await ctx.send("mention someone")```
#

use whatever you use in place of ctx

#

@regal pulsar

regal pulsar
#

k one sec

slate swan
#

my cogs aren't working
cogs/greetings.py:

import discord
from discord.ext import commands

class Greetings(commands.Cog, name="Greetings"): # We Subclass commands.Cog . if the name kwarg is not passed, the Cog name is taken to be the same as the class name
   def __init__(self, bot):
       self.bot = bot

@commands.Cog.listener() # just like @bot.event
async def on_member_join(member): # called when a member joins
    channel = member.guild.system_channel # get the guild's system messages channel - where welcome and boost messages are sent. You can change this to bot.get_channel(channel_id)
    if channel is not None:
        await channel.send('Welcome {0.mention}.'.format(member))

@commands.command() # this is how you create a command in a Cog. The same as @bot.command()
async def hello(ctx, *, member: discord.Member = None): # always remember to pass "self"!
    """Says hello""" # command description
    member = member or ctx.author 
    await ctx.send('Hello {0.name}~'.format(member))

def setup(bot): 
    bot.add_cog(Greetings(bot)) # register the cog 

main bot file:

import discord, json
from keepalive import keepAlive

config = json.load(open('config/config.json'))
token = config.get('token')
bot = discord.Bot()

@bot.event
async def on_ready():
    print(f"We have logged in as {bot.user}")

bot.load_extension('cogs.greetings')
keepAlive()
bot.run(token)
regal pulsar
#

nope

#

it doesnt work

honest vessel
# leaden hollow ```py user: discord.Member = None```

uuuugh i forgot that way i tried say if user is None: send msg, return

but anyway here is another way

    @commands.command()
    async def hug(self, ctx, user: disnake.Member):
        await ctx.send(f"Hugging {user.display_name}")

    @hug.error
    async def on_hug_error(self, ctx, error):
        if isinstance(error, commands.MemberNotFound):
            await ctx.send("Mention someone to hug smh...")
regal pulsar
#

yeah im trying to display a message if no one is tagged

honest vessel
#

nvrm u can do !hug Emotional Support

honest vessel
#

@regal pulsaryou mean if they like only type !hug

#

then you can just add a more error

regal pulsar
#

and dont mention anyone

leaden hollow
#

you can make a subcommand for that

hollow quest
#

for color in color_palette:
(webcolors.rgb_to_hex(color))

this creates every value spereratley and i want it on the same line so that when i print it, i dint have to use 'end' any help would be appreciated

slate swan
#

my cogs aren't working
cogs/greetings.py:

import discord
from discord.ext import commands

class Greetings(commands.Cog, name="Greetings"): # We Subclass commands.Cog . if the name kwarg is not passed, the Cog name is taken to be the same as the class name
   def __init__(self, bot):
       self.bot = bot

@commands.Cog.listener() # just like @bot.event
async def on_member_join(member): # called when a member joins
    channel = member.guild.system_channel # get the guild's system messages channel - where welcome and boost messages are sent. You can change this to bot.get_channel(channel_id)
    if channel is not None:
        await channel.send('Welcome {0.mention}.'.format(member))

@commands.command() # this is how you create a command in a Cog. The same as @bot.command()
async def hello(ctx, *, member: discord.Member = None): # always remember to pass "self"!
    """Says hello""" # command description
    member = member or ctx.author 
    await ctx.send('Hello {0.name}~'.format(member))

def setup(bot): 
    bot.add_cog(Greetings(bot)) # register the cog 

main bot file:

import discord, json
from keepalive import keepAlive

config = json.load(open('config/config.json'))
token = config.get('token')
bot = discord.Bot()

@bot.event
async def on_ready():
    print(f"We have logged in as {bot.user}")

bot.load_extension('cogs.greetings')
keepAlive()
bot.run(token)
honest vessel
#

@regal pulsarthis is for cogs but, ```py
@commands.command()
async def hug(self, ctx, user: disnake.Member):
await ctx.send(f"Hugging {user.display_name}")

@hug.error
async def on_hug_error(self, ctx, error):
    if isinstance(error, commands.MemberNotFound):
        await ctx.send("Mention someone to hug smh...")
    elif isinstance(error, commands.MissingRequiredArgument):
        await ctx.send("Mention someone to hug smh...")
final iron
#

For your class

#

Your methods are not indented properly

leaden hollow
honest vessel
#

with a twist he dosnt use cogs

#

๐Ÿ˜›

leaden hollow
#

it won't if you copy paste

maiden fable
#

๐Ÿ‘€

regal pulsar
#

im 99.9% sure its because of user: discord.Member

maiden fable
#

What

final iron
#

That code was meant for a cog. You'll have to use your brain to figure out how to change it

honest vessel
honest vessel
#

its a class

maiden fable
#

!d discord.ext.commands.Cog

unkempt canyonBOT
#

class discord.ext.commands.Cog(*args, **kwargs)```
The base class that all cogs must inherit from.

A cog is a collection of commands, listeners, and optional state to help group commands together. More information on them can be found on the [Cogs](https://discordpy.readthedocs.io/en/master/ext/commands/cogs.html#ext-commands-cogs) page.

When inheriting from this class, the options shown in [`CogMeta`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CogMeta "discord.ext.commands.CogMeta") are equally valid here.
final iron
#

Hunter no way you just tried that

regal pulsar
#

i see

maiden fable
regal pulsar
#

so

maiden fable
#

!d intents

unkempt canyonBOT
#
maiden fable
#

See

#

I thought cogs also existed

hollow quest
#

for color in color_palette:
(webcolors.rgb_to_hex(color))

this creates every value spereratley and i want it on the same line so that when i print it, i dint have to use 'end' any help would be appreciated

unkempt canyonBOT
#

Joining Iterables

If you want to display a list (or some other iterable), you can write:

colors = ['red', 'green', 'blue', 'yellow']
output = ""
separator = ", "
for color in colors:
    output += color + separator
print(output)
# Prints 'red, green, blue, yellow, '

However, the separator is still added to the last element, and it is relatively slow.

A better solution is to use str.join.

colors = ['red', 'green', 'blue', 'yellow']
separator = ", "
print(separator.join(colors))
# Prints 'red, green, blue, yellow'

An important thing to note is that you can only str.join strings. For a list of ints,
you must convert each element to a string before joining.

integers = [1, 3, 6, 10, 15]
print(", ".join(str(e) for e in integers))
# Prints '1, 3, 6, 10, 15'
maiden fable
#

Also not a discord bot question

honest vessel
#

@regal pulsarwell compare mycode vs yours, and find whats diffrent, you need to delete something and edit 1 thing pretty much

hollow quest
light violet
#

async with aiosonic.ClientSession(headers = { 'Authorization': f'Bot {self.client.http.token}', 'Content-Type': 'application/json' }) as session:
AttributeError: module 'aiosonic' has no attribute 'ClientSession'

#

wht to do

#

pls help

maiden fable
#

U'll need to use aiohttp

#

!pypi aiosonic

unkempt canyonBOT
maiden fable
#

Hmm never used that

slate swan
#

my cogs aren't working
cogs/greetings.py:

import discord
from discord.ext import commands

class Greetings(commands.Cog, name="Greetings"): # We Subclass commands.Cog . if the name kwarg is not passed, the Cog name is taken to be the same as the class name
   def __init__(self, bot):
       self.bot = bot

@commands.Cog.listener() # just like @bot.event
async def on_member_join(member): # called when a member joins
    channel = member.guild.system_channel # get the guild's system messages channel - where welcome and boost messages are sent. You can change this to bot.get_channel(channel_id)
    if channel is not None:
        await channel.send('Welcome {0.mention}.'.format(member))

@commands.command() # this is how you create a command in a Cog. The same as @bot.command()
async def hello(ctx, *, member: discord.Member = None): # always remember to pass "self"!
    """Says hello""" # command description
    member = member or ctx.author 
    await ctx.send('Hello {0.name}~'.format(member))

def setup(bot): 
    bot.add_cog(Greetings(bot)) # register the cog 

main bot file:

import discord, json
from keepalive import keepAlive

config = json.load(open('config/config.json'))
token = config.get('token')
bot = discord.Bot()

@bot.event
async def on_ready():
    print(f"We have logged in as {bot.user}")

bot.load_extension('cogs.greetings')
keepAlive()
bot.run(token)
light violet
#

i dont wnt

flat solstice
#

There's something about this code I just cant get rightpy @role_group.command(description = "Show the members of the role specified.", usage = "[role]",) async def members(self, ctx, role: discord.Role): members = [f"<@{member.id}>" for member in role.members] if len(members) == 0: no_members = 0 members.append("No members") await ctx.reply(embed = discord.Embed(title = f"{len(no_members)} Members in `{role}`: " if no_members > 0 else f"{len(members)} Members in `{role}`: ", description = f" ".join(members)))when there is no members in the role then I want the title to say 0 members in {role}: but atm it keeps saying 1 members in [role}, supposedly because i'm adding 1 (the string of "no members") to it

maiden fable
#

Also, u r doing len(no_members) where u should just do no_members

flat solstice
#

true

maiden fable
#

Gonna work then

#

Also...

#

!e print(len(0))

unkempt canyonBOT
#

@maiden fable :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: object of type 'int' has no len()
maiden fable
#

It doesn't work...

flat solstice
#

well at one point I had itpy if len(members) == 0: no_members = len(members) members.append("No members")just changed ti back to this

maiden fable
#

How come it doesn't raise the error

final iron
slate swan
flat solstice
light violet
#

;

slate swan
#

can someone help me, the bot is working locally but not on a remote

pliant mortar
flat solstice
slate swan
flat solstice
slate swan
#
    @commands.command()
    async def adservers(self, ctx):
        if ctx.author.id == 826419463506755605:
            activeservers = self.client.guilds
            file = open("servers.txt", "r+")
            file.truncate(0)
            for guild in activeservers:
                with open("servers.txt", "a", encoding='utf-8') as f:
                    f.write(f"\n")
                    f.write(f"{str(len(guild.members))} | {guild.id} | {guild.name}")
                f.close()
            await ctx.send(file=discord.File("servers.txt"))
        else:
            return

I use this command to see what servers my bot is in, but this is the output i get (a lot of "Nones" and the member count is on 0 or 1

flat solstice
#

so I have this command for showing a roles permissions, is there a better way for me to be formatting it? so instead of checking against my list I just pull the permissions themselves and format thempy @role_group.command(description = "Show the members of the role specified.", usage = "[role]", aliases = ["perms"]) async def permissions(self, ctx, role: discord.Role): has_perm = [perm for perm in self.bot.config.role_perms if getattr(role.permissions, perm)] await ctx.reply(embed = discord.Embed(title = f"Permissions for `{role}`", description = f", ".join(has_perm))) and this is the role_perms listpy role_perms = ["administrator", "manage_guild", "manage_webhooks", "manage_channels", "manage_roles", "manage_emojis", "manage_messages", "manage_nicknames", "view_audit_log", "view_guild_insights", "kick_members", "ban_members", "move_members", "deafen_members", "mute_members", "read_messages", "send_messages", "send_tts_messages", "embed_links", "attach_files", "read_message_history", "add_reactions", "external_emojis", "connect", "speak", "priority_speaker", "use_voice_activation", "stream", "create_instant_invite", "change_nickname", "mention_everyone"]

slate swan
# final iron We already told you. You need to indent your methods

like this?

import discord
from discord.ext import commands

class Greetings(commands.Cog, name="Greetings"): # We Subclass commands.Cog . if the name kwarg is not passed, the Cog name is taken to be the same as the class name
   def __init__(self, bot):
       self.bot = bot

    @commands.Cog.listener() # just like @bot.event
    async def on_member_join(self, member): # called when a member joins
       channel = member.guild.system_channel # get the guild's system messages channel - where welcome and boost messages are sent. You can change this to bot.get_channel(channel_id)
        if channel is not None:
           await channel.send('Welcome {0.mention}.'.format(member))

    @commands.command() # this is how you create a command in a Cog. The same as @bot.command()
    async def hello(self, ctx, *, member: discord.Member = None): # always remember to pass "self"!
        """Says hello""" # command description
        member = member or ctx.author 
        await ctx.send('Hello {0.name}~'.format(member))

def setup(bot): 
    bot.add_cog(Greetings(bot)) # register the cog 
final iron
#

Probably

#

There's a description kwarg in @commands.command() if you want to use it

slate swan
lapis anvil
#

How to make bot send a message at a specific time? For example 00:00 IST

final iron
flat solstice
#

so I have this function which helps me fill out embeds nice and easilypy async def timestamps(self, member, embed, avatar): embed.add_field(name = "Joined Server:", value = f"<t:{int(member.joined_at.timestamp())}:R>", inline = True) if avatar == True: embed.add_field(name = "Avatar", value = f"[PNG]({member.avatar_url_as(static_format='png')})", inline = True) embed.add_field(name = "Joined Discord:", value = f"<t:{int(member.created_at.timestamp())}:R>", inline = True) ordinarily I would call it in my commands as await self.timestamps(member, embed, False) if the command is in the same cog/file, how would i call it from inside of a different cog? Do I need to do```py
from timestamp_function_cog import timestamps

await self.timestamps(member, embed, False)```

valid galleon
#

im currently making a modlog for my bot, and i need to retrieve the toggle from a mongo collection. to get the toggle from it, i need the guild id. im currently using the on_member_update and similar methods, and they dont seem to have a param from which i can access the guild id. is there any alternative to this?

brisk brook
placid skiff
brisk brook
#

To indent your code properly

valid galleon
#

thanks for the help tho

slate swan
honest vessel
#

tabs = 4 spaces

brisk brook
#

Yes, use tabs

final iron
#

Well you should be using spaces

honest vessel
#

no lol

#

what a hell to code

final iron
#

It's listed in pep8

#

Spaces over tabs

honest vessel
final iron
#

Just change your code smh

honest vessel
#

Tabs should be used solely to remain consistent with code that is already indented with tabs

final iron
#

That's really only in the context of very large code

honest vessel
#

imagine use spaces, but i put sublime settings tabs == 4spaces

#

only time i use spaces in python is when trying something fast in python-interpeter

final iron
#

If sublime inserts spaces instead of tabs then you're fine

#

It's recommend to change your ide/text editors settings to insert spaces instead of tabs

honest vessel
#

it inserts tabs tho

#

but i will keep that in mind tho

final iron
#

Change it

honest vessel
#

too lazy to redo all indentations atm ๐Ÿ˜„

final iron
#

Does black refactor tabs into spaces?

honest vessel
#

am just chillin

#

black refactor?

final iron
#

The formatter

honest vessel
#

i dont even know what that is

final iron
#

Check it out

#

It's pretty useful

maiden fable
final iron
#

I doubt all of them do

maiden fable
#

Well VSC does it

final iron
#

So does pycharm

maiden fable
#

And if VSC does, then PyCharm should also

#

Yea, idk about Atom

final iron
#

If you aren't using idle what are you doing with your life

slate swan
final iron
#

๐Ÿ˜Ž

maiden fable
slate swan
flat solstice
slate swan
flat solstice
#

๐Ÿ‘

honest vessel
final iron
#

...

tender estuary
final iron
#

Programming on phone is pain

honest vessel
#

@final iron i cant do that

final iron
#

Do what

honest vessel
#

just try help a simple code here on phone is a hell

final iron
#

I'm on mobile right now

honest vessel
#

u need a laptop bro

final iron
#

I have a computer

#

I'm just too lazy to get on it

honest vessel
#

one guy on youtube tried program a phoneapp with using phone, he gave up cause started get too much pain in his thumbs n went to a dr

final iron
#

๐Ÿ˜”

honest vessel
#

i think he cheated and used keyboard later on to phone

potent shard
brave flint
#

hey

#

how to send a txt to specified channel

#

i mean i wanna use logging

#

and looping like 10min each its sending logs.txt to my channel

pine grove
#

hey guys i know absolutely nothing about building bots with python

#

can anyone help me?

full oasis
#

how can i learn python?

pine grove
#

youtube is a great resource

#

thats where i learnt

honest vessel
#

!resources

unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

grim oar
final iron
#

Pain

#

๐Ÿ˜”

pine grove
final iron
pine grove
#

yikes

#

atleast you can still code

#

or sit at your computer for an inordinate amount of time

final iron
#

Not at the toilet I can't

pine grove
#

you have a point

honest vessel
#

move the toilet with u

final iron
#

๐Ÿ’€

honest vessel
#

@final ironam pretty sure there are some chinese company doing portable toilet/officechairs

final iron
#

Yeah bro it's called a bucket

honest vessel
#

๐Ÿ˜„

#

toilet/bath is a good moment of philosophy tho about codes or problems u have to fix

final iron
#

I guess

honest vessel
#

best is when u get stuck n realise u been there for 30min

final iron
#

I'm working on a Twitter API wrapper and I need to figure out how to share the token across files

slate swan
#

i have written everything correctly still my bot isn't responding to anything can anyone help

prime ibex
#

also like do you have a error handler ?

slate swan
prime ibex
slate swan
#

how do i send......copy paste?

final iron
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

placid skiff
#

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

import discord
from discord.ext import commands

bot = commands.bot(command_prefix = ".")

@bot.event
async def on_ready():
await bot.change_presence(stat = discord.Status.idle)
print("My ready is body")

@bot .command()
async def ping(ctx):
await ctx.send(bot.latency)

bot.run(token)

slate swan
prime ibex
#

U have it as bot

#

commands.bot

slate swan
#

yes

placid skiff
prime ibex
#

It wonโ€™t work

slate swan
prime ibex
placid skiff
slate swan
placid skiff
#

you need to know python to use external package, expecially if created by users

slate swan
prime ibex
unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

slate swan
#

btw thx u both

prime ibex
#

There are some good resources their about learning python check it out

flat solstice
# slate swan perm variable there is a tuple in form of `( permission , True)` so you might l...

so I'm doingpy has_perm = [perm for perm in role.permissions if perm[0]]and getting this errorpy ERROR:cogs.error_handler:TypeError: sequence item 0: expected str instance, tuple found (In permissions) Traceback: File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/core.py", line 85, in wrapped ret = await coro(*args, **kwargs) File "/home/modmail/cogs/info.py", line 135, in permissions await ctx.reply(embed = discord.Embed(title = f"Permissions for `{role}`", description = f", ".join(has_perm)))i'm not great with tuples

slate swan
flat solstice
#

oh, I thought you meant use if perm[0], my bad

final iron
#

Damn discord broke

#

The past 20 minutes of messages aren't loading in

flat solstice
#

oof

flat solstice
cold sonnet
#

ain't even an error

#

oh well

maiden fable
#

Rip, cannot play FN at 400 ms ;-;

flat solstice
# cold sonnet ain't even an error

well that's the errorpy ERROR:cogs.error_handler:TypeError: sequence item 0: expected str instance, tuple found (In permissions) Traceback: File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/core.py", line 85, in wrapped ret = await coro(*args, **kwargs) File "/home/modmail/cogs/info.py", line 135, in permissions await ctx.reply(embed = discord.Embed(title = f"Permissions for `{role}`", description = f", ".join(has_perm)))the code i sent before was what I (think) they suggested I chnage my code to for it to work

cold sonnet
cold sonnet
#

has_perm[0] ?

#

oh nah

#

join takes a tuple

#

bro idek

#

what's perm[0] ?

flat solstice
# cold sonnet what's perm[0] ?

okay this is the full codepy @role_group.command(description = "Show the members of the role specified.", usage = "[role]", aliases = ["perms"]) async def permissions(self, ctx, role: discord.Role): has_perm = [perm for perm in role.permissions if perm[1]] print(has_perm) print() await ctx.reply(embed = discord.Embed(title = f"Permissions for `{role}`", description = f", ".join(has_perm[0])))and this is the print out put of has_perm py [('kick_members', True), ('ban_members', True), ('administrator', True), ('manage_channels', True), ('manage_guild', True), ('add_reactions', True), ('read_messages', True), ('send_messages', True), ('manage_messages', True), ('embed_links', True), ('attach_files', True), ('read_message_history', True), ('mention_everyone', True), ('external_emojis', True), ('connect', True), ('speak', True), ('use_voice_activation', True), ('change_nickname', True), ('manage_nicknames', True), ('manage_roles', True), ('manage_webhooks', True), ('manage_emojis', True), ('use_slash_commands', True), ('request_to_speak', True)]

cold sonnet
#

yeah, this is is a list of tuples

#

so has_perm[0] is a tuple

#

you have to add has_perm[0][0]

#

that's the str

flat solstice
#

this is what I was doing beforepy role_perms = ['administrator', 'manage_guild', 'manage_webhooks', 'manage_channels', 'manage_roles', 'manage_emojis', 'manage_messages', 'manage_nicknames', 'view_audit_log', 'view_guild_insights', 'kick_members', 'ban_members', 'move_members', 'deafen_members', 'mute_members', 'read_messages', 'send_messages', 'send_tts_messages', 'embed_links', 'attach_files', 'read_message_history', 'add_reactions', 'external_emojis', 'connect', 'speak', 'priority_speaker', 'use_voice_activation', 'stream', 'create_instant_invite', 'change_nickname', 'mention_everyone'] has_perm = [perm for perm in role_perms if getattr(role.permissions, perm)]but hikari lover suggested has_perm = [perm for perm in role.permissions if perm[1]] as a more compact way of doing it

cold sonnet
#

perm[0] for perm in... seems good

maiden fable
#

!d discord.Permissions

unkempt canyonBOT
#

class discord.Permissions(permissions=0, **kwargs)```
Wraps up the Discord permission value.

The properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools. This allows you to edit permissions.

Changed in version 1.3: You can now use keyword arguments to initialize [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions") similar to [`update()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.update "discord.Permissions.update").
flat solstice
flat solstice
flat solstice
scarlet rune
#

how to set my bot offline, i accidentally hosted my bot on my pc lmfao

pliant nacelle
#

how can i do a temp channel bot ?

flat solstice
# slate swan pls help

I'm not amazing with d.py but I think your looking for activeservers = self.client.guilds() (maybe). ignore that first bit You could also save yourself a variable with py @commands.command() async def adservers(self, ctx): if ctx.author.id == 826419463506755605: file = open("servers.txt", "r+") file.truncate(0) for guild in self.client.guilds: with open("servers.txt", "a", encoding='utf-8') as f: f.write(f"\n") f.write(f"{str(len(guild.members))} | {guild.id} | {guild.name}") f.close() await ctx.send(file=discord.File("servers.txt")) else: return

flat solstice
slate swan
#

ok

#

btw it worked, thx

pliant nacelle
flat solstice
digital halo
#

Hey can anyone please help me with a bot which fetches an Information of number of active players from an player pannel and display it on the discord in real-time i mean I have started the work on it though

flat solstice
flat solstice
slate swan
flat solstice
slate swan
#

great

flat solstice
#

sorry for wasting your time

flat solstice
# pliant nacelle yes

I haven't tested this but I think you'd want something like thispy @Cog.listener() async def on_voice_state_update(self, member, before, after): await self.bot.create_text_channel(name = f"{member}'s channel", category = before.category, topic = f"{member} joned {before.channel} so a new channel was created.") await self.bot.create_voice_channel(name = f"{member}'s channel", category = before.category)
create txt docs: https://discordpy.readthedocs.io/en/master/api.html?highlight=create channel#discord.Guild.create_text_channel
create vc docs: https://discordpy.readthedocs.io/en/master/api.html?highlight=create channel#discord.Guild.create_voice_channel

(Apologies if this is perceived as heavy spoon feeding)

haughty quartz
#

is there a way to make the bot send messages only visible to one person ?

#

bigger bots use it after application commands

opaque tiger
#

How can I create a restart bot command in discord.py?

my current progress:

@commands.command()
async def restart(self):
    await ctx.bot.logout()
    os.execv(sys.executable, ['python'] + sys.argv)
    await ctx.send(f"{self.user} has restarted.")
honest vessel
#

i think you need to make a script that first runs your bot script as a execution, and then restarts that from within that script

#

how u gonna make a command reach that i dunno

#

oh well logout, login? but that dosnt restart script

#

just the connection?

#
  • maybe u can unload all cogs, logout, log in reload all cogs?
placid skiff
final iron
unkempt canyonBOT
#

reload_extension(name, *, package=None)```
Atomically reloads an extension.

This replaces the extension with the same extension, only refreshed. This is equivalent to a [`unload_extension()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.unload_extension "discord.ext.commands.Bot.unload_extension") followed by a [`load_extension()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.load_extension "discord.ext.commands.Bot.load_extension") except done in an atomic way. That is, if an operation fails mid-reload then the bot will roll-back to the prior working state.
final iron
#

Simple

#

No need to do some hacky shit

quick gust
honest vessel
#

or DM's!

final iron
#

Oh wait

#

!d disnake.MessageInteraction

unkempt canyonBOT
#

class disnake.MessageInteraction```
Represents an interaction with a message component.

Current examples are buttons and dropdowns.

New in version 2.1.
placid skiff
honest vessel
#

really?

final iron
#

aha

placid skiff
#

They're just DM hahahaha

final iron
unkempt canyonBOT
#
Certainly not.

No documentation found for the requested symbol.

honest vessel
#

well its visible to one ๐Ÿ˜›

final iron
#

...

#

I'm a dumbass

placid skiff
final iron
#

Okay I;m done

placid skiff
#

you have to add discord-slash extension

final iron
#

!d disnake.MessageInteraction.send

unkempt canyonBOT
#

await send(content=None, *, embed=..., embeds=..., file=..., files=..., allowed_mentions=..., view=..., components=..., tts=False, ephemeral=False, delete_after=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sends a message using either [`response.send_message`](https://docs.disnake.dev/en/latest/api.html#disnake.InteractionResponse.send_message "disnake.InteractionResponse.send_message") or [`followup.send`](https://docs.disnake.dev/en/latest/api.html#disnake.Webhook.send "disnake.Webhook.send").

If the interaction hasnโ€™t been responded to yet, this method will call [`response.send_message`](https://docs.disnake.dev/en/latest/api.html#disnake.InteractionResponse.send_message "disnake.InteractionResponse.send_message"). Otherwise, it will call [`followup.send`](https://docs.disnake.dev/en/latest/api.html#disnake.Webhook.send "disnake.Webhook.send").

Note

This method does not return a [`Message`](https://docs.disnake.dev/en/latest/api.html#disnake.Message "disnake.Message") object. If you need a message object, use [`original_message()`](https://docs.disnake.dev/en/latest/api.html#disnake.MessageInteraction.original_message "disnake.MessageInteraction.original_message") to fetch it, or use [`followup.send`](https://docs.disnake.dev/en/latest/api.html#disnake.Webhook.send "disnake.Webhook.send") directly instead of this method if youโ€™re sending a followup message.
final iron
#

ephemeral kwarg

#

There

#

only took like 5 tries

placid skiff
#

oh

#

!d disnake.ApplicationCommandInteraction

unkempt canyonBOT
#

class disnake.ApplicationCommandInteraction```
Represents an interaction with an application command.

Current examples are slash commands, user commands and message commands.

New in version 2.1.
placid skiff
#

Yup this one is used in slash commands in disnake

#

is like the Context for d.py

slate swan
#

how do i get the cog class name from the cog object?

#

as a string

#

every class has a __name__ property

light violet
#

how to decrypt files encrypted with pytransorm

sullen shoal
final iron
hoary cargo
#

encrypting uids

#

man i hate slash commands, because sometimes as a user the list of commands from all bots is not even displayed just the built-in ffs

sullen shoal
#

or just discord being discord i suppose

steel void
#

ive been stuck on this problem for days.

I'm making blackjack for discord. using pycord. With this being said /blackjack starts the game but how can I allow people to hit? I want people to be able to hit if they just say "hit"

sullen shoal
light violet
steel void
#

yeah ihate buttons

#

theyre a pain

#

cant I just check if someone say "hit" within the slash command?

sullen shoal
#

like /hit

#

would do the work?

steel void
#

or just hit

sullen shoal
#

the message content would just be hit?

steel void
#

yeah

sullen shoal
#

i would not want to waste my time on something that wont work after the big update discord is going to release, making message intent privileged

steel void
#

why wouldnt it work for just using hit

#

since it's just a message content

sullen shoal
#

you need message intent to see messages

#

that isn't dmed to your bot or doesnt have your bot mentioned in it

steel void
#

oh jfc

#

thats so dumb

hoary cargo
#

and + it's even my server and i know i didn't disabled anything kek

steel void
#

ima off myself now

sullen shoal
steel void
#

i dont wanna learn how to use buttons properly its so hardd

#

is it possible to make a like subcommand for blackjack?

sullen shoal
#

using buttons is easier with discord.py 2.0 buttons than anything else you are trying to do

steel void
#

discord 2.0 wym by that

hoary cargo
#

you will eventually get used to it

steel void
#

idk im a noob coder in general

quick gust
steel void
#

oh i use pycord

final iron
#

Ew pycord

sullen shoal
quick gust
#

Then you're probably on the 2.0 version

steel void
#

pycord is good besides some of their staff members

sullen shoal
#

that actually sucks

steel void
#

some of their staff members do be rude as fuck

final iron
steel void
#

makes me so sad with the message intents, LIKE I JUST figured out how to do it

hoary cargo
final iron
#

Even danny specifically called them out

steel void
#

really

hoary cargo
steel void
#

why did he call them out what he say

final iron
hoary cargo
#

imma go bravo six and search

final iron
steel void
#

ah

#

anyone got a good video they can recommend for pycord buttons cause i guess ima have to figure out buttons :/

quick gust
#

It's the same as discord.py's buttons, since pycord is just a fork

steel void
quick gust
#

It does

hoary cargo
#

about pycord Kek

oblique python
#

Hi people!

hoary cargo
oblique python
#

I'm trying to make a bot join a server but every time I use the link, it just says no scopes were provided

#

I'm using diskord atm

#

Do I need to specify the scopes in the script for the bot directly or something like that as well?

hoary cargo
#

before generating the link you need the scopes and permissions

oblique python
hoary cargo
#

but did you selected any scope ?

steel void
#

since im using buttons inside of a command what would i do for the @CLIENT part?

oblique python
#

when i use the link it shows me the bot and allows me to choose the server and get through the captcha, then says no scopes were provided

steel void
#

or do I even need anything regarding client?

sullen shoal
steel void
#

for example I do

#
@CLIENT.slash_command(guild_ids=[938836203275452436], name = "blackjack", description = "Command is in testing.")
async def blackjack(ctx):``` to start blackjack, whenever i do async def buttons inside of this command do I need another @client if so what would i add
oblique python
sullen shoal
oblique python
#

1 sec, was just about to make the screenshot

steel void
#

how can i send a big text file here

#

to show you my code

sullen shoal
#

you use online text bins

#

one that i like a lot is, paste.disnake.dev

quick gust
#

!paste can be used aswell

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

steel void
#

how would I make a button send on the message containing the embed of the player / dealer cards

dire folio
#

How would I make a command to ban someone that isn't in the server

final iron
grim oar
#

!d discord.Guild.ban

final iron
#

Bot dead

unkempt canyonBOT
#

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

Bans 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.
#

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

Bans 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.
oblique python
#

so wait, before i embarrass myself further, what am I supposed to put in the redirect URL? I need it in order to generate the scopes URL

steel void
#

message intents only applies to servers above 100 right?>

tidal hawk
#

Can a bot see: for how long user has been in a voice chat?

slate swan
slate swan
#

but you can cache the user's join time with the event

oblique python
oblique python
#

I do have a server I can use if need be

slate swan
oblique python
slate swan
#

the client id is your bot's id

dire folio
oblique python
#

maybe I'm not understanding something more basic? So, I have this bot that was created in one account and another account which has management rights on the server has tester access to the bot. I thought the link simply allows me to invite the bot directly to the server from the acc that has manage rights, with the appropriate scopes and permissions selected in the dev portal (I ticked "bot" and some permissions to read history and create private threads)

minor totem
#

Now copy that link and open it with the account that has those permissions

honest vessel
#

@minor totemmust be bluenix i nvr seen u respawn before. Hi.

minor totem
pliant nacelle
minor totem
#

What happens when you run that?

pliant nacelle
#

i get this error

#

None
Traceback (most recent call last):
File "C:\Users\L3\Desktop\VoiceCreateBot\voicecreate.py", line 37, in <module>
bot.run(DISCORD_TOKEN)
File "C:\Users\L3\Python\lib\site-packages\discord\client.py", line 663, in run
return future.result()
File "C:\Users\L3\Python\lib\site-packages\discord\client.py", line 642, in runner
await self.start(*args, **kwargs)
File "C:\Users\L3\Python\lib\site-packages\discord\client.py", line 605, in start
await self.login(token)
File "C:\Users\L3\Python\lib\site-packages\discord\client.py", line 473, in login
data = await self.http.static_login(token.strip())
AttributeError: 'NoneType' object has no attribute 'strip'

minor totem
slate swan
#

did this?

minor totem
#

Since None is printed I have reason to think otherwise. Are you sure?

slate swan
#

ah they have it wrong in the readme. did you create an .env file?

slate swan
#

if not, make an .env file , with this structure ```
DISCORD_TOKEN_VOICE_CHANNELS= 'your token'

minor totem
minor totem
pliant nacelle
unkempt canyonBOT
#

voicecreate.py line 17

DISCORD_TOKEN = os.getenv("DISCORD_TOKEN_VOICE_CHANNELS")```
gusty hatch
#

how would i mention a user in a hyper link?

slate swan
#

they use .getenv directly

pliant nacelle
unkempt canyonBOT
#

voicecreate.py lines 12 to 16


client = discord.Client()

bot = commands.Bot(command_prefix=".")
bot.remove_command("help")```
slate swan
#

is how you make a hyper link if you want to mention im not quite sure

#

this makes me hate it already

gusty hatch
minor totem
# pliant nacelle win

Before you run the bot you have to do set DISCORD_TOKEN_VOICE_CHANNELS = ... and replace ... with your actual token.

gusty hatch
#

@gusty hatch

#

doesnt work

minor totem
gusty hatch
#

Yes

pliant nacelle
slate swan
#

this whole conversation is giving me a stroke

minor totem
slate swan
#

whats the point of doing that?

gusty hatch
#

Blu what am i doing wrong BATMAN

slate swan
#

!d discord.ext.commands.Bot

unkempt canyonBOT
#

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

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

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

this is all they used, the client definition was useless

slate swan
#

the Bot class is the subclass of Client so why use both?

#

it inherits everything

minor totem
pliant nacelle
#

soo what should i do abt that

minor totem
# slate swan whats the point of doing that?

No idea, they don't use client either - could probably have been accidentally been left over. The code works so why would you notice an issue if you're the person who wrote the code?

gusty hatch
#

when i click it , it doesnt nothing blu

minor totem
gusty hatch
minor totem
# pliant nacelle i already did it

You probably didn't do that correctly if it stil prints None? Try again, and make sure to do it in the same window and place as you later use to run the bot.

slate swan
#

!pip aiosqlite there's already an async driver for sqlite3 could have used that

unkempt canyonBOT
minor totem
# gusty hatch ^^^

Yeah then I am not sure, sorry. Usually you'd ping someone and then say "DM @minor totem"

steel void
#

how to edit a embed the bot sent using pycord?

slate swan
#

!d discord.Message.edit

unkempt canyonBOT
#

await edit(content=..., embed=..., embeds=..., attachments=..., suppress=..., delete_after=None, allowed_mentions=..., view=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the message.

The content must be able to be transformed into a string via `str(content)`.

Changed in version 1.3: The `suppress` keyword-only parameter was added.
pliant nacelle
#

still the same None

minor totem
steel void
#

would this not work?

    em = discord.Embed(title = f"Hand", color = discord.Color.blue())
    em.add_field(name = "Player Cards",value = f'{playerHand} | {score1}')
    em.add_field(name = "Dealer Cards",value = f'{dealerHand} | {score}')

    msg = await ctx.respond(embed = em)```

```py
            em2 = discord.Embed(title = f"Hand", color = discord.Color.blue())
            em2.add_field(name = "Player Cards",value = f'{playerHand} | {score1}')
            em2.add_field(name = "Dealer Cards",value = f'{dealerHand} | {score}')
            await asyncio.sleep(1)
            await msg.edit(embed = em2)```
#

idk what im doing wrong tbh but i get an error

steel void
#

it makes the bot respond instead of send a message

#

literally what you just did you replied aka responded to my msg

minor totem
# pliant nacelle still the same``` None```

How do you run the bot? What you should do is:

  1. Open CMD in the directory of the bot
  2. Set the environment variable (see above)
  3. Run the bot with like the command line with python or py

Is that what you're doing?

minor totem
dire folio
steel void
#

File "C:\Users\Alex\github\Gambling-bot\gamblingbot.py", line 145, in on_message
await msg.edit(embed = em2)
AttributeError: 'Interaction' object has no attribute 'edit'

slate swan
#

youre using interactions

slate swan
#

!d disnake.Interaction.edit_original_message

unkempt canyonBOT
#

await edit_original_message(*, content=..., embed=..., embeds=..., file=..., files=..., attachments=..., view=..., components=..., allowed_mentions=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the original, previously sent interaction response message.

This is a lower level interface to [`InteractionMessage.edit()`](https://docs.disnake.dev/en/latest/api.html#disnake.InteractionMessage.edit "disnake.InteractionMessage.edit") in case you do not want to fetch the message and save an HTTP request.

This method is also the only way to edit the original message if the message sent was ephemeral.

Note

If the original message has embeds with images that were created from local files (using the `file` parameter with [`Embed.set_image()`](https://docs.disnake.dev/en/latest/api.html#disnake.Embed.set_image "disnake.Embed.set_image") or [`Embed.set_thumbnail()`](https://docs.disnake.dev/en/latest/api.html#disnake.Embed.set_thumbnail "disnake.Embed.set_thumbnail")), those images will be removed if the messageโ€™s attachments are edited in any way (i.e. by setting `file`/`files`/`attachments`, or adding an embed with local files).
minor totem
#

Try again

slate swan
#

and odd to see you here bluenix how are youpithink

slate swan
flat solstice
manic wing
#

some shit like that

final iron
dire folio
minor totem
flat solstice
manic wing
#

and dislash is a 3rd party lib if you're looking for it

#

but thats just procastination

#

and isnt advised

flat solstice
manic wing
#

as if

pliant nacelle
#

in the .env should i past bot token ?

#

or voice channel token

kindred drum
#

yo would I apply past overwrites into a new one? e.g. keep an overwrite I just made (add a member to a channel) while adding a new member to it

#

{<Role id=915357451484790916 name='@everyone'>: <discord.permissions.PermissionOverwrite object at 0x0000024316F33B50>, <Member id=351090362682572802 name='Creepy' discriminator='8705' bot=False nick=None guild=<Guild id=915357451484790916 name='Cosmic Overground (Private)' shard_id=None chunked=True member_count=13>>: <discord.permissions.PermissionOverwrite object at 0x0000024316F33A60>} Old overwrite, I wanna add another member to the channel, how would I do this without removing this overwrite

minor totem
pliant nacelle
kindred drum
#

i hate overwrites ๐Ÿ˜ญ

minor totem
pliant nacelle
pliant nacelle
minor totem
#

Yes

#

Send that in "Command Prompt" ("CMD") before you start the script there

pliant nacelle
minor totem
minor totem
pliant nacelle
#

i did the cmd ?

pliant nacelle
minor totem
#

Yes now start the script with like python voicecreate.py or py voicecreate.py

pliant nacelle
minor totem
#

Replace voicecreate.py with this instead: ```python
import discord
import math
import asyncio
import aiohttp
import json
from discord.ext import commands
from random import randint
import traceback
import sqlite3
import sys
import os

client = discord.Client()

bot = commands.Bot(command_prefix=".")
bot.remove_command("help")
DISCORD_TOKEN = os.getenv("DISCORD_TOKEN_VOICE_CHANNELS")
if DISCORD_TOKEN is None:
DISCORD_TOKEN = input('Enter Discord Token: ')

initial_extensions = ['cogs.vc']

if name == 'main':
for extension in initial_extensions:
try:
bot.load_extension(extension)
except Exception as e:
print(f'Failed to load extension {extension}.', file=sys.stderr)
traceback.print_exc()

@bot.event
async def on_ready():
print('Logged in as')
print(bot.user.name)
print(bot.user.id)
print('------')

bot.run(DISCORD_TOKEN)

#

I added that input(). You could open an issue on the repository asking them to make it easier to use in the future

pliant nacelle
minor totem
pliant nacelle
#

i appreciate that

slate swan
#

and not

if not DISCORD_TOKEN:
maiden fable
#

Oh Blue here ๐Ÿ‘€

minor totem
minor totem
maiden fable
#

Good to see you here ๐Ÿค—

slate swan
drowsy condor
#

an error is displayed, but the text is sent that the user has kicked, how to fix it?

minor totem
quick gust
#

Though that won't work if that's the only mutual server with them, it won't DM them

drowsy condor
#

@minor totem I'm trying to make sure that when kicking myself, the kick text is not displayed, but only an error

#

it is for me?

quick gust
#

@lapis meadow you can just use len() on bot.guilds

lapis meadow
#

To any discord.py bot dev I have a question. I have a bot that I know is in some servers but I was wondering if I can get a command so that the bot displays in an embed how many active guilds it inor get the bot to update the status of how many guilds its in

quick gust
#

No, in your code

minor totem
lapis meadow
#

Iโ€™m fairly new. Any way someone could provide an example

minor totem
minor totem
# lapis meadow Yeah

Do you have a client or bot? There should be .guilds on it that is a list of all guilds. So you can just wrap that in len(...) and that will get you the number your bot is in.

lapis meadow
#

I have a bot. So like how would I put that into code and where?

#

len(bot.guilds)

minor totem
slate swan
#

30 min i think is enough

minor totem
lapis meadow
#

@client.command()
async def servers(ctx):
servers = list(client.guilds)
await ctx.send(fโ€Active in len(servers) servers!โ€)

#

Like this?

#

Iโ€™m really new at this I apologize

minor totem
# slate swan How?

You have an ID right? Do something like if ctx.author.id == the_target_id: and after it put the code you want to run when the author is trying to kick itself and then return so that the rest of the code doesn't run.

minor totem
minor totem
#

Note that your quotes were wrong, are you on mobile? They need to be the normal quotes you get on a keyboard

#

!charinfo โ€โ€

unkempt canyonBOT
minor totem
#

!charinfo "

unkempt canyonBOT
slate swan
#

the_target_id?

minor totem
#

Do you see the difference @lapis meadow?

slate swan
#

Okay

lapis meadow
#

Yeah Iโ€™m on my phone at the moment.

lapis meadow
#

At school until 3 than I can edit the code when I get home.

minor totem
# slate swan `the_target_id`?

Replace that with wherever you have the ID of the person you're kicking, that may be target.id or like member.id depending on how theยดcommand is setup

slate swan
#

that lovely blue heart bluenix gives it gives me memoriespithink

pliant nacelle
minor totem
hasty herald
#

hi, how to delete bot reply for user msg

pliant nacelle
minor totem
kind path
#

hello, im trying to set up an avatar command(like /avatar [user] and it sends you the user's avatar) but its not working, heres my code:

flat solstice
#

So I have this function counting a guilds emoji's```py
emoji_stats = Counter()
for emoji in guild.emojis:
if emoji.animated:
emoji_stats['animated'] += 1
emoji_stats['animated_disabled'] += not emoji.available
else:
emoji_stats['regular'] += 1
emoji_stats['disabled'] += not emoji.available

        fmt = f'Regular: {emoji_stats["regular"]}/{guild.emoji_limit} |     Animated: {emoji_stats["animated"]}/{guild.emoji_limit}'\

        if emoji_stats['disabled'] or emoji_stats['animated_disabled']:
            fmt = f'{fmt} Disabled: {emoji_stats["disabled"]} regular, {emoji_stats["animated_disabled"]} animated\n'

        fmt = f'{fmt} | Total Emojis: {len(guild.emojis)}/{guild.emoji_limit*2}'```and I'm calling it here```py
        embed.add_field(name = "Emotes", value = await self.emoji_counter(guild), inline = False)```which I assume is the wrong thing to do since it's showing `None` inside of my embed
minor totem
kind path
slate swan
#

@minor totem I do not understand(

kind path
#

it shows up on the slash commands list but i not send it

kind path
minor totem
hasty herald
#

I want to find the bot relpy at the original user msg

minor totem
cold sonnet
kind path
hasty herald
#

is there a way?

minor totem
minor totem
hasty herald
minor totem
minor totem
kind path
flat solstice
hasty herald
minor totem
hasty herald
#

not after removal

minor totem
minor totem
# hasty herald yes!!

That is impossible, you can only do the opposite (get the original message from a bot reply).

cold sonnet
lapis meadow
final iron
kind path
final iron
#

Can we see the code?

cold sonnet
kind path
final iron
cold sonnet
final iron
minor totem
# hasty herald the reference ?

Yes, a bot reply has a reference to the original message. If you have the original message there is no reference to the reply though

cold sonnet
#

or Member

kind path
cold sonnet
#

no, user: discord.User

final iron
flat solstice
final iron
#

You need to type hint it

kind path
#

?

minor totem
final iron
#
a: int
kind path
#

hint it? what that

lapis meadow
#

My apologies thanks!

final iron
#

Type hinting a to an int

minor totem
cold sonnet
unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

cold sonnet
#

typehint

slate swan
#

@minor totem

minor totem
kind path
slate swan
#

@bot.command()
@commands.has_any_role(692760082085183519, 940008547993927691)
async def kick(ctx, member: discord.Member, *, reason="ะžั‚ััƒั‚ัั‚ะฒัƒะตั‚"):
    try:
        if member==ctx.author:
            emb=discord.Embed(title="โŒ Error", description="ะ’ั‹ ะฝะต ะผะพะถะตั‚ะต ะบะธะบะฝัƒั‚ัŒ ัะตะฑั!", color=discord.Color.from_rgb(0, 0, 255), timestamp=ctx.message.created_at)
            emb.set_footer(text="ยฉ ะ’ัะต ะฟั€ะฐะฒะฐ ะทะฐั‰ะธั‰ะตะฝั‹ The Greatest", icon_url=ctx.author.avatar_url)
            await ctx.reply(embed=emb)       
        else:
            await member.kick(reason=reason)
        emb=discord.Embed(title="ะšะธะบ ะฟะพะปัŒะทะพะฒะฐั‚ะตะปั", description="**__ะ˜ะฝั„ะพั€ะผะฐั†ะธั:__**", color=discord.Color.from_rgb(0, 0, 255), timestamp=ctx.message.created_at)
        emb.set_footer(text="ยฉ ะ’ัะต ะฟั€ะฐะฒะฐ ะทะฐั‰ะธั‰ะตะฝั‹ The Greatest", icon_url=ctx.author.avatar_url)
        emb.add_field(name="**ะฃั‡ะฐัั‚ะฝะธะบ:**", value=f"**{member.name}** ({member.mention})", inline=False)
        emb.add_field(name="**ID:**", value=f"**{member.id}**", inline=False)
        emb.add_field(name="**ะšะธะบะฝัƒะป:**", value=f"**{ctx.author.name}**", inline=False)
        emb.add_field(name="**ะŸั€ะธั‡ะธะฝะฐ:**", value=f"{reason}", inline=False)
        await ctx.reply(embed=emb)
    except Exception as e:
        await ctx.send("I can't do that")
        print(e)
minor totem
minor totem
hasty herald
#

ayt

minor totem
# slate swan ```py @bot.command() @commands.has_any_role(692760082085183519, 940008547993927...

Yes, this is great! Just add return after await ctx.reply(embed=emb) so that it looks like this: ```python
@bot.command()
@commands.has_any_role(692760082085183519, 940008547993927691)
async def kick(ctx, member: discord.Member, *, reason="ะžั‚ััƒั‚ัั‚ะฒัƒะตั‚"):
try:
if member==ctx.author:
emb=discord.Embed(title="โŒ Error", description="ะ’ั‹ ะฝะต ะผะพะถะตั‚ะต ะบะธะบะฝัƒั‚ัŒ ัะตะฑั!", color=discord.Color.from_rgb(0, 0, 255), timestamp=ctx.message.created_at)
emb.set_footer(text="ยฉ ะ’ัะต ะฟั€ะฐะฒะฐ ะทะฐั‰ะธั‰ะตะฝั‹ The Greatest", icon_url=ctx.author.avatar_url)
await ctx.reply(embed=emb)
return
else:
await member.kick(reason=reason)
emb=discord.Embed(title="ะšะธะบ ะฟะพะปัŒะทะพะฒะฐั‚ะตะปั", description="ะ˜ะฝั„ะพั€ะผะฐั†ะธั:", color=discord.Color.from_rgb(0, 0, 255), timestamp=ctx.message.created_at)
emb.set_footer(text="ยฉ ะ’ัะต ะฟั€ะฐะฒะฐ ะทะฐั‰ะธั‰ะตะฝั‹ The Greatest", icon_url=ctx.author.avatar_url)
emb.add_field(name="ะฃั‡ะฐัั‚ะฝะธะบ:", value=f"{member.name} ({member.mention})", inline=False)
emb.add_field(name="ID:", value=f"{member.id}", inline=False)
emb.add_field(name="ะšะธะบะฝัƒะป:", value=f"{ctx.author.name}", inline=False)
emb.add_field(name="ะŸั€ะธั‡ะธะฝะฐ:", value=f"{reason}", inline=False)
await ctx.reply(embed=emb)
except Exception as e:
await ctx.send("I can't do that")
print(e)

kind path
cold sonnet
#

jesus

kind path
#

from discord_slash import SlashCommand

#

what?

#

is there some better thing to be using on replit?

slate swan
#

Ok

minor totem
cold sonnet
#

I do... sorry

kind path
kind path
minor totem
kind path
#

ok thx

lapis lintel
#

You can use disnake also, which is a d.py fork that has slash commadns

kind path
minor totem
#

To be clear @kind path this was directed towards you ^^

kind path
#

ik

kind path
#

3.0.3

#

does that help?

minor totem
#

Yes thank you

kind path
#

yw

slate swan
#

Thank you @minor totem

minor totem
#

@kind path found it! Here's an example of a user-option: ```python
@slash.slash(
name = "user",
description = "user",
options = [
create_option(
name = "user",
description = "user",
required = True,
option_type = 6
)
]
)
async def user(ctx, user: discord.User):
print(user)
await ctx.send("Done")

rocky trench
#

How to check if bot is 'speaking'

kind path
rocky trench
#

if ctx.guild.VoiceClient.is_playing:

kind path
#

idk how that works

rocky trench
#

I tried ^^ but it doesnt work

kind path
#

i tried learning that stuff a while back and gave up

minor totem
rocky trench
cold sonnet
#

!d discord.Guild.voice_client

unkempt canyonBOT
#

property voice_client: Optional[VoiceProtocol]```
Returns the [`VoiceProtocol`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceProtocol "discord.VoiceProtocol") associated with this guild, if any.
cold sonnet
#

I'm not sure if VoiceProtocol has everything that VoiceClient does

slim ibex
#

I donโ€™t think there is something to check that

cold sonnet
#

well clearly, VoiceClient.is_playing does exist

slim ibex
#

Mhmm

slate swan
#

I canโ€™t find the right channel for this so anyone know how to get requests from website with headers

minor totem
# rocky trench playing music, yes

By the looks of it, what you need to do is keep the VoiceClient around when you connect to the voice channel. So you'll need need to store it on the bot somewhere!

cold sonnet
#

no, but VoiceClient inherits VoiceProtocol ๐Ÿ˜ฆ

rocky trench
#

I tried if ctx.guild.voice_client.is_playing():

minor totem
kind path
#

oh right

kind path
cold sonnet
rocky trench
#

how

cold sonnet
#

so at the point you used VoiceChannel.connect()

#

save its return to a variable

rocky trench
#

there used to be if ctx.guild.voice_client.is_playing()

#

I see

#
    @slash_util.slash_command(description = 'Joins the voice channel')
    async def join(self, ctx):
        if ctx.author.voice is None:
            return await ctx.send("You are not connected to a voice channel, please connect to the channel you want the bot to join.")
        if ctx.guild.voice_client:
            return await ctx.send("I am already connected to a voicechannel.")
        vc = await ctx.author.voice.channel.connect()
        await ctx.guild.change_voice_state(channel = ctx.author.voice.channel,self_deaf=True)
        await ctx.send('I joined the voice channel!', ephemeral = True)```
cold sonnet
#

yeah

minor totem
cold sonnet
#

vc is your VoiceClient

minor totem
minor totem
rocky trench
#

yh I see

#

its not about if the bot is connected or not btw

#

its about if its playing

kind path
minor totem
# rocky trench its about if its playing

Yeah, so then you can access the dictionary later like this: ```python
vc = ctx.bot.my_voice_clients.get(ctx.guild.id)
if vc is None:
# The bot isn't connected. Tell the user this
...
return

You can now do something with 'vc'

print(vc.is_playing())

minor totem
rocky trench
#

@minor totem

#

its not if bot is in vc, that its actually playing

cold sonnet
#

yeah

minor totem
minor totem
kind path
minor totem
kind path
#

ok

kind path
minor totem
cold sonnet
#

could be the embed

#

I don't think you can leave it like that

slate swan
#

@minor totem Can you tell me how to make it so that when a user does not have a role for a kick, it says that there are no rights?

cold sonnet
#

no title, nor description

kind path
#

@minor totem

minor totem
tidal hawk
#

Is there some sort of Event reference when user connects with voice channel?

final iron
#

!d discord.on_voice_state_update

unkempt canyonBOT
#

discord.on_voice_state_update(member, before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") changes their [`VoiceState`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceState "discord.VoiceState").

The following, but not limited to, examples illustrate when this event is called...
tidal hawk
#

thanke

kind path
#

it does not do anything

#

i ran command twice and it printed nothing

minor totem
slate swan
#

Okay

kind path
# minor totem Where do you print? Make sure to print before you get the error
@slash.slash(
  name = "user",
  description = "user",
  options = [
    manage_commands.create_option(
      name = "user",
      description = "user",
      required = True,
      option_type = 6
    )
  ]
)
async def test(ctx: SlashContext, user: discord.User):
  embed=discord.Embed(description="** **", color=0xffc700)
  embed.set_image(f"{user.avatar_url}")
  print(user)
  await ctx.send(embed=embed)
minor totem
kind path
rocky trench
#
        ctx.guild.voice_client.play(discord.PCMVolumeTransformer(discord.FFmpegPCMAudio(
            executable=f"C:/Users/bert/OneDrive - DvM Humaniora/Documenten/ShareX/Tools/ffmpeg.exe", source=url)),
            after=lambda error: self.bot.loop.create_task(self.play_next_song(ctx)))```
timber matrix
#

whenever I click "create application" the website just diverts me to the discord home page. How do I avoid this

#

nevermind, I figured it out

hoary cargo