#discord-bots

1 messages · Page 599 of 1

slate swan
#

It would work as it is but it is bad practice.

#

Do it again and show

full valley
#

secondly, its not working because when I do !stats, its not showing my own stats

#

however the !stats @ user is working

slate swan
#

Print info

bitter harness
#

hi i wanna do this :-

for example someone adds my bot in their server

and there is a join log in my main server

for example

WE JOINED PYTHON server```
slate swan
#

Gaah I'm on phone I can't understand shat
Give me a sec

full valley
#

@slate swan

slate swan
#

Ty

#

You might have used tab instead of space or vice versa and your IDE did not automatically change it

#

also this code do not send the info

slate swan
full valley
slate swan
#
@bot.command(pass_context=True, name="stats", description="Check your 6Mans stats")
async def stats(ctx, player:discord.User = None):
    if ctx.channel.id in allowed_channels:
        if player == None:
            pid = ctx.author.id
            info = pstats.find_one({"id": pid})
        else:
            pid = player.id
            info = pstats.find_one({"id": pid})
        if info is None:
            embed = discord.Embed(description="You have not played a game yet!", color=0xE74C3C)
            embed.set_footer(text="CBell 6 Mans | Created by Heptix", icon_url="https://i.imgur.com/1utxX7d.png")
            await ctx.channel.send(embed=embed)```

This is based on the code you sent. I fixed the indentation error
bitter harness
slate swan
full valley
full valley
#

because it was just under else

slate swan
#

Coding on phone is a big nono sigh

full valley
#

My bad, i didnt realize you could do if else if

slate swan
full valley
#

My ass would have just pasted if info is none code under each

slate swan
slate swan
full valley
slate swan
#

its easier

slate swan
slate swan
boreal ravine
#

by the way @full valley you dont need pass_context

bitter harness
full valley
slate swan
#

Ty once again.

slate swan
full valley
slate swan
boreal ravine
slate swan
slate swan
#

Gods I just want a laptop in my hands now

bitter harness
#

okie 😮

slate swan
#

@full valley can you send the full code for the command?

full valley
#

If i do !stats (id of another member), it doesnt work, just gives me my own stats

slate swan
#

full code pls 🧘‍♂️

#

long ouch
ok

full valley
slate swan
#

also remember this
you dont want a lot of nested shit

slate swan
#
if x is this:
    print(crap)
    do(crap)
```or or or ```py
if x is not this:
    return
print(crap)
do(crap)```
slate swan
#

And does it need it?

#

not needed

#

Why is that so?

#

they are just accessing public info(snowflake id) of a particular mentioned user
and fetching data of it from their own db

full valley
slate swan
full valley
slate swan
#

player:discord.User = None
the :discord.User part tries to convert the mentioned/id to a discord object Hmm

#

try printing pid before info =
@full valley

full valley
slate swan
#

yup

icy mango
#

Are there any ideas for utility command : which no popular bot has?

full valley
#

yeah so its printing the right id @slate swan

#

but is it a string, instead of an integer or something

slate swan
#

in my bot, this is working completely fine

slate swan
full valley
slate swan
#

pstats.find_one({"id": pid}) tis find_one wants id as int, am i correct? @full valley

#

just pass int(pid) into it Hmm

#

yea thats also right

full valley
#

yeah so its stored as an int

#

thats probably it

#

nvm

full valley
slate swan
#

i just cleaned your code itself a little Hmm

#

try printing info too btw Hmm

full valley
#

Command raised an exception: UnboundLocalError: local variable 'info' referenced before assignment

#

@slate swan

slate swan
full valley
#

wait im an idiot

#

thats my bad

#
    print(info)
    info = pstats.find_one({"id": int(pid)})
#

LOL

slate swan
#

oof

slate swan
full valley
slate swan
#

why dont you just do name="Wins", value=f"{info["Wins"]}", inline=True

full valley
#

fyi that is not my id

slate swan
slate swan
#

its printing the right id but getting the wrong info blobthinkmad

full valley
#

yeah

slate swan
#

does info print the correct info for id @full valley ?

full valley
#

{'_id': ObjectId('6193644878c4593b498bd45e'), 'id': 606022210573959179, 'Wins': 0, 'Losses': 0, 'MMR': 1600, 'Rank': 'C'}

slate swan
#

well what the fuck

full valley
#

but that is not my id

slate swan
#

ah.

full valley
#

what if

slate swan
#

ayo

slate swan
full valley
#

So they were his stats

#

LOL

full valley
#

tysm though

slate swan
#

How to check if bot has permission in a "channel"

like we use guild.me.guild_permissions.send_messages

slate swan
unkempt canyonBOT
#

permissions_for(obj, /)```
Handles permission resolution for the [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") or [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role").

This function takes into consideration the following cases...
terse flare
#

hmmm

#

I changed from discord.py in pypi to discord.py in github but there's some bugs in code because of this change

maiden fable
#

Okay?

terse flare
#

in discord pypi we can use from discord.ext import commands but now I can't

#

hmm idk how to fix it

maiden fable
#

That isn't possible? That's always supported

#

Can I know whats the error?

terse flare
#

it's "can not import commands from module discord"

#

hmm

#

maybe it's path error?

#

let me see

#

agh yes path error

#

but there's a new error

#

