This repository was archived by the owner on Oct 20, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDUST.py
More file actions
249 lines (211 loc) · 12.1 KB
/
DUST.py
File metadata and controls
249 lines (211 loc) · 12.1 KB
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
# -*- coding: utf-8 -*-
#Auto Loop
import discord
from discord.ext import commands
from discord.utils import get
import sqlite3
import os
import random
import asyncio
TOKEN = ''
BOT_PREFIX = '.mj'
bot = commands.Bot(command_prefix=BOT_PREFIX)
DIR = os.path.dirname(__file__)
db = sqlite3.connect(os.path.join(DIR, "BankAccounts.db"))
SQL = db.cursor()
START_BALANCE = 10000
C_NAME = "DUST"
@bot.event
async def on_ready():
print("Logged in as: " + bot.user.name + "\n")
game = discord.Game(".mj도움말")
await bot.change_presence(status=discord.Status.online, activity=game)
@bot.command(pass_context=True, brief="유저의 지갑을 보여줍니다.")
async def 내지갑(ctx):
USER_ID = ctx.message.author.id
USER_NAME = str(ctx.message.author)
SQL.execute('create table if not exists Accounts("Num" integer primary key autoincrement,"user_name" text, "user_id" integer not null, "balance" real)')
SQL.execute(f'select user_id from Accounts where user_id="{USER_ID}"')
result_userID = SQL.fetchone()
if result_userID is None:
SQL.execute('insert into Accounts(user_name, user_id, balance) values(?,?,?)', (USER_NAME, USER_ID, START_BALANCE))
await ctx.send(f"{ctx.message.author.mention}님! {C_NAME}에 가입이 안되있으셔서 시작금액을 지급해드렸어요.")
db.commit()
return
SQL.execute(f'select balance from Accounts where user_id="{USER_ID}"')
result_userbal = SQL.fetchone()
SQL.execute(f'UPDATE Accounts set user_name = "{USER_NAME}" where user_id = "{USER_ID}"')
await ctx.send(f"{ctx.message.author.mention}님은 {result_userbal[0]} {C_NAME}가 있어요")
@bot.command(pass_context=True, brief="유저의 지갑을 보여줍니다.")
async def 지갑(ctx, user: discord.Member):
USER_ID = user.id
USER_NAME = str(user)
SQL.execute('create table if not exists Accounts("Num" integer primary key autoincrement,"user_name" text, "user_id" integer not null, "balance" real)')
SQL.execute(f'select user_id from Accounts where user_id="{USER_ID}"')
result_userID = SQL.fetchone()
if result_userID is None:
SQL.execute('insert into Accounts(user_name, user_id, balance) values(?,?,?)', (USER_NAME, USER_ID, START_BALANCE))
await ctx.send(f"<@{user.id}>님! {C_NAME}에 가입이 안되있으셔서 시작금액을 지급해드렸어요.")
db.commit()
return
SQL.execute(f'select balance from Accounts where user_id="{USER_ID}"')
result_userbal = SQL.fetchone()
SQL.execute(f'UPDATE Accounts set user_name = "{USER_NAME}" where user_id = "{USER_ID}"')
await ctx.send(f"<@{user.id}>님은 {result_userbal[0]} {C_NAME}가 있어요")
@bot.command(pass_context=True, brief="돈을 줍니다.")
async def 돈줘(ctx, amount: int):
if ctx.author.id == 380625576014381060:
USER_ID = ctx.message.author.id
USER_NAME = str(ctx.message.author)
SQL.execute('create table if not exists Accounts("Num" integer primary key autoincrement,"user_name" text, "user_id" integer not null, "balance" real)')
SQL.execute(f'select user_id from Accounts where user_id="{USER_ID}"')
result_userID = SQL.fetchone()
if result_userID is None:
SQL.execute('insert into Accounts(user_name, user_id, balance) values(?,?,?)', (USER_NAME, USER_ID, START_BALANCE))
await ctx.send(f"{ctx.message.author.mention}님! {C_NAME}에 가입이 안되있으셔서 시작금액을 지급해드렸어요.")
db.commit()
return
SQL.execute('update Accounts set balance = balance + ? where user_id = ?', (amount, USER_ID))
db.commit()
await ctx.send(f"{ctx.message.author.mention}님이 {amount} {C_NAME}를 받았습니다.")
else:
await ctx.send("당신은 권한이 없습니다!")
return
@bot.command(pass_context=True, brief="룰렛")
async def 배팅(ctx, amount: int):
randomNum = random.randrange(1, 3)
USER_ID = ctx.message.author.id
USER_NAME = str(ctx.message.author)
max_balance = 1000
SQL.execute(f'select balance from Accounts where user_id="{USER_ID}"')
result_userbal = SQL.fetchone()
if amount > int(result_userbal[0]):
await ctx.send(f"{ctx.message.author.mention}님! 당신의 배팅금액을 {result_userbal[0]} {C_NAME}보다 높게 설정하셨어요!")
return
if randomNum==1:
await ctx.send("배팅중....")
await asyncio.sleep(0.7)
await ctx.message.add_reaction("💵")
await asyncio.sleep(0.7)
await ctx.message.add_reaction("💴")
await asyncio.sleep(0.7)
await ctx.message.add_reaction("💶")
SQL.execute('create table if not exists Accounts("Num" integer primary key autoincrement,"user_name" text, "user_id" integer not null, "balance" real)')
SQL.execute(f'select user_id from Accounts where user_id="{USER_ID}"')
result_userID = SQL.fetchone()
SQL.execute('update Accounts set balance = balance + ? where user_id = ?', (amount, USER_ID))
db.commit()
await ctx.send(f"{ctx.message.author.mention}님이 배팅에 성공하셔서 {amount} {C_NAME}를 받으셨습니다.")
await ctx.message.add_reaction("💰")
else:
await ctx.send("배팅중....")
await asyncio.sleep(0.7)
await ctx.message.add_reaction("💵")
await asyncio.sleep(0.7)
await ctx.message.add_reaction("💴")
await asyncio.sleep(0.7)
await ctx.message.add_reaction("💶")
SQL.execute('create table if not exists Accounts("Num" integer primary key autoincrement,"user_name" text, "user_id" integer not null, "balance" real)')
SQL.execute(f'select user_id from Accounts where user_id="{USER_ID}"')
result_userID = SQL.fetchone()
SQL.execute('update Accounts set balance = balance - ? where user_id = ?', (amount, USER_ID))
db.commit()
await ctx.send(f"{ctx.message.author.mention}님이 배팅에 실패하셔서 {amount} {C_NAME}를 잃으셨습니다.")
await ctx.message.add_reaction("💸")
@bot.command(pass_context=True, brief="룰렛")
async def 돈지급(ctx):
amount = 1000
moneyd = 1
USER_ID = ctx.message.author.id
USER_NAME = str(ctx.message.author)
SQL.execute('create table if not exists Accounts("Num" integer primary key autoincrement,"user_name" text, "user_id" integer not null, "balance" real)')
SQL.execute(f'select user_id from Accounts where user_id="{USER_ID}"')
result_userID = SQL.fetchone()
result_userID = SQL.fetchone()
SQL.execute(f'select balance from Accounts where user_id="{USER_ID}"')
result_userbal = SQL.fetchone()
if result_userID is None:
SQL.execute('insert into Accounts(user_name, user_id, balance) values(?,?,?)', (USER_NAME, USER_ID, START_BALANCE))
await ctx.send(f"{ctx.message.author.mention}님! {C_NAME}에 가입이 안되있으셔서 시작금액을 지급해드렸어요.")
db.commit()
return
if moneyd > int(result_userbal[0]):
await ctx.send(f"{ctx.message.author.mention}님의 {C_NAME}이 없으셔서 {amount} {C_NAME}를 지급해드렸어요.")
SQL.execute('update Accounts set balance = balance + ? where user_id = ?', (amount, USER_ID))
db.commit()
return
else:
await ctx.send(f"{ctx.message.author.mention}님은 {C_NAME}가 있어요.")
@bot.command(pass_context=True, brief="돈을 송금합니다.", aliases=["전송"])
async def 송금(ctx, other: discord.Member, amount: int):
if amount < 0:
await ctx.send("-는 사용하실 수 없습니다!.")
return
USER_ID = ctx.message.author.id
USER_NAME = str(ctx.message.author)
OTHER_ID = other.id
OTHER_NAME = str(other)
SQL.execute('create table if not exists Accounts("Num" integer primary key autoincrement,"user_name" text, "user_id" integer not null, "balance" real)')
SQL.execute(f'select user_id from Accounts where user_id="{USER_ID}"')
result_userID = SQL.fetchone()
SQL.execute(f'select user_id from Accounts where user_id="{OTHER_ID}"')
result_otherID = SQL.fetchone()
if result_userID is None:
SQL.execute('insert into Accounts(user_name, user_id, balance) values(?,?,?)', (USER_NAME, USER_ID, START_BALANCE))
db.commit()
if result_otherID is None:
SQL.execute('insert into Accounts(user_name, user_id, balance) values(?,?,?)', (OTHER_NAME, OTHER_ID, START_BALANCE))
db.commit()
SQL.execute(f'select balance from Accounts where user_id="{USER_ID}"')
result_userbal = SQL.fetchone()
if amount > int(result_userbal[0]):
await ctx.send(f"{ctx.message.author.mention}님의 잔액은 {amount} {C_NAME}보다 적어서 보낼 수 없어요.")
return
SQL.execute('update Accounts set balance = balance - ? where user_id = ?', (amount, USER_ID))
db.commit()
SQL.execute('update Accounts set balance = balance + ? where user_id = ?', (amount, OTHER_ID))
db.commit()
await ctx.send(f"{ctx.message.author.mention}님이 {other.mention}님에게 {amount} {C_NAME}를 보냈습니다.")
@bot.command(pass_context=True, brief="순위를 보여줍니다.")
async def 순위(ctx):
try:
SQL.execute(f"select user_name, balance from Accounts order by balance desc")
result_top10 = SQL.fetchmany(10)
embed = discord.Embed(
colour=discord.Colour.gold()
)
embed.set_author(name="순위")
embed.add_field(name="#1", value=f"이름: {result_top10[0][0]} 잔액: {result_top10[0][1]}", inline=False)
embed.add_field(name="#2", value=f"이름: {result_top10[1][0]} 잔액: {result_top10[1][1]}", inline=False)
embed.add_field(name="#3", value=f"이름: {result_top10[2][0]} 잔액: {result_top10[2][1]}", inline=False)
embed.add_field(name="#4", value=f"이름: {result_top10[3][0]} 잔액: {result_top10[3][1]}", inline=False)
embed.add_field(name="#5", value=f"이름: {result_top10[4][0]} 잔액: {result_top10[4][1]}", inline=False)
embed.add_field(name="#6", value=f"이름: {result_top10[5][0]} 잔액: {result_top10[5][1]}", inline=False)
embed.add_field(name="#7", value=f"이름: {result_top10[6][0]} 잔액: {result_top10[6][1]}", inline=False)
embed.add_field(name="#8", value=f"이름: {result_top10[7][0]} 잔액: {result_top10[7][1]}", inline=False)
embed.add_field(name="#9", value=f"이름: {result_top10[8][0]} 잔액: {result_top10[8][1]}", inline=False)
embed.add_field(name="#10", value=f"이름: {result_top10[9][0]} 잔액: {result_top10[9][1]}", inline=False)
await ctx.send(embed=embed)
except:
embed = discord.Embed(
colour=discord.Colour.gold()
)
embed.set_author(name="오류!")
embed.add_field(name="``죄송합니다.``", value="DUST를 이용하는 사람이 최소 10명 이상이 되야지 순위를 보여드릴 수 있어요.", inline=False)
await ctx.send(embed=embed)
@bot.command()
async def about(ctx):
embed = discord.Embed(colour=discord.Colour.gold())
embed.set_author(name="DUST란")
embed.add_field(name="``about``", value="DUST는 가상으로 만든 디스코드 코인입니다. ``가치 없음``", inline=False)
embed.set_footer(text="먼지#3536")
await ctx.send(embed=embed)
@bot.command()
async def 도움말(ctx):
embed = discord.Embed(colour=discord.Colour.gold())
embed.set_author(name="도움말")
embed.add_field(name="``명령어``", value=".mjabout, .mj돈지급, .mj송금 [코인 갯수], .mj내지갑, .mj지갑 [@멘션 필수!], .mj순위, .mj배팅 [코인 갯수]", inline=False)
embed.add_field(name="``시작시 주의사항``", value=".mj내지갑을 치셔야지 정상적으로 시작가입금액 10000 DUST가 충전됩니다.", inline=False)
embed.set_footer(text="먼지#3536")
await ctx.send(embed=embed)
bot.run(TOKEN)