import discord
import asyncio
import datetime
# import requests
# import json
import pyowm
import random
from pyowm import OWM
from pyowm.utils import config
from pyowm.utils import timestamps
from discord.ext import commands
owm = OWM('e25bc8f**88888888')
mgr = owm.weather_manager()
# api_key = 'e25bc8f098a***************'
# command_prefix = '!w'
client = commands.Bot(command_prefix = '!', self_bot = False)
client.remove_command('help')
@client.command()
async def w(ctx, *, region):
observation = mgr.weather_at_place(region)
w = observation.get_weather()
print(w)
temp = w.temperature('celsius')["temp"]
cloud = w.detailed_status
rain = w.rain
window = w.wind()["speed"]
emb = discord.Embed(title = f'**Погода в {region}**', colour = discord.Color.purple())
emb.add_field(name = f'Погода: {cloud}\nТемпература: {temp}\nДождь: {rain}\nВетер: {window}',value = f'Вот такая погода в {region} на сегодняшний день')
await ctx.send(embed=emb)
@commands.command(aliases = ["hel","Информация"])
@commands.cooldown(1, 60, commands.BucketType.user)
async def help(self, ctx):
await ctx.channel.purge(limit = 1)
emb = discord.Embed (title = 'Навигация по командам :clipboard:', colour = discord.Color.gold())
emb.add_field(name ='Описание сервера :pencil:', value = 'Rojers Squad, правила можно прочитать в канале #правила')
emb.add_field(name ='{}clear :broom:'.format(PREFIX), value = 'Очистка чата')
emb.add_field(name ='{}voteban :lock:'.format(PREFIX), value = 'Бан участника')
emb.add_field(name ='{}kick :wave:'.format(PREFIX), value = 'Кик с сервера')
emb.add_field(name ='{}unban :unlock:'.format(PREFIX), value = 'Разбан участника')
emb.add_field(name ='{}tempmute :mute:'.format(PREFIX), value = 'Мут участника')
emb.add_field(name ='{}unmute :speaker:'.format(PREFIX), value = 'Размут участника')
emb.add_field(name ='{}ds :rose:'.format(PREFIX), value = 'Ссылка на наш дс')
emb.add_field(name ='{}slot '.format(PREFIX), value = 'Игра для развлечения')
await ctx.send (embed = emb, delete_after=30)
emb = discord.Embed (title = 'Пинг: {0} ms'.format(client.latency * 1000), colour = discord.Color.gold())
emb = discord.Embed (title = 'Пинг: {0} ms'.format(self.client.latency * 1000), colour = discord.Color.gold())
@client.command(pass_context = True)
@commands.has_any_role(819292703589269514,817408828500213860,817408830240456754,817643991331766283)
async def clear (ctx, amount : int):
if amount > 100:
await ctx.channel.purge(limit = amount + 1)
emb = discord.Embed (title = 'Укажите число меньше 100'colour = discord.Color.gold())
await ctx.send(embed = emb, delete_after=30)
return
if amount < 100:
await ctx.channel.purge(limit = amount + 1)
emb = discord.Embed (title = 'Удалено {} сообщений!'.format(amount), colour = discord.Color.gold())
await ctx.send(embed = emb, delete_after=30)
@client.command(pass_context = True)
@commands.has_any_role(819292703589269514,817408828500213860,817408830240456754,817643991331766283)
async def clear (ctx, amount : int):
if amount > 100:
await ctx.channel.purge(limit = amount + 1)
emb = discord.Embed (title = 'Удалено {} сообщений!'.format(amount), colour = discord.Color.gold())
await ctx.send(embed = emb, delete_after=30)