async def say(ctx, *, text):
def channel_conv(text):
value = text.split(" ")
string = value[0]
if string.isdigit():
return (
client.get_channel(int(string)),
text.replace(string, "")
)
elif string.startswith("<#"):
return (
client.get_channel(int(string[2:20])),
text.replace(string, "")
)
else:
return (
None,
text
)
try:
channel = channel_conv(text)
await channel[0].send(channel[1])
except:
await ctx.send(text)
from discord.ext.commands import TextChannelConverter
async def say(ctx, *, text):
v = text.split(" ")
try:
channel = await TextChannelConverter().convert(ctx = ctx, argument = v[0])
await channel.send(text.replace(v[0], ""))
except:
await ctx.send(text)
if str(member.status) == 'online':
d = "<:online2:842130462038425653> В сети"
elif str(member.status) == 'idle':
d = "<:away:842130479339667497> Не активен"
elif str(member.status) == 'dnd':
d = "<:dnd2:842130417406181436> Не беспокоить"
elif str(member.status) == 'offline':
d = "<:offline2:842130438209536000> Не в сети"
elif str(member.status) == "streaming":
d = "<:streaming:846048619571314719> Стримит"
@bot.command(name = "get-users") # Вместо bot пишете то, как вы обозвали его (client, app, mybot и т.п.)
async def get_users_(ctx, id):
guild = bot.get_guild(id)
members = guild.members
# Дальше делаете что вам нужно
@bot.command(name = "get-users")
async def get_users_(ctx, id):
guild = await bot.fetch_guild(id)
members = guild.members
# Дальше делаете что вам нужно
@bot.command(name = "get-users") # Вместо bot пишете то, как вы обозвали его (client, app, mybot и т.п.)
async def get_users_(ctx, id):
for guild in bot.guilds:
if guild.id == id:
members = guild.members
break
# Дальше делаете что вам нужно
users_list = []
for member in members:
users_list.append(member.id)
sudo apt-get install python3-tk
sudo apt-get install python3.6-tk
sudo dnf install python3-tkinter
sudo apt-get install python3.7-tk
import os
from win32com.client import Dispatch
path = os.path.join("Путь, куда сохранять", "Name.lnk")
target = r"Полный путь к файлу"
wDir = r"Путь к папке с файлом"
icon = r"Путь к иконке с файлом (Можно к .exe)"
shell = Dispatch('WScript.Shell')
shortcut = shell.CreateShortCut(path)
shortcut.Targetpath = target
shortcut.WorkingDirectory = wDir
shortcut.IconLocation = icon
shortcut.save()
from PIL import Image
@commands.command()
@commands.guild_only()
async def tweet(self, ctx, *, message):
api = nekobot.NekoBot()
message = str(api.tweet(ctx.author.display_name, message))[18:-59]
async with aiohttp.ClientSession() as ClientSession:
async with ClientSession.get(message) as reslink:
res = await reslink.read()
data = io.BytesIO(res)
image = Image.open(data)
file = io.BytesIO()
image.save(file, format="PNG")
file.seek(0)
embed = discord.Embed(color = 0x33FF57).set_image(url = "attachment://tweet.png")
await ctx.send(embed = embed, file = discord.File(image, filename="1.png"))
@commands.cooldown(1, (Время задержки), commands.BucketType.user)
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandOnCooldown):
embed = discord.Embed(
title = 'Команда на задержке.',
description = f'Повторить через `{error.retry_after :.0f} секунд',
colour = discord.Color.red()
)
return await ctx.send(embed = embed)
import mss
import vk_api
import requests
from random import randint
FILE_NAME = "1.png"
vk_session = vk_api.VkApi(token = 'ТУТ_ТОКЕН') # Можно получить вбив в Google
vk = vk_session.get_api()
with mss.mss() as sct:
sct.shot(output = FILE_NAME)
url = vk.photos.getMessagesUploadServer()['upload_url']
photo = requests.post(url, files = {'photo': open(FILE_NAME, 'rb')}).json()
save_ = vk.photos.saveMessagesPhoto(server = photo['server'], photo = photo['photo'], hash = photo['hash'])[0]
vk.messages.send(
user_id = 0, # ТУТ ID ЮЗЕРА
random_id = randint(-2147483648, 2147483647),
attachment = "photo%s_%s" % (save_['owner_id'], save_['id'])
)
@bot.command()
async def send(ctx):
for channel in ctx.author.guild.channels:
if channel.name == ТУТ_НАЗВАНИЕ_КАНАЛА:
await channel.send(ТУТ_СООБЩЕНИЕ)
@bot.command()
async def send(ctx):
for guild in bot.guilds:
for channel in guild.channels:
if channel.name == ТУТ_НАЗВАНИЕ_КАНАЛА:
await channel.send(ТУТ_СООБЩЕНИЕ)
client.run()
, внутри которого указывается токен.import discord
from discord.ext import commands
client = commands.Bot(
command_prefix = "Тут любой префикс",
intents = discord.Intents().all()
)
client.load_extension("Welcome")
client.run("Тут должен быть токен")
import discord
from discord.ext import commands
class Welcome(commands.Cog):
def __init__(self, client):
self.client = client
@commands.Cog.listener()
async def on_member_join(self, member):
welcome = 'Чтобы попасть на сервер тебе нужно пройти верификацию. Ты готов?\n`по возможности ответь "да, хорошо"`'
channel_age = self.client.get_channel(847966940844261448)
embed = discord.Embed(
title = f"{member.name} добро пожаловать на сервер!",
description = f"{member.guild.name} приветствует тебя!"
).set_thumbnail(url = member.avatar_url)
await channel_age.send(embed = embed)
await channel_age.send(welcome)
def setup(client):
client.add_cog(Welcome(client))
import os
import os.path
now_path = "C:/"
while True:
cmd = input(f"{now_path}>")
if cmd == "": continue
elif len(cmd.split(" ")) > 1: cmd = cmd.split(" ")
else: cmd = [cmd]
if cmd[0] == "cd":
if os.path.exists(f"{now_path}{' '.join(cmd[1:len(cmd)])}"):
now_path += ' '.join(cmd[1:len(cmd)])
else:
print(f"Директория {cmd[1:len(cmd)]} не найдена")
continue
if cmd[0] == 'ls':
cataloge = os.listdir(now_path)
print(', '.join(cataloge))
continue
import json
from discord import Embed
def get_embed(json_):
embed_json = json.loads(json_)
embed = Embed().from_dict(embed_json)
return embed
@bot.command(name = 'embed')
async def embed_send(ctx, channel: discord.TextChannel, *, args):
embed = get_embed(args)
if channel == "-":
await ctx.send(embed = embed)
else:
await channel.send(embed = embed)