-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
71 lines (54 loc) · 2.06 KB
/
main.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
import discord
from discord.ext import commands
from discord import Intents
from discord.ext.commands import Bot
import os
import random
from PIL import Image, ImageDraw, ImageSequence
import imagecreator
from secrets import BOT_TOKEN
from settings import Settings
gifs = os.listdir("gokugifs")
bot = commands.Bot(command_prefix='.',intents=Intents.default())
GuildSettings = {}
@bot.event
async def on_ready():
print("Logged In As")
print(bot.user.name)
print("------")
#await bot.tree.sync()
print(bot.user.id)
await bot.change_presence(
activity=discord.Activity(type=discord.ActivityType.watching, name="Nothing")
)
@bot.hybrid_command("rule")
async def rule(ctx , rule_number: int, *, rule_text: str):
settings = getGuildSettings(ctx.guild.id)
filename = imagecreator.writeText(Image.open("gokugifs/" + random.choice(gifs)), rule_number, rule_text,str(ctx.message.id),settings.getLanguage())
if settings.getRuleChannel() != None:
await bot.get_channel(settings.getRuleChannel()).send(file=discord.File(filename))
await ctx.send("Done!")
else:
await ctx.send(file=discord.File(filename))
os.remove(filename)
@commands.has_permissions(administrator=True)
@bot.hybrid_command("setrulechannel")
async def setrulechannel(ctx, channel: discord.TextChannel):
settings = getGuildSettings(ctx.guild.id)
settings.setRuleChannel(channel.id)
await ctx.send(f"Rule channel set to {channel.mention}")
def getGuildSettings(guildID):
if not guildID in GuildSettings:
GuildSettings[guildID] = Settings(guildID)
return GuildSettings[guildID]
languages = ["en","tr"]
@commands.has_permissions(administrator=True)
@bot.hybrid_command("setlanguage")
async def setlanguage(ctx, language: str):
if not language in languages:
await ctx.send("Language not supported! use one of these languages: " + ", ".join(languages))
return
settings = getGuildSettings(ctx.guild.id)
settings.setLanguage(language)
await ctx.send(f"Language set to {language}")
bot.run(BOT_TOKEN)