我正在尝试将公会放在存在Discord bot的情况下,但我不明白,版本是v12,这是我的代码。示例(观看76台服务器)
public partial class test2 : Form
{
SqlConnection con = new SqlConnection("Server=.\\sqlexpress;Initial Catalog=test;Persist Security Info=True;User ID=sa;Password=Rfl@123");
public test2()
{
InitializeComponent();
getRegion();
int i;
}
public void getRegion()
{
con.Open();
SqlCommand cmd1 = new SqlCommand("sptblRegion", con);
cmd1.CommandType = CommandType.StoredProcedure;
SqlDataAdapter sda = new SqlDataAdapter(cmd1);
DataTable dt = new DataTable();
sda.Fill(dt);
DataRow dr = dt.NewRow();
dr["Region_Name"] = "Select Region";
dr["Region_ID"] = 0;
dt.Rows.InsertAt(dr, 0);
comboBox1.ValueMember = "Region_Id";
comboBox1.DisplayMember = "Region_Name";
comboBox1.DataSource = dt;
con.Close();
}
public void getState()
{
if (comboBox1.SelectedValue.ToString() != null)
{
con.Close();
con.Open();
SqlCommand cmd1 = new SqlCommand("sptblState", con);
cmd1.CommandType = CommandType.StoredProcedure;
cmd1.Parameters.AddWithValue("@Region_Id", comboBox1.SelectedValue.ToString());
SqlDataAdapter sda = new SqlDataAdapter(cmd1);
DataTable dt2 = new DataTable();
sda.Fill(dt2);
comboBox2.ValueMember = "State_ID";
comboBox2.DisplayMember = "State_Name";
comboBox2.DataSource = dt2;
con.Close();
}
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
getState();
}
public void getZone()
{
if (comboBox2.SelectedValue.ToString() != null)
{
con.Close();
con.Open();
SqlCommand cmd2 = new SqlCommand("sptblZone", con);
cmd2.CommandType = CommandType.StoredProcedure;
cmd2.Parameters.AddWithValue("@State_ID", comboBox2.SelectedValue.ToString());
SqlDataAdapter sda = new SqlDataAdapter(cmd2);
DataTable dt3 = new DataTable();
sda.Fill(dt3);
comboBox3.ValueMember = "Zone_ID";
comboBox3.DisplayMember = "Zone_Name";
comboBox3.DataSource = dt3;
con.Close();
}
}
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
{
getZone();
}
private void button1_Click(object sender, EventArgs e)
{
con.Open();
SqlCommand cmd = new SqlCommand("spRSZ", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Action", "Insert");
cmd.Parameters.AddWithValue("@Region", comboBox1.DisplayMember);
cmd.Parameters.AddWithValue("@State", comboBox2.DisplayMember);
cmd.Parameters.AddWithValue("@Zone", comboBox3.DisplayMember);
con.Close();
}
}
示例图片:
答案 0 :(得分:1)
我假设您正在尝试显示机器人所在的行会数量。
client.user.setPresence({
status: 'online',
activity: {
name: `${client.guilds.cache.size} servers`,
type: 'WATCHING'
}
)
或者,如果您不更改客户端状态(默认为online
,则可以使用setActivity
:
client.user.setActivity(`${client.guilds.cache.size} servers`, {type: 'WATCHING'})