-
Notifications
You must be signed in to change notification settings - Fork 1
/
Setup.py
183 lines (133 loc) · 6.51 KB
/
Setup.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
import discord
import random
import asyncio
import youtube_dl
from discord.ext import commands, tasks
from discord.utils import get
from discord import FFmpegPCMAudio
from discord.ext.commands import Bot, has_permissions, CheckFailure
from itertools import cycle
from youtube_dl import YoutubeDL
import os
from dotenv import load_dotenv, find_dotenv
load_dotenv(find_dotenv())
KEY = os.environ.get("KEY")
MY_TOKEN_HERE = os.getenv('MY_TOKEN_HERE')
client = commands.Bot(command_prefix=']')
status = cycle(['NODES', 'MODULES', 'WAVES'])
mangalist = cycle(['Vinland saga', 'One piece',
'Fire force', 'Steel ball run'])
linklist = ['https://myanimelist.net/manga/642/Vinland_Saga', 'https://myanimelist.net/manga/13/One_Piece',
'https://myanimelist.net/manga/91037/Enen_no_Shouboutai?q=fire%20force&cat=manga', 'https://myanimelist.net/manga/1706/JoJo_no_Kimyou_na_Bouken_Part_7__Steel_Ball_Run']
# Initalizes the bot and gives it a status
@client.event
async def on_ready():
change_status.start()
print("Bot is online.")
# Backgrounds tasks for the Discord Bot ()
@tasks.loop(seconds=10)
async def change_status():
await client.change_presence(activity=discord.Game(next(status)))
# These commands load and Unload the cogs from ./cogs folder
@client.command()
async def load(ctx, extension):
client.load_extension(f'cogs.{extension}')
@client.command()
async def unload(ctx, extension):
client.unload_extension(f'cogs.{extension}')
@client.command()
async def reload(ctx, extension):
client.unload_extension(f'cogs.{extension}')
client.load_extension(f'cogs.{extension}')
# Searches for the python scripts in the directory and attaches a string to them
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
client.load_extension(f'cogs.{filename[:-3]}')
# When a Member Joins the server,
@client.event
async def on_memberjoin(member):
print(f'{member} has joined the server, Welcome!')
# When a Members Leaves the server,
@client.event
async def on_member_remove(member):
print(f'{member} has left the server, Goodbye.')
# Shows the ping of the bot
@client.command()
async def ping(ctx):
await ctx.send(f'Pong! `{round(client.latency * 1000)}ms`')
# Creates a 8ball minigame with a range of responses from the bot
@client.command(aliases=['8ball', 'eightball'])
async def _8ball(ctx, *, question):
responses = ['It is certain', 'It is decidedly so', 'Without a doubt', 'Yes – definitely', 'You may rely on it', 'As I see it, yes', 'Most likely', 'Outlook good', 'Yes Signs point to yes', 'Reply hazy',
'try again', 'Ask again later', 'Better not', 'Cannot predict now', 'Concentrate and ask again', 'Dont count on it', 'My reply is no', 'My sources say no', 'Outlook not so good', 'Very doubtful']
await ctx.send(f'Question: {question}\nAnswer: {random.choice(responses)}')
# Info Embed, used for displaying information
@client.command(aliases=['bot'])
async def info(message):
embedVar = discord.Embed(
title="🎇CodenBot", description="Developed by `Abraham/CodeProductions`, this simple bot was coded with discord.py. This bot is a multi-purpose bot used for administration and chat moderation.", color=0x8919cf)
embedVar.add_field(name="Documentation and Issues",
value="If you run into any issues, please go to the following github: \n https://github.com/Rezatachi", inline=False)
embedVar.set_thumbnail(
url="https://cdn.discordapp.com/attachments/761256129191477261/779902108920709141/Ten.jpg")
await message.channel.send(embed=embedVar)
# Creates an embed for how many commands there are
@client.command(aliases=['commands'])
async def ask(message):
embedHelp = discord.Embed(title="This Embed contains the list of commands for Coden.",
description="This bot uses the prefix `]`", color=0x8919cf)
embedHelp.add_field(name="Command and Intents", value="`commands` - displays the help embed displaying the various commands\n `info` - shows the bot information \n `clear` auto purges messages up to 10 \n `8ball` - fun minigame to test your luck\n `ban`- bans are member from the discord server\n `kick`- kicks a member from the server.\n `load` - loads extra commands from cogs \n `play` - playing music from youtube URL \n `leave` - bot leaves the voice channel \n `stop` - music stops playing \n `resume` - music resumes \n `pause` - music is paused. ")
embedHelp.set_thumbnail(
url="https://cdn.discordapp.com/attachments/761256129191477261/779902108920709141/Ten.jpg")
await message.channel.send(embed=embedHelp)
# Clear commands, wont work without numbers
@client.command()
async def clear(ctx, amount: int):
await ctx.channel.purge(limit=amount)
embedClear = discord.Embed(
title=f'**{amount} messages have been cleared!**')
botclear = await ctx.channel.send(embed=embedClear)
await asyncio.sleep(1)
await botclear.delete()
# Clear error displayed
@clear.error
async def clear_error(ctx, error):
if isinstance(error, commands.MissingRequiredArgument):
embedArguement = discord.Embed(
title="**Please specify the amount of messages to delete**!")
botembedArguement = await ctx.channel.send(embed=embedArguement)
await asyncio.sleep(1)
await botembedArguement.delete()
# Kick
@client.command()
@commands.has_permissions(kick_members=True)
async def kick(message, member: discord.Member, *, reason=None):
await member.kick(reason=reason)
embedVar2 = discord.Embed(title="**User kicked!**", color=0x8919cf)
botembed = await message.channel.send(embed=embedVar2)
await asyncio.sleep(2)
await botembed.delete()
# Ban
@client.command()
@commands.has_permissions(ban_members=True)
async def ban(message, member: discord.Member, *, reason=None):
await member.ban(reason=reason)
embedVar3 = discord.Embed(title="**User banned!**", color=0x8919cf)
botembedvar = await message.channel.send(embed=embedVar3)
await asyncio.sleep(3)
await botembedvar.delete()
@client.command()
async def github(ctx):
await ctx.send("https://github.com/Rezatachi")
@client.command()
async def linktree(ctx):
await ctx.send("https://linktr.ee/CodeProd")
@client.command()
async def reading(ctx):
embed = discord.Embed(
title=f"**Abe is currently reading {next(mangalist)}**")
embed.set_footer(text="by Makoto Yukimura")
embed.set_image(
url="https://images-na.ssl-images-amazon.com/images/I/91+Qs9DaFZL.jpg")
await ctx.send(embed=embed)
client.run(KEY)