This repository has been archived by the owner on Feb 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
global_methods.py
76 lines (58 loc) · 2.62 KB
/
global_methods.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import asyncio
import discord
#### PERMISSION ####
def is_admin(member) :
return member.server_permissions.administrator
#### SAY CHANNELS ####
async def say_gambling(ctx, msg, bot):
server = ctx.message.server
channel = await find_or_create_text_channel('gambling', server, bot)
await bot.send_message(channel, msg)
async def say_general(ctx, msg, bot):
server = ctx.message.server
channel = await find_or_create_text_channel('general', server, bot)
await bot.send_message(channel, msg)
async def say_other(ctx, msg, bot):
server = ctx.message.server
channel = await find_or_create_text_channel('other', server, bot)
await send_message(channel, msg, bot)
#await bot.send_message(channel, msg)
async def say_music(ctx, msg, bot):
server = ctx.message.server
channel = await find_or_create_text_channel('music', server, bot)
await bot.send_message(channel, msg)
async def say_tax(ctx, msg, bot):
server = ctx.message.server
channel = await find_or_create_text_channel('tax', server, bot)
await bot.send_message(channel, msg, bot)
async def send_message(channel, msg, bot):
embed = discord.Embed()
embed.title = "Buffbot"
embed.description = msg
embed.color = discord.Color.blue()
await bot.send_message(channel, "", embed=embed)
async def music_playing(player, bot, server) :
embed = discord.Embed()
m, s = divmod(player.duration, 60)
embed.title = "Music"
embed.add_field(name="Song name", value=player.title, inline=True)
embed.add_field(name="Duration", value=str("{}:{}".format(m, s)), inline=True)
embed.add_field(name="Likes/dislike", value=str(player.likes)+"/"+str(player.dislikes), inline=True)
embed.add_field(name="Views", value=str(player.views))
embed.description = "Now playing.. "
embed.add_field(name="Please add your own music", value="Do !queue <link to song> to queue up a song!")
embed.color = discord.Color.dark_green()
channel = await find_or_create_text_channel("music", server, bot)
await bot.send_message(channel, "", embed=embed)
async def find_or_create_text_channel(name, server, bot) :
channels = server.channels
for channel in channels:
if str(channel.type) == 'text' and channel.name == name :
return channel
return await bot.create_channel(name=name, server=server, type='text')
async def find_or_create_voice_channel(name, server, bot):
channels = server.channels
for channel in channels:
if str(channel.type) == 'voice' and channel.name == name:
return channel
return await bot.create_channel(name=name, server=server, type='text')