discord code

discord code

Liksa
Начнем с простого как создается бот ?
Отличная инструкция тут
https://appmaster.io/ru/blog/bot-discord-kak-sozdat-i-dobavit-na-server



Prefix - Это кличка бота , т.е после написание спец символа будет выпонляться та программа, которую вы запрограммировали


import discord
from discord.ext import commands

config = {
    'token' : 'MTAyOTcwMDU2OTU0MTEyNDA5Ng.GC2Hpz.g-O167GAIK89k_Yh41qbicxuo72udPCwJXja9c',
    'prefix': '!',
}
intents = discord.Intents.all()
bot = commands.Bot(command_prefix=config['prefix'], intents=intents)

@bot.event
async def on_ready():
    game = discord.Game('moderating')
    await bot.change_presence(status=discord.Status.online, activity=game)

@bot.command(name="привет")
async def hi(ctx):
    author = ctx.message.author
    await ctx.send(f'Привет воин {author.mention}!')

@bot.command(name='поговори')
async def testpg(ctx):
    await ctx.channel.send("Поговорил ;/")

import datetime
@bot.event
async def on_member_join(member):
    now = datetime.datetime.now()
    embed = discord.Embed(
        title="Добро пожаловть на сервер 'Бродяг'",
        description = '',
        color = 0x0000FF
    )
    embed.set_author(name=f'{member.name}#{member.discriminator}')
    embed.set_footer(text=f"Ваш ID:{member.id} ^ {now.hour}:{now.minute}")
    await member.send(embed=embed)
    chanel = bot.get_channel(1073904517822808067)
    await chanel.send(embed=embed)
@bot.command(name='send')
async def send(ctx, chanel: discord.TextChannel, *,message):
    await chanel.send(message)
@bot.command(name='ban')
@commands.has_permissions(administrator=True)
async def ban(ctx, member: discord.Member, *, reason=None):
    await member.ban(reason=reason)
    embed = discord.Embed(color=0xEC2CD,
                          title="Ban",
    description=f'Был забанен  и изгнан{member.mention}')
    embed.set_footer(text=ctx.author.name)
    embed.set_author(name=bot.user.name)
    await ctx.send(embed=embed)

bot.run(config['token'])




Report Page