Created
July 1, 2022 03:29
-
-
Save AlgorithmAlchemy/5ada556c2b3226d654357648f3d96908 to your computer and use it in GitHub Desktop.
discord_little_temka
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import discord | |
from discord.ext import commands | |
intents = discord.Intents.all() | |
client = commands.Bot(command_prefix='.', intents=intents) | |
client.remove_command('help') | |
# Words | |
hello_words = ['hello', 'hi', 'привет', 'privet', 'kу', 'ку', 'здарова'] | |
answer_words = ['узнать информацию о сервере', 'какая информация', 'команды', 'команды сервера', 'что здесь делать'] | |
goodbye_words = ['пока', 'bb', 'poka', 'bb all', 'пока всем', 'удачи всем', 'удачи'] | |
guild_welcome = {643867541189558303} # Тут ID канала, в которые приходит сообщение и приветствие | |
# В Cogs команды имеют свой собственный способ определения, который использует commands.command()декоратор. | |
# Он выполняет ту же функцию, что и bot.command(), однако теперь работает и в Cogs: | |
class SomeCommands(commands.Cog): | |
"""A couple of simple commands.""" | |
def __init__(self, bot: commands.Bot): | |
self.bot = bot | |
self.last_msg = None | |
@commands.command(pass_context=True) | |
@commands.has_permissions(administrator=True) # если есть права админа можем удалять сообщения | |
async def clear(self, ctx, amount=100): | |
"""Delete message""" | |
await ctx.channel.purge(limit=amount) | |
@commands.command(pass_context=True) | |
async def hello(self, ctx, arg): | |
author = ctx.message.author | |
await ctx.send(f' {author.mention} ' + arg) | |
class Events(commands.Cog): | |
def __init__(self, bot): | |
self.bot = bot | |
@commands.Cog.listener() | |
async def on_ready(self): | |
print('Ready!') | |
print('Logged in as ---->', self.bot.user) | |
print('ID:', self.bot.user.id) | |
print("--------------") | |
print("<by kaktys>") | |
@commands.Cog.listener() | |
async def on_message(self, message): | |
msg = message.content.lower() | |
if msg in hello_words: | |
await message.channel.send('Прив, что хотел?') | |
if msg in answer_words: | |
await message.channel.send('Пропиши в чат команду .help, и всё узнаешь!') | |
if msg in goodbye_words: | |
await message.channel.send('Пока, удачи тебе!') | |
@commands.Cog.listener() | |
async def on_member_join(self, member): | |
channelsadg = client.get_channel(919767333243867156) # Where ID is your welcome channel's ID | |
# await channelsadg.send(f'Привет, {member}! Ты попал в канал {member.guild.name}. Чтобы узнать мои команды | |
# пропиши /help') | |
embed = discord.Embed(title="Добро пожаловать!", | |
description=f"**Привет** __{member}__ **ты приехал в** __{member.guild.name}__!" | |
f"\n**Советую ознакомится с** ┣•[Правила](https://discord.com/channels/" | |
f"643867541189558297/643867541189558303)🍊" | |
f"\n**Приятного тебе общения : )**", color=0xCC974F) # Embed | |
await channelsadg.send(embed=embed) # Отправка сообщения | |
# Добавляем все cogs сюда. Другие созданные классы | |
def setup(bot: commands.Bot): | |
client.add_cog(SomeCommands(bot)) | |
bot.add_cog(Events(bot)) | |
client.run("TOOKKKKKKKKEEEEEEEEEEN") | |
setup(client) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment