【发布时间】:2018-03-12 16:38:31
【问题描述】:
我正在尝试为 c# discord bot 制作 xp 系统,但我的 int 不会保存在命令之外,例如检查余额或购买其他需要我检查整数值的项目。我是否需要将此数据存储在 sql 数据库中,或者是否可以将其作为 int 保留在 Visual Studio 中。谢谢。
public class Buy : ModuleBase<SocketCommandContext>
{
int coins = 24;
int coins2buymeme = 23;
[Command("buyrole")]
public async Task Ishoping (IGuildUser user, IRole role)
{
string invite_code = "you have sucesfully purchased the " + role + " role for " + coins2buymeme + " coins !!!";
await Context.Channel.SendMessageAsync(invite_code);
await user.AddRoleAsync(role);
Console.WriteLine("User bought" + role + "for" + coins2buymeme + "if you are not happy with this decision please change there roles on server manually");
this.coins -= coins2buymeme;
Console.WriteLine("your new balance is " + this.coins + " if you are not happy with this decision please change there roles on server manually");
const int delay = 90000;
string bought = "your new balance is " + this.coins + " if you are not happy with this decision please change there roles on server manually";
await Context.Channel.SendMessageAsync(bought);
}
[Command("refund")]
public async Task Ishopidang(IGuildUser user, IRole roles)
{
string invite_code = "you have sucesfully refunded the " + roles + " role for " + coins2buymeme + " coins !!!";
await Context.Channel.SendMessageAsync(invite_code);
await user.RemoveRoleAsync(roles);
Console.WriteLine("User refunded" + roles + "for" + coins2buymeme + "if you are not happy with this decision please change there roles on server manually");
}
[Command("balance")]
public async Task Ishopiddang(IGuildUser user)
{
await Context.Channel.SendMessageAsync("you have " + this.coins + " to spend use !shop to find out more");
Console.WriteLine("User has " + this.coins + "if you are not happy with this decision please change there roles on server manually");
}
}
}
【问题讨论】:
-
你指的是什么
int? -
硬币 int,这样当用户购买 meme 角色时,硬币数量会减少,他们将能够在余额中看到它。