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)
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)
@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 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)
for guild in Bot.guilds:
maincategory = discord.utils.get(guild.categories, id=848659633664032829)
@Bot.event
async def on_voice_state_update(member, before, after):
if after.channel != None:
if after.channel.id == 843730990408007698:
category = after.channel.category
channel2 = await member.guild.create_voice_channel(
name = f' || { member.display_name }',
category = category
)
await channel2.set_permissions(member, connect = True)
await member.move_to(channel2)
def check(x, y, z): return len(channel2.members) == 0
await Bot.wait_for('voice_state_update', check = check)
await channel2.delete()
import discord
import discord.utils
from discord.ext import commands
intents = discord.Intents(messages=True, guilds=True)
intents = discord.Intents.default()
intents.members = True
client = commands.Bot(command_prefix='!', intents=intents)
@client.event
async def on_ready():
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="#Общение"))
print("Bot is ready!")
@client.command()
async def admin(ctx):
member = ctx.author
role = discord.utils.get(member.guild.roles, id = 852691194433503232)
await member.add_roles(role)
import discord
client = discord.Client()
Matrix = "▢"
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
global Matrix
if message.content.startswith("#on"):
Matrixsend = Matrix.replace(Matrix[0], "▣")
Matrix = Matrixsend
await message.channel.send(''+str(Matrix))
if message.content.startswith("#off"):
Matrixsend = Matrix.replace(Matrix[0], "▢")
Matrix = Matrixsend
await message.channel.send(''+str(Matrix))
client.run("Тут могла быть ваша реклама")