My bot: (I'm newbie)

import os
from discord.ext import commands
import discord
from dotenv import load_dotenv
from discord import Member
from discord.ext import commands
from discord.ext.commands import has_permissions, MissingPermissions
import random
import asyncio

load_dotenv('DISCORD_TOKEN.env')
TOKEN = os.getenv('DISCORD_TOKEN')
bot = commands.Bot(command_prefix=';') 
bot.remove_command("help")

@bot.event
async def on_ready():
    activity = discord.Game(name="A game", type=3)
    await bot.change_presence(status=discord.Status.online, activity=activity)
    print("Bot is ready!")
    
@bot.command()
@commands.has_permissions(ban_members=True)#bans members if admin role is true
async def ban(ctx, user: discord.Member, *, reason="No reason provided"):
        await user.ban(reason=reason)
        ban = discord.Embed(title=f":boom: Banned {user.name}!", description=f"Reason: {reason}\nBy: {ctx.author.mention}",color=0xB026FF)
        await ctx.message.delete()
        await ctx.channel.send(embed=ban)
        await user.send(embed=ban)

@bot.command()
@commands.has_permissions(kick_members=True)
async def kick(ctx, user: discord.Member, *, reason="No reason provided"):
        await user.kick(reason=reason)
        ban = discord.Embed(title=f":boot: Kicked {user.name}!", description=f"Reason: {reason}\nBy: {ctx.author.mention}",color=0xB026FF)
        await ctx.message.delete()
        await ctx.channel.send(embed=ban)
        await user.send(embed=ban)
#

@bot.command()## get mentioned users avatar
async def av(ctx, *,  avamember : discord.Member=None):
    userAvatarUrl = avamember.avatar_url
    await ctx.send(userAvatarUrl)

@bot.command()##help command
async def help(ctx):
    em = discord.Embed(title="Tutorial Bot command list:", description="", color=0x2f3136)
    em.add_field(name="`;ban {user}`", value="Bans the user.")
    em.add_field(name="`;kick {user}`", value="Kicks user.")
    em.add_field(name="`;av {user}`", value="Gets the mentioned users pfp.")

    em.set_footer(text="Krise Alumine")
    await ctx.send(embed=em)

bot.run(TOKEN)
#

the bug is:

   [ ...Many traceback... ]
    from .bot import *
  File "/private/var/mobile/Containers/Shared/AppGroup/162FBE5F-D295-49F2-AA76-1963F27DA4B8/Pythonista3/Documents/site-packages/discord/ext/commands/bot.py", line 25
    from __future__ import annotations
                                     ^
SyntaxError: future feature annotations is not defined

In modules of new discord.py

#

hmmm

#

wait?!!

#

it's version error again?

#

my python ver. is 3.6.1

lethal umbra
#

How you all get dpy 2.0

slate swan
#

"""
While you can install discord.py 2.0a, Danny doesn't recommend it, since it has breaking changes, and drops support for older version of Python. Regardless, if you want to install it, just do it like you normally will from Git. https://github.com/Rapptz/discord.py

This has breaking changes, so expect bugs to occur as well as features to change or become deprecated.
"""

GitHub

An API wrapper for Discord written in Python. Contribute to Rapptz/discord.py development by creating an account on GitHub.

terse flare
#

wait, what's version of python dpy 2.0 support for?

#

OvO)?

slate swan
#

just use 3.9 for gods sake idk

terse flare
#

yes dammit

#

I have only a iphone and Pythonista, and now it's using Python 3.6.1

#

_:(´ཀ`」 ∠):

opaque plinth
terse flare
#

there's no way to build a bot

lethal umbra
#

Fails on dpy 2.0 only

slate swan
#

depends which tutorial you are using and which api you are using MC_lmao

slate swan
lethal umbra
opaque plinth
#

Lol

slate swan
lethal umbra
slate swan
#

well figure out for which api its using that token and get your own token for it

placid skiff
#

Guys a lapsus, how i make the bot so it works only for one guild?

stoic bridge
#

you can use errors for checking like

@client.event
async def on_command_error(ctx, error):
    if isinstance(error, commands.errors.CommandNotFound):
        await ctx.channel.purge(limit=1)

the thing is it only works with message that starts with the prefix of your bot

boreal ravine
#

An "API token" is something you need to access an API (like a password of sort)

#

you can check for the message content to see if its "something" you want and then you could delete it I guess

rough snow
visual island
#

if message.channel.id == ...:

sullen shoal
#

await message.delete(message)

heavy folio
#
      public_flags = {
        "bug_hunter": "![bughunter](https://cdn.discordapp.com/emojis/900314000972206110.webp?size=128 "bughunter")",
        "bug_hunter_level_2": "![bughunter2](https://cdn.discordapp.com/emojis/910104023917547561.webp?size=128 "bughunter2")",
        "discord_certified_moderator": "![discordcertifiedmod](https://cdn.discordapp.com/emojis/900312231500218398.webp?size=128 "discordcertifiedmod")",
        "early_supporter": "![earlysupporter](https://cdn.discordapp.com/emojis/900313515561218058.webp?size=128 "earlysupporter")",
        "early_verified_bot_developer": "![earlyverifiedbotdev](https://cdn.discordapp.com/emojis/909978235863982110.webp?size=128 "earlyverifiedbotdev")",
        "hypesquad": "![hypesquadevents](https://cdn.discordapp.com/emojis/910105356666023948.webp?size=128 "hypesquadevents")",
        "hypesquad_balance": "![hypesquadbalance](https://cdn.discordapp.com/emojis/909978235956244530.webp?size=128 "hypesquadbalance")",
        "hypesquad_bravery": "![hypesquadbravery](https://cdn.discordapp.com/emojis/909978236967063562.webp?size=128 "hypesquadbravery")",
        "hypesquad_brilliance": "![hypesquadbrilliance](https://cdn.discordapp.com/emojis/909978235935268904.webp?size=128 "hypesquadbrilliance")",
        "partner": "![partner](https://cdn.discordapp.com/emojis/900313311894200401.webp?size=128 "partner")"
      }

      if member.public_flags is None:
        yourPublicFlags = "None"
      else:
        for badge in member.public_flags:
          print(badge)```how do i display member's public flags using my own emojis
#

thing is idk how to continue after the for loop

boreal ravine
#

check the message channel id

#

well it exists

#

yes

sullen shoal
#

channel id needs to be int btw

slate swan
#

yeš

visual island
sullen shoal
#

and that verification system is very easy to bypass

rare saddle
#

When I try to add a role to all channels and issue permissions, this error appears

visual island
#

not directly PermissionOverwrite

visual island
#

for @everyone role?

rare saddle
visual island
#

ah

#

overwrites = {your_role: PermissionOverwrite(speak=True, send_messages=True)}

visual island
#

yes

rare saddle
slate swan
#

nu , it must just be discord.PermissionOverwrite object

#
overwrite = discord.PermissionOverwrite()
overwrite.send_messages = False
overwrite.read_messages = True
await channel.set_permissions(member, overwrite=overwrite)
``` example from the docs
visual island
#

oh my bad

#

I thought they were using .edit() method

brave flint
#

Hello i have a question so i made a wikisearch commands with wikipedia.py
here is my code :

    async def wiki_search(self, ctx, *,question):
        def wsearch(self, arg):
            wsearch = wikipedia.summary(arg, sentences=5, chars=500)
            return wsearch
        wembed = discord.Embed(title="Wiki search", description=wsearch(question))
        await ctx.send(embed=wembed)```
i run it with ?wiki amd and get error :
```TypeError: wsearch() missing 1 required positional argument: 'arg'```
slate swan
boreal ravine
#

anyways it looks like you didnt enter anything at question or its a parameter issue

brave flint
brave flint
slate swan
boreal ravine
boreal ravine
brave flint
#

Uh i had no idea

slate swan
boreal ravine
#

you dont need to codeblock everything

slate swan
#

I like them tho😔

brave flint
#

So i need to my def wiki_search to another name thennmy wsearch = wiki_search question?

slate swan
brave flint
#

Ok

#

Oh i see

#

Tq for help

slate swan
#

Yw

slate swan
#

whats mute_role

rare saddle
# slate swan whats mute_role

This role is installed by the owner of the server for the mutation of participants, and I get this role from the database and want to add it to all channels

slate swan
rare saddle
#

yea

slate swan
#

works decently for me

#

ohhh wait py for guild in self.bot.guilds: for channel in guild.channels:

so basically what's happening is , the bot tries to edit a channel for a role that is not from that server

rare saddle
slate swan
#

and use a guild object to which the role belongs

slate swan
#

yea sure

#

or even for channel in ctx.guild.channels would work

rare saddle
rare saddle
#

How to make the date show as in (de_DE)

#

So that the day goes first, then the month and the last year

glass rock
#

raise HTTPException(r, data)
discord.errors.HTTPException: 429 Too Many Requests (error code: 0): You are being blocked from accessing our API temporarily due to exceeding our rate limits frequently. Please read our docs at https://discord.com/developers/docs/topics/rate-limits to prevent this moving forward.
why do i keep getting this error

Discord Developer Portal

Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.

boreal ravine
glass rock
#

i dont think i made even 1 though

#

and i definitely didnt make more than 50/sec

boreal ravine
#

@glass rock

  • They use a shared IP for everything running on the service.
    This one is important - if someone is running a user bot on their service and gets banned, everyone on that IP will be banned. Including you.
glass rock
glass rock
glass rock
#

ty

slate swan
#

How do i add a illegal character to a str?

maiden fable
slate swan
maiden fable
#

'""'

#

Or just use \

boreal ravine
unkempt canyonBOT
#

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

what illegal characters? 'this'?
boreal ravine
#

🤨

maiden fable
#

print(""hi")

boreal ravine
#

invalid syntax

slate swan
#

print("im a string "hello"im a string")

boreal ravine
maiden fable
unkempt canyonBOT
#

@maiden fable :white_check_mark: Your eval job has completed with return code 0.

"hi
boreal ravine
#

oh

slate swan
boreal ravine
#

what hunter said

#

!e

print("hi \"hi\" \"hi\" ")
unkempt canyonBOT
#

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

hi "hi" "hi" 
slate swan
#

Ok thx

gaunt ice
#

@slate swan halp am trying to connect a time api and i.... need help

#

here in the datetime i need to retrieve 2 digits

#

but dunno how to

#

halp

visual island
#

!d discord HTTPException.text

#

woops

#

!d discord.HTTPException.text

unkempt canyonBOT
visual island
#

there

gaunt ice
#

hm is it for me?

visual island
#

no

gaunt ice
#

ok..............

visual island
gaunt ice
#

the json data

visual island
#

ex.text

gaunt ice
#

{"abbreviation":"IST","client_ip":"115.97.36.3","datetime":"2021-11-16T18:46:01.325874+05:30","day_of_week":2,"day_of_year":320,"dst":false,"dst_from":null,"dst_offset":0,"dst_until":null,"raw_offset":19800,"timezone":"Asia/Kolkata","unixtime":1637068561,"utc_datetime":"2021-11-16T13:16:01.325874+00:00","utc_offset":"+05:30","week_number":46}

#

this is it in this i need to retrieve the datetime

visual island
#

then what do you mean by 2 digits

gaunt ice
#

the thing which i bolded

#

the 18 i need to retrive that place

#
            em=discord.Embed(title='Error!', description=f"{error}.", colour=discord.Colour.red())
 #           em.add_field(name=f'Failed exception:', value=ctx)
            await ctx.send(embed=em)```
#

here my error handler

gaunt ice
#

oki TYY lemme try

visual island
#

for missing permission raised from HTTPException, you cant

boreal ravine
#

u tried indexing discord

#

good job

gaunt ice
#

oh......

#

welp , kayle then halp me

boreal ravine
#

well what did u try to do

gaunt ice
gaunt ice
#

and from the data i highlighted the 2 digits

boreal ravine
#

why

gaunt ice
#

i want to retrieve that

boreal ravine
#

do u even need the 2 digits

gaunt ice
#

those are the hours , im making a change_pfp thingy

boreal ravine
#

hm

gaunt ice
#

the bot's pfp

#

it shud change every 12 hours

#

so

boreal ravine
#

just make a loop

gaunt ice
#

i mean i can make it with tasks but the timing must be perfect for the server people

boreal ravine
#

why perfect

#

🤨

gaunt ice
#

;-;

boreal ravine
#

well

#

just use a tasks.loop

#

it dont have to be perfect 😌

gaunt ice
#

hm

#

oki ;-;

#

i mean it shud change different pfps @boreal ravine

boreal ravine
#

use a loop?

gaunt ice
#

can ya help this poor bot guy

boreal ravine
#

what

#

🤨

gaunt ice
#

hm

#

hm

boreal ravine
#

.

#

bruh

#

wtf u tryna do

gaunt ice
#

lul use normal cmd tbh

#
async def change_pfp():
#  responseTimezone = requests.get("http://worldtimeapi.org/api/timezone/Asia/Kolkata")
#  data = json.loads(responseTimezone)
#  response = data['datetime']
#  response1 = response
 with open('night.png', 'rb') as image:
    

  if client.user.avatar == image:
    with open('sun.png','rb') as image2:
      await client.user.edit(avatar=image2)

  else:
    with open('night.png','rb') as image:
      await client.user.edit(avatar=image)```
boreal ravine
#

u cant tell what permission needs to be enabled if u want that make normal command errors

gaunt ice
#

now what does this do

#

true lul

boreal ravine
gaunt ice
#

i tried it for my bot and it totally was weird

#

umm

boreal ravine
#

yes

gaunt ice
#

slash command handlers are......... idk read the docs ig?

boreal ravine
#
@bot.command()
async def roll(...):
  ...

@roll.error
async def ...(...):
  ...
```this is a command error
#

shit lib

#

use a proper fork thats not one designed to be used with dpy

#

forks have easier syntax

#

nice

#

Now whats your error again

#

yes

#

disnake, pycord, nextcord (beta iirc) etc

#

is this getting raised when ur doing slash commands

#

ah

#

you need the application.commands + bot scope in your bot

#

re-invite it with the scopes

gaunt ice
#

ey

#

@boreal ravine can we change the bot's pfp using cmd

#

oh wait i got it ig

boreal ravine
#

hm does ur bot have perms

gaunt ice
#

ugh

boreal ravine
#

Whos name did u try to change

boreal ravine
#

show code

#

afk command

#

hm

#

well

#

it looks like

  1. bot didnt have permissions
  2. bot didnt have a certain scope
  3. hierarchy
#

try-excepts

gaunt ice
#

it isnt working

boreal ravine
gaunt ice
#

hm

hushed galleon
#

or more preferably a check + error handler

#

you have the bot perm check in there too, you just havent specified any permission to check

slate swan
#

how do I get all the messages in the bots cache?

gaunt ice
#

i hab a doubt

#

can we use more than 1 database in replit?

boreal ravine
#

very nice

boreal ravine
gaunt ice
#

ik but

#

can we use some different database , which is the best one

boreal ravine
#

theres literally nothing stopping you

#

from using another db

gaunt ice
#

hm ok

boreal ravine
#

not like its illegal or anything 🤨 😌

gaunt ice
#

i need suggestions for database

boreal ravine
#

sql, mongo

gaunt ice
#

oki

slate nymph
boreal ravine
#

you think what

slate nymph
#

in replit its hard to protect ur db stuff

#

since its public

boreal ravine
#

dude

#

you know a proper IDE exists

slate nymph
#

so you need a replit database?

boreal ravine
#

VSC, PyCharm exists

#

if u dont want ur shit stolen just use those 🤨

slate nymph
boreal ravine
fallen mica
#

Is sql lite a good database module for discord.py???

slate nymph
#

yes

boreal ravine
#

proper IDEs are private

slate swan
slate nymph
boreal ravine
slate nymph
#

people use replit just because its free hosting

fallen mica
gaunt ice
slate swan
boreal ravine
boreal ravine
fallen mica
#

Ohhhhh

slate nymph
boreal ravine
#

shrug

slate nymph
#

¯\_(ツ)_/¯

slate swan
#

A vps is better than replit premium tbh

slate nymph
#

replits already trash and your giving it even more money

slate swan
#

🤷‍♂️

slate nymph
spiral frigate
#

help


    @commands.command(name="настройки")
    async def settings(self, ctx, *, value=None):
        if settings == "авто-роль":

            if value == None:
                embed = disnake.Embed (
                    title = ':x: Ошибка',
                    description = f'>>> Ты должен(на) указать 1 роль которая будет выдаваться автоматический.',
                    colour = 0xff6c66
                )
                embed.set_footer(text= 'Барабан4ик © 2021 Все права у тянок', icon_url= self.owner.avatar)

                await ctx.reply(embed = embed, delete_after= 20)
            elif len(value) >=2:  #There's a problem here
                print(len(value))
            else:

                role = value.replace("<@&", "").replace(">", "")

                embed = disnake.Embed (
                    title = 'Авто роль:',
                    description = f'>>> **Установлено на:**\n{value}',
                    colour = 0x694c5f
                )
                embed.set_footer(text= 'Барабан4ик © 2021 Все права у тянок', icon_url= self.owner.avatar)

                await ctx.reply(embed = embed)

                guild = ctx.guild

                self.collection.update_one({"_id": guild.id}, {"$set": {"auto_role": int(role)}})

he writes that there are 22 words in the line and there are 1 of them there
What I write in the argument: <@&ROLE>

gaunt ice
slate nymph
#

but to use a vps

slate swan
spiral frigate
slate nymph
#

aws has 1 year free trial @gaunt ice

#

use it

gaunt ice
#

true as soon as i get my own moni , its raining host

slate nymph
#

then after aws trial ends u can use google cloud trial for 3 months

#

xd

gaunt ice
#

hmm

slate swan
slate nymph
#

i m still using the trial

#

(and i dont want to pay either nor i want to know the cost)

slate swan
#

Digital oceans is 5 bucks a month for the lowest plan

gaunt ice
#

i will never forget that day when i saw a utube tutrl to make a cmd and was so happy the bot responded

brisk helm
#

How to do something like global unabn command

gaunt ice
gaunt ice
#

i was freaking out......... i know javascript but its hard to make discord bots in that

slate swan
gaunt ice
#

LMAO YEA

#

i felt like im a hecker

slate swan
gaunt ice
#

pls wait

boreal ravine
#

you just need to be good in javascript to make your bot respond

slate swan
boreal ravine
#

djs generally has the same syntax/naming as dpy

slate swan
#

🤷‍♂️

boreal ravine
#

iirc message.content is messageContent in djs

dapper cobalt
#

It's also message.content.

slate swan
slate swan
edgy vine
#

.

dapper cobalt
dapper cobalt
#

It's pretty much very same. A message is also a discord.Message object, and so is member and multiple other things.

slate swan
edgy vine
slate swan
slate swan
#

Because it's commands and not command

#

wut

#

its Bot.command() , they just have m thrice

slate nymph
#

i think

slate nymph
slate swan
#

yea

slate swan
winter moth
#

im super new to python and coding but im trying to do make a bot where if the correct string of words are entered they get a good response. If the member doesnt enter that correct response they get a premade message random that flames them. I can get the message to send for the right answer but the random message is beating me up.

winter moth
#

import discord
import os
import requests
import random
from keep_alive import keep_alive

client = discord.Client()
message = [
"'Oi! Look at this loser here!'"
"'YOU DAFT PRAT'"
"'Better luck next time… NOT!'"
]
@client.event
async def on_ready():
print('You have logged in as {0.user}'.format(client))

called whether there is a message in the chat

@client.event
async def on_message(message):
if message.content == 'scar calico hoodie wink':
await message.channel.send('You cracked the code🔥 Only the first one to get this wins.')

else:
await message.channel.send, "{}".format(random.message(message));

keep_alive()
client.run(os.getenv('token'))

tawdry lantern
#

hello. can you change the discord bot permissions later.? like i dont really know what permissions to give the bot and if i miss something can i add later?

boreal ravine
#

admin

winter moth
#

you can always change discord perms

boreal ravine
slate swan
slate swan
tawdry lantern
#

?

slate swan
tawdry lantern
#

ok

slate swan
winter moth
#

would this look right?

else:
await message.channel.send, ~~"{}".format(random.message(message));~~random.choice(customlist)

slate swan
#

Not quite

full valley
#

How do I find the guild id without using ctx

#

if its not in a function

slate swan
#

No need for .format if the list doesnt have a int

winter moth
#

im using replit. would i have to create the random file or will it pull it automatically

slate swan
full valley
#

Would this work:

def getserverid(ctx):
   gid = ctx.guild.id
   return gid

guildset = settings.find_one({"guild_id": getserverid()})
qsize = guildset["qsize"]
winter moth
slate swan
# winter moth

Yeah but change the name so it wont be the same as the message object

winter moth
#

so variable would work since its nowhere else in the file

slate swan
winter moth
#

new bug is now its now repeat messaging

slate swan
winter moth
#

import discord
import os
import requests
import random
from keep_alive import keep_alive

client = discord.Client()
list = [
"'Oi! Look at this loser here!'"
"'YOU DAFT PRAT'"
"'Better luck next time… NOT!'"
]
@client.event
async def on_ready():
print('You have logged in as {0.user}'.format(client))

called whether there is a message in the chat

@client.event
async def on_message(message):
if message.content == 'scar calico hoodie wink':
await message.channel.send('You cracked the code🔥 Only the first one to get this wins.')

else:
await message.channel.send({random.choice(list)})

keep_alive()
client.run(os.getenv('token'))

maiden fable
#

Ah

#

Add another line

slate swan
maiden fable
#
if message.author == client.user:
    return
winter moth
#

yeah i just caught the commas

slate swan
maiden fable
#

(:

slate swan
#

Doesn't really matter but its better

maiden fable
#

He should add that inside the on_message...

slate swan
maiden fable
#

.....?

slate swan
#

Nothingyert

winter moth
#

do that below the @client.event

slate swan
#

Below:
async def test(ctx):

winter moth
slate swan
winter moth
#

did it

slate swan
#
@client.event
async def on_message(message):
          if message.author == client.user:
                  return 
winter moth
#

besides the {} printing in the messages which isnt a thing this is perfect

brittle ingot
#

Are you accessing a list? cause all you need to do is just index that list

slate swan
#

^

#

So that all bots get ignored

brittle ingot
#

that would be ideal. Unless you're like me and make a bot that commands another bot 😂

winter moth
#

its in a channel that only members with a certain role can access and bots are denied access

maiden fable
full valley
#

Hi guys how can I access the guild id of the server without having typed a message?

brittle ingot
#

can you show your code?

maiden fable
brittle ingot
#

I kinda wish all that was camel cased like in JS

full valley
#
#Global variables
x = settings.find_one({"guild_id": ctx.guild.id})
qsize = x["qsize"]
playerqueue = []
lobby = []
games = {}
allowed_channels = [892691480228020235]
allowed_sizes = [2,4,6,8]

#!qsize command -> Changes the guild prefix
@bot.command(name="qsize", description="Change the queue size")
async def qsize(ctx, size):
    if ctx.channel.id in allowed_channels:
        if size in allowed_sizes:
            settings.update_one({"guild_id": ctx.guild.id}, { "$set": { 'qsizq': size } })
            embed = discord.Embed(description=f"The queue size has been update to {size}", color=0xE74C3C)
            embed.set_footer(text="CBell 6 Mans | Created by Heptix", icon_url="https://i.imgur.com/1utxX7d.png")
        else:
            embed = discord.Embed(description=f"Please use a valid size (2,4,6,8)", color=0xE74C3C)
            embed.set_footer(text="CBell 6 Mans | Created by Heptix", icon_url="https://i.imgur.com/1utxX7d.png")
        await ctx.channel.send(embed=embed)
winter moth
#

after message author bot. how would you deny the printing of a message

brittle ingot
#
if message.author.bot:
    return

if you do that you can remove the two lines above it.

full valley
#

So I want q size to =

x = settings.find_one({"guild_id": ctx.guild.id})
qsize = x["qsize"]
#

but I cant just get the guild id

brittle ingot
#

It looks like something with your query because in a command, ctx.guild.id does work.

full valley
#

yeahh but its not in a command

winter moth
#

@brittle ingot @slate swan @slate swan Thank you Thank You Thank YOu for all the help

brittle ingot
#

oh i see

full valley
#

yeah u get what I mean

brittle ingot
#

i was looking further down. In that case i would make it a standalone function with a guild parameter. That way you can call it in your bot command.

slate swan
# winter moth

use

if message.author == client.user or message.author.bot:
  return
brittle ingot
#

something like updateQueue?

full valley
tiny ibex
#

Hey NVM me interrupting but can I DM you
@brittle ingot

brittle ingot
#

a bot.command is a function just that its assigned a decorator so the code knows its a command. something like:

async def getQueue(self, guild):
    x = settings.find_one({"guild_id": guild.id})
    return x["qsize"]
tiny ibex
#

I just wanted to ask bout your guardian system

brittle ingot
cobalt jacinth
#

any way to trigger the discord bot when data from webhook arrives ?

tiny ibex
full valley
brittle ingot
#

who said it was an int?

boreal ravine
#

ig ur using ctx then

#

😌

brittle ingot
#

a webhook event?

brittle ingot
#

ur right,

#

good catch

full valley
#

Yeah but can I use that if qsize is a global variable?

brittle ingot
#

is it more than one server?

#

otherwise you will need to get the guild from the cache?

full valley
#

Not, but ive set it up so it can be

brittle ingot
#

So if you want it to be more than one guild, even if you only want one guild. This code isn't self updating as a global variable:

x = settings.find_one({"guild_id": ctx.guild.id})
qsize = x["qsize"]

As i understand it this is your way to change the guild prefix? You will want a way to fetch the updated list. Which would require some sort of function as far as i can see. I could be wrong though

#

also here, qsize is spelled wrong, dk if that is intended or not.

settings.update_one({"guild_id": ctx.guild.id}, { "$set": { 'qsizq': size } })
full valley
#

but yeah that was a typo, it is 'qsize'...

brittle ingot
#

So if you store it in your mongo Db you can access it everytime you want without much consequence just like you would with a local DB.

full valley
#
x = settings.find_one({"guild_id": ctx.guild.id})
qsize = x["qsize"]
``` is finding the qsize variable in my mongo db
brittle ingot
#

ok i think i understand now. So that is finding the current variable to be used throughout your code? If this is the case i would stick to my original recommendation where you have a function that gets called when you want that qsize. That way you are always getting the most recent version of the qsize.

#

so as example, function would be:

async def getQsize(guild):
   x = settings.find_one({"guild_id": guild.id})
  return x["qsize"]

Then to access it you would call the function for instance in a command:

@bot.command()
async def qSize(ctx):
    qsize = await getQsize(ctx.guild)
    await ctx.send(f"Current qsize is: {qsize}")
meager chasm
#

getQsize doesn't need to be async ^

brittle ingot
#

true

full valley
#

You can see I use the qsize variable in my queue command

#

e.g. if len(lobby) == qsize

#

So im really just trying to update the global variable here with whatever value qsize has in the data base

brittle ingot
#

if you are fetching the settings again, cant you just get the qsize from that? with qsize = ggid["qsize"] or is that a different collection

full valley
#

Yeah I guess you are right same collection

#

so I just define q size in the command function

#

instead of global

brittle ingot
#

yeah if you are get the setting within the command function you can do it right after you get the settings.

#

plus i wouldn't advise creating many global variables as it gets confusing.

full valley
#

right so:

#!q command -> Puts players into queue
@bot.command(name="queue", aliases=["q"], description="Join the queue")
async def queue(ctx):
    if ctx.channel.id in allowed_channels:
        ggid = settings.find_one({"guild_id": ctx.guild.id})
        game_id = ggid["game_id"]
        qsize = ggid["qsize"]
        pid = ctx.author.id
        pmention = ctx.author.mention
        if pmention in playerqueue:
            embed = discord.Embed(
              ...
brittle ingot
#

looks good to me

full valley
#

I was trying to over complicate it..

#

cheers

brittle ingot
#

I get what you were trying to do and it was right for a more complex application but i think for this i don't think so 😄 good luck

full valley
#

ty!

woeful thunder
#

Hello guys, maybe anyone know or there is a bot who can moderate the channel? i have problem always someone hacks my admin/mod acc and kicks all members. I want to add bot for example if person kicks or bans 10 players in a row it auto bans him.

tiny ibex
#

Preety simple IG

cloud dawn
tiny ibex
cloud dawn
#

Yeah lol accounts don't just get hacked.

slate swan
cloud dawn
tiny ibex
slate swan
#

Depends

tiny ibex
cloud dawn
full valley
tiny ibex
slate swan
cloud dawn
#

That or get more trustworthy mods/admins.

slate swan
#

Yes^

#

Or get a better password

tiny ibex
full valley
#

and make sure they have 2fa

tiny ibex
#

Get lastpass today

slate swan
tiny ibex
#

No adverstising

tiny ibex
#

Simple

slate swan
woeful thunder
#

@cloud dawn no there is some hackers who steal discord dev tokens, they even bypass 2ffa.

tiny ibex
#

Or pass the ownership to bot

woeful thunder
#

they steal everything even chrome cookies 😄

tiny ibex
cloud dawn
slate swan
#

^

#

Always the sketchy people

tiny ibex
#

Don't you guys think it's not a coding related issue?

woeful thunder
#

i dont run, i talking about my staff members, i never been hacked. but there is some reg ppl who get hacked always.

tiny ibex
#

Simple

#

¯_(ツ)_/¯

slate swan
cloud dawn
#

If someone doesn't know what applications are faulty and get easily tricked i'd recommend that aswell.

slate swan
#

If your staff wouldn't go to robux.free.generator you would be fine🤷‍♂️

cloud dawn
tiny ibex
tiny ibex
#

jk
jk
jk

woeful thunder
#

idk 2 times my discord got hacked first time all members banned, now i got ppl back and again all members kicked. moderator did that.

slate swan
#

The lesson is to never download a random exe. File you see on the internetyert

cloud dawn
#

I haven't had a anti-virus in over 4 years, even forced de-activated windows defender. Never had a virus or malware. Sometimes ran a scan then uninstalled it again- no result.

slate swan
cloud dawn
slate swan
tiny ibex
cloud dawn
#

Yep lol

slate swan
#

Or just make yourself a osbrainmon

tiny ibex
cloud dawn
winter moth
tiny ibex
tiny ibex
slate swan
winter moth
cloud dawn
#

Well have a good long password for thinks like google or other sensitive application. And remember: sentences are the best passwords.

tiny ibex
tiny ibex
cloud dawn
slate swan
#

Like:
Yourmomismygf

tiny ibex
cloud dawn
tiny ibex
tiny ibex
cloud dawn
#

I don't really want any 3th party password manager to have all my passwords.

slate swan
tiny ibex
slate swan
tiny ibex
cloud dawn
#

Nothing is more secure than your own brain.

tiny ibex
tiny ibex
slate swan
woeful thunder
#

Noone answered my question or there is a bot to manage moderators, for example if moderator kicks 10 players or 10 it gets auto ban.

tiny ibex
#

But you ignored

slate swan
#

Lots of mod bots

#

That have good security and varity

tiny ibex
slate swan
cloud dawn
tiny ibex
cloud dawn
#

It's pretty easy though when using on_command_succes

tiny ibex
#

Making an anti nuke bot is not really hard

cloud dawn
#

Agreed.

tiny ibex
#

And a nuke bot is even easierbrainmon

#

lol

slate swan
#

Or just be responsible and remove that staff member and moderate your own serverbrainmon

slate swan
cloud dawn
tiny ibex
slate swan
tiny ibex
slate swan
tiny ibex
#

Why would I make something like that

cloud dawn
slate swan
cloud dawn
tiny ibex
#

Selfbots are interesting tho

slate swan
tiny ibex
#

Nuke bot is shit

tiny ibex
cloud dawn
#

selfbots are pretty nice, but some people ruined it for everyone by abusing the API and ruining servers.

tiny ibex
#

I swear I never made a nuke bot

tiny ibex
#

With more rate limiting maybe

slate swan
tiny ibex
cloud dawn
slate swan
#

Yes

tiny ibex
cloud dawn
#

"like us"?

slate swan
tiny ibex
#

and my friends

slate swan
tiny ibex
#

I made selfbots earlier but now they are boring

slate swan
tiny ibex
#

Cuz my friend got banned💀

tiny ibex
slate swan
tiny ibex
#

...........

#

Imma kill you Okimii

slate swan
cloud dawn
#

I always follow Discord ToS, i don't see a reason to break it. If you want to listen to music with friends use Spotify and what would you ever want to automate on your Discord account?

tiny ibex
slate swan
#

Wasnt me

tiny ibex
slate swan
#

Whos that

tiny ibex
slate swan
tiny ibex
cloud dawn
#

Are we still talking about something Discord related..?

slate swan
#

maybe

#

MAYBE NOT

tiny ibex
#

To spam my gfbrainmon

cloud dawn
tiny ibex
slate swan
cloud dawn
tiny ibex
maiden fable
#

Is this a discussion related to Discord Bots........? Doesn't seem like one to me

slate swan
#

I love discord bots

tiny ibex
#

It's a discussion about Discord selfbots

maiden fable
#

:tos:

tiny ibex
tiny ibex
slate swan
cloud dawn
#

The only way to convince Discord if you'd build your own Discord selfbot gf AI

tiny ibex
tiny ibex
#

WTH does that actually mean
Discord selfbot gf AI

slate swan
#

Do it youll become a billionaire like bill gates

cloud dawn
#

At this point just hire a gf on fiverr

tiny ibex
slate swan
#

🤷‍♂️

#

Jk

tiny ibex
slate swan
#

||or am i||

cloud dawn
slate swan
slate swan
slate swan
maiden fable
#

pithink there are ot channels FYI

tiny ibex
#

okimii is smarT

slate swan
#

Ofc i do i work for bill gatesbrainmon

#

perhaps we could keep this chat dedicated to the name of this channel.

slate swan
#

is it possible to track usage by a specific user without checking it in every million event

#

Back to topic now

tiny ibex
#

goes to my gf

slate swan
#

anything a user does

#

send a message, react to one, delete etc

cloud dawn
#

Well no you'd prob need like 6 to 8 events to do that

#

prob even more.

#

Why though..?

slate swan
#

You wanna stalk them bro?

#

i want to stalk myself PES_Rage

slate swan
#

im giving account access to a friend so we can stream a video using this accounts nitro and his network speed EE_sigh
dont ask why

#

So basically you want to track all inputs of a user?

#

correct.

#

Well idk😔

cloud dawn
#

But you're seeing his screen..?

#

I just recommend not doing it, only if you really trust this friend...

slate swan
#

Yeah

#

Better for everything

cloud dawn
#

You would be server restricted anyways, he can just DM or hop to another server.

tiny ibex
#

You can do it using selfbots tho

#

But they are against ToS

cloud dawn
#

So it's best to just not bring it up.

tiny ibex
slate swan
tiny ibex
slate swan
#

If your trying to see everything your discord account is doing i dont think its possible

slate swan
cloud dawn
tiny ibex
tiny ibex
slate swan
cloud dawn
#

When talking about a package when not referred we're always talking about the stable version.

slate swan
tiny ibex
slate swan
tiny ibex
slate swan
#

not really

slate swan
#

guild members

#

they won't be in cache

#

you'd have to use an alternative lib

tiny ibex
slate swan
#

yeah

tiny ibex
slate swan
#

depends

#

on what you're trying to do

cloud dawn
#

Most people self bot for their status

tiny ibex
#

I don't think many people use selfbots to get roleinfo lol

tiny ibex
slate swan
#

guild related information is pretty useful

tiny ibex
slate swan
#

i made a welcome command but it sends the message when users join a different server with the bot too, how can i fix it?

slate swan
slate swan
opaque trail
slate swan
#

any1 know how to add quotation marks in text

opaque trail
#
'xxx "xx" xxx'
"xxx \"xx\" xxx"
#

either one will work

slate swan
#

@cloud dawn have you seen such a chat before

slate swan
slate swan
cold sand
#

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

@bot.event
async def on_ready():
   print('We have logged in as {0.user}'.format(bot))

class SomeCommands(commands.Cog):
    #A couple of simple command
   def __init__(self, bot: commands.Bot):
      self.bot = bot

   @commands.command(name="ping")
   async def ping(self, ctx: commands.Context):
         #Get the bot's current websocket latency.
         await ctx.send(f"Pong! {round(self.bot.latency * 1000)}ms")

   def setup(bot: commands.Bot):
      bot.add_cog(SomeCommands(bot))
#

this command seem not be running when I try the command on my Discord server

slate swan
#

ok im back

#

sorry i was gone for the day had to do family things

#

ok one i am really dumb plus i have not use python in years so imma need some one to lead me though this

#

im trying to get my bot to dm people with a certain roles

#

like dm everyone with that role

slate swan
#

Get the role with Guild.get_role() (if you have ID, otherwise use discord.utils.get()) then get the list of members that have this role with Role.members then send a message to them by looping through the list and use Member.send()

slate swan
#

how do i hide my discord bot token on repl?

slate swan
#

.env*

slate swan
dusk dust
#

how can I make a form command to join the staff? Like: the person writes /apply and the bot sends the questionnaire... is it possible?

slate swan
#

Use wait_for

#

So that you can wait for user response as normal message

#

User: /apply
Bot: What's your name?
User: xxxxx
Bot can do anything with the xxxxx response, such as saving or other things

dusk dust
slate swan
#

You can with any number of questions

dusk dust
pine lava
#

can i check if something errors? or would it return none? eg a string converted into an int

slate swan
#

try/except

pine lava
#

k ty

hollow agate
#
@client.command()
async def warn(ctx, member: discord.Member = None, *, reason=None):
    if ctx.author idk :P``` How can I check if the person using the command has admin permissions?
dusk dust
hollow agate
#

I can't use that in this instance, sadly. It needs to be an if check.

slate swan
#

.guild_permissions.administrator

#

Returns a boolean whether or not the user has the permission

hollow agate
#

Thank you!

unkempt canyonBOT
#

Hey @slate swan! I noticed you posted a seemingly valid Discord API token in your message and have removed your message. This means that your token has been compromised. Please change your token immediately at: https://discordapp.com/developers/applications/me

Feel free to re-post it with the token removed. If you believe this was a mistake, please let us know!

slate swan
#
import discord
from discord.ext import commands

bot = commands.Bot(commands_prefix='o!')

@bot.command()
async def yur(ctx):
    await ctx.reply('yesirrrr')

bot.run('Token')
#

like bro why it aint working

#

been like this for days

#

command_prefix, not commands_prefix

#

you telling me it was that simple😢

#

Yup

#

thank you

#

No problem

slate swan
#
                    cursor.execute(f"SELECT channel_id FROM ticketdozamykania WHERE message_id = {x[0]}")
                    wynik4 = cursor.fetchall()
                    TicketChannel = self.client.get_channel(wynik4[0])
                    print("3")
                    await TicketChannel.delete()
                    await member.send("Usunoles ticketa")

TicketChannel has not attribute delete

#

When i send
channel.send()
to an channel with slowmode enabled the code freezes? is this normal behavior? it doesnt ever cause an error it just freezes.

#
 for i in x:
        channel = bot.get_channel(i)
        await channel.send(advert)     
        await asyncio.sleep(3)
slate swan
#

@normal folio ask for help

normal folio
#

SyntaxError: 'await' outside function

slate swan
#

If he removes await

#

Then there's another error

#

Yes we both commit dev

#

Because you can't execute async code outside of an async function

#

As simple as thay

#

await needs to be used within an async function

#

My brain committed die

normal folio
#

my brain commited
100iq-100iq

slate swan
#
await do_stuff() # not good

async def my_func():
    await do_stuff() # good
slate swan
#

Ehat

pliant gulch
#

You forgot an indent in your example

slate swan
#

No

pliant gulch
#

What

slate swan
#

Or what

pliant gulch
#

OH my discord was bugged had to refresh

slate swan
normal folio
#

cuz my brain didn't understand

slate swan
#

Same

#

Yeah that won't work

#

We have stupid in our brain

#

Also

regal shell
#

Are cogs worth it?

slate swan
#

Kinda

#

If u wanna sort stuff

#

Or smth

regal shell
#

I like organized but are they worth all the hassle

slate swan
#

Not that complicated

#

So yes it's worth to use them

regal shell
#

Alright

#

Thanks

slate swan
#

But that reaction = is in async def shop

#

So how it can be error

normal folio
#

it no edit :sad:

#

bot good but no do anythin

slate swan
#

Ok imma go help u whatever

normal folio
regal shell
#

Can someone help me with cogs or send a link or sum

brittle ingot
#

Also i would recommend adding some check and timeout as that will wait forever and listen to ANY message the reactions are used on given the message is still cached if i remember correctly.

brittle ingot
#

a check?

slate swan
brittle ingot
#

wait_for has a timeout

#

you just do timeout = seconds

slate swan
#

Ah i see ty

brittle ingot
#
reaction, user = await self.bot.wait_for("reaction_add", check = yourcheckFunction, timeout= timeoutInSeconds)
brittle ingot
#

np

hollow agate
#
@client.command()
@commands.has_permissions(administrator=True)
async def whitelistadd(ctx, ):``` what's the best way of putting a Guild ID in the kwarg?
brittle ingot
#

you want someone to input an id? you can just add guildId: int. and call that in your function.

#

there we go, didn't fully read at first, sorry.

hollow agate
brittle ingot
#

that i don't know. if you can hang on a sec i can try to find an answer for ya

hollow agate
#

Thank you, I really appreciate it!

brittle ingot
#

I can't find anything i think would answer the question. The only thing i can think of is actually fetching the guild from discord's API with an API call (would return a partial guild i believe) and checking if anything was returned from discord. so essentially if a partialGuild object was returned you know its an actual guild snowflake otherwise it may not be? i haven't tested this so take it with a grain of salt, its just a best guess.

hollow agate
#

I see, thank you!

brittle ingot
#

np, good luck.

kindred epoch
#

is there a way i can set a link as an emoji in an embed?

brittle ingot
#

like a hyperlink but the text is an emoji?

#

i mean i don't see why not.

kindred epoch
#

no

#

convert a link to an embed inside an embed

brittle ingot
#

uh no i don't believe so. Unless you are linking to an embed message that is already sent.

kindred epoch
#

ok

regal shell
#

Ok so I made a cog but why did it make a pycashe folder and put my cog file in it?

#

Oh wait it made a sub folder inside the cog folder

#

Is that good or bad